ThinkPHP学习(一) Windows下Nginx+PHP5+ThinkPHP_3.2.1的安装与配置

工具原料:

Nginx153:

网盘下载地址:http://pan.baidu.com/s/1qWNgLf2

php-5.3.28-nts-Win32-VC9-x86

网盘下载地址:http://pan.baidu.com/s/1pdukY

ThinkPHP_3.2.1

网盘下载地址:http://pan.baidu.com/s/1pJlpfuj

RunHiddenConsole是一个用来隐藏 DOS窗口的小程序

网盘下载地址:http://pan.baidu.com/s/1gd7kApP

开始安装,其实就是解压文件:

解压Nginx到“F:\Nginx153”;

解压RunHiddenConsole到“F:\Nginx153”;

解压PHP5到“F:\PHP\php5328Win32”;

解压ThinkPHP到“F:\PHP”;

修改PHP配置文件

修改“F:\PHP\php5328Win32”目录下的文件“php.ini-development”的文件名,把“-development”去掉就可以,文件内容先不做任何修改。

修改Nginx配置文件

用文本编辑器,本人使用Notepad++打开“F:\Nginx153\conf”目录下的“Nginx.conf”文件,

配置文件内容如下,重点位置用中文简单注释了一下:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80; #//端口号
        server_name  localhost; #//域名,主机头值

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   F:\\www\\html; #//站点根目录
            index  index.html index.htm index.php; #//默认页
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           F:\\PHP;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

		#ThinkPHP配置
		location ~ .*\.php.* {
			root           F:\\PHP; #//ThinkPHP框架文件位置
			fastcgi_pass	127.0.0.1:9000;
			fastcgi_index	index.php;
			include	fastcgi.conf;
			set	$real_script_name	$fastcgi_script_name;
			fastcgi_param	SCRIPT_FILENAME	$document_root$fastcgi_script_name;
			fastcgi_param	SCRIPT_NAME		$real_script_name;
			fastcgi_param	PATH_INFO		$path_info;
			if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
				set	$real_script_name	$1;
				set	$path_info	$2;
			}
		}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

创建启动服务批处理(.bat)文件,文件名“start_nginx.bat”,文件内容如下:

@echo off
echo Starting PHP FastCGI...
RunHiddenConsole ../php/php5328Win32/php-cgi.exe -b 127.0.0.1:9000 -c ../php/php5328Win32/php.ini
echo Starting nginx...
nginx.exe

pause

创建停止服务批处理(.bat)文件,文件名“stop_nginx.bat”,文件内容如下:

@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

见证奇迹的时刻:

双击“start_nginx.bat”启动服务,会打开一个DOS窗口,最小化或关闭即可;

打开浏览器,在地址栏输入“http://localhost/index.php”,回车,看到几个大字了吗?

欢迎使用ThinkPHP!

恭喜你,环境配置成功了!

下一篇:ThinkPHP学习(二)理清ThinkPHP的目录结构及访问规则,创建第一个控制器

时间: 2024-08-03 18:15:39

ThinkPHP学习(一) Windows下Nginx+PHP5+ThinkPHP_3.2.1的安装与配置的相关文章

Windows下Nginx+PHP5的安装与配置方法_nginx

以下是我在 Windows 2003 安装中 Nginx 和 PHP5.2 的步骤,但windows版本的nginx性能要比Linux/Uninx版本的Nginx差太多. 安装 PHP5首先,从 http://www.php.net/downloads.php 下 载最新的 PHP5.2.9-2 Windows 版本,解压至 C:\php,把压缩包中的 php.ini-recommended,更名为 php.ini,然后打开修改几个选项: error_reporting = E_ALLdispl

Windows下Nginx + PHP5 的安装与配置方法_nginx

安装 PHP5 首先,从 http://www.php.net/downloads.php 下载最新的 PHP 5.3 Windows 版本,解压至 C:\php5,把压缩包中的 php.ini-recommended,更名为 php.ini,然后打开修改几个选项: 复制代码 代码如下: error_reporting = E_ALL display_errors = On extension_dir = "C:\php5\ext" ; 动态扩展,可以根据需要去掉 extension

Windows下Nginx的启动、停止等命令&Nginx 配置多域名&windows下设置Nginx开机自动启动

Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍. 1.启动: C:\server\nginx-1.0.2>start nginx 或 C:\server\nginx-1.0.2>nginx.exe 注:建议使用第一种,第二种会使你的cmd窗口一直处于执行中,不能进行其他命令操作. 2.停止: C:\server\nginx-1.0.2>ngin

Windows下Nginx的安装与配置

Windows下Nginx的安装与配置 Nginx ("engine x") 是一款高性能的,轻量级的HTTP Web 服务器 和 反向代理服务器及电子邮件 IMAP/POP3/SMTP 代理服务器. Nginx 是由俄罗斯的程序设计师 Igor Sysoev 所开发,为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过四年多时间了,Igor 将源代码以类BSD许可证的形式发布. 自 Nginx 发布四年来,Nginx 已经因它的稳定性.丰富的功能集.示例配置

Windows下Apache+Tomcat+MySQL+jsp+php的服务器整合配置经验总结

apache|js|mysql|window|服务器 Windows下Apache+Tomcat+MySQL+jsp+php的服务器整合配置经验总结 1.作者:moonsbird 题目:Windows下Apache+Tomcat+MySQL+jsp+php的服务器整合配置经验总结 时间:2004.8.19 最初发表于西南交通大学锦城驿站 2.本文是作者学习几年来学习jsp/配置服务器环境的经验总结.可以转载,但请注明出处. 开始学习jsp很久了,网上有许多关于jsp整合的例子,但存在着许多问题.

《高性能Linux服务器构建实战》——1.8节实战Nginx与Perl、Java的安装与配置

1.8 实战Nginx与Perl.Java的安装与配置 通过前面的介绍,可以对Nginx有了一个比较全面的认识:Nginx本身是一个静态的HTTP服务器和反向代理服务器,它不支持动态页面,所谓的Nginx对动态程序的支持都是通过反向代理功能实现的.下面要讲述的Nginx对Perl和JSP的支持,就是通过Nginx的反向代理功能来完成的.Nginx对Perl和JSP的支持在实现细节上可能有一定差别,但是实现原理是完全一样的. Nginx的安装这里不再讲述,假定Nginx的安装路径为/usr/loc

windows下nginx安装、配置与使用_nginx

目前国内各大门户网站已经部署了Nginx,如新浪.网易.腾讯等:国内几个重要的视频分享网站也部署了Nginx,如六房间.酷6等.新近发现Nginx 技术在国内日趋火热,越来越多的网站开始部署Nginx.     相比apeach.iis,nginx以轻量级.高性能.稳定.配置简单.资源占用少等优势广受欢迎. 1)下载地址: http://nginx.org 2)启动 解压至c:\nginx,运行nginx.exe(即nginx -c conf\nginx.conf),默认使用80端口,日志见文件

windows 下 nginx+iis 实现负载均衡方案

nginx安装 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用.其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度.新浪.网易.腾讯等. 最新版本的nginx版本为1.9.3,我这下载的是window版本的

windows下nginx+tomcat配置负载均衡的方法_nginx

目标:Nginx做为HttpServer,连接多个tomcat应用实例,进行负载均衡. 注:本例程以一台机器为例子,即同一台机器上装一个nginx和2个Tomcat且安装了JDK1.7. 1.安装Nginx 安装Nginx教程 2.配置两个Tomcat 在本机上配置两个Tomcat,分别为tomcat7-8081.tomcat7-8082. tomcat7-8081访问地址:http://localhost:8081,浏览显示内容:this is 8081 port tomcat7-8082访问