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.
+关注继续查看

工具原料:

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的目录结构及访问规则,创建第一个控制器

目录
相关文章
|
2月前
|
负载均衡 算法 Unix
nginx学习使用
nginx学习使用
40 0
|
2月前
|
消息中间件 缓存 负载均衡
五分钟快速学习Nginx
五分钟快速学习Nginx
32 0
|
3月前
|
Java 应用服务中间件 nginx
nginx限流配置理解与学习
nginx限流配置理解与学习
77 0
|
3月前
|
缓存 负载均衡 应用服务中间件
Nginx+Tomcat 反向代理负载均衡 配置 学习(1)
Nginx+Tomcat 反向代理负载均衡 配置学习 #user nobody; worker_processes 1;
82 0
|
3月前
|
存储 缓存 负载均衡
我在学习Nginx的时候认识的cookie和session,有什么不同?
我在学习Nginx的时候认识的cookie和session,有什么不同?
61 0
|
4月前
|
tengine 应用服务中间件 网络安全
nginx学习(核心配置详解)
nginx学习(核心配置详解)
84 0
|
7月前
|
应用服务中间件 Linux nginx
Nginx学习(二):反向代理案例
这个案例期望实现的效果:打开浏览器,在地址栏输入www.123.com,跳转到linux系统Tomcat主页面中。
Nginx学习(二):反向代理案例
|
7月前
|
应用服务中间件 Linux nginx
Nginx学习(一):Linux下安装Nginx
Nginx学习(一):Linux下安装Nginx
126 0
Nginx学习(一):Linux下安装Nginx
|
8月前
|
运维 Unix 应用服务中间件
深入浅出学习透析 Nginx 服务器的基本原理和配置指南「运维操作实战篇」
深入浅出学习透析 Nginx 服务器的基本原理和配置指南「运维操作实战篇」
506 0
深入浅出学习透析 Nginx 服务器的基本原理和配置指南「运维操作实战篇」
|
9月前
|
PHP
宝塔的nginx.在Thinkphp伪静态情况下配置图片裁剪
宝塔的nginx.在Thinkphp伪静态情况下配置图片裁剪
134 0
相关产品
云迁移中心
推荐文章
更多