Thinkphp Learning (i) installation and configuration of nginx+php5+thinkphp_3.2.1 under Windows
Tool Material:
Nginx153:
Download the Web drive address: http://pan.baidu.com/s/1qWNgLf2
Php-5.3.28-nts-win32-vc9-x86
Download the Web drive address: Http://pan.baidu.com/s/1pdukY
thinkphp_3.2.1
Download the Web drive address: Http://pan.baidu.com/s/1pJlpfuj
Runhiddenconsole is a small program used to hide DOS windows.
Download the Web drive address: Http://pan.baidu.com/s/1gd7kApP
To start the installation, is actually the decompression file:
Decompression Nginx to "F:\Nginx153";
Unzip the runhiddenconsole to "F:\Nginx153";
Unzip the PHP5 to "F:\PHP\php5328Win32";
Unzip the thinkphp to "F:\PHP";
Modify PHP configuration file
Modify the "F:\PHP\php5328Win32" Directory of the file "php.ini-development" file name, the "-development" is removed, the contents of the file will not be modified first.
modifying Nginx configuration Files
With a text editor, I use notepad++ to open the "nginx.conf" file in the "F:\Nginx153\conf" directory,
The contents of the configuration file are as follows, the key position is briefly commented in Chinese:
#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; #//port number server_name localhost; #//domain name, host header value #charset koi8-r; #access_log Logs/host.access.log Main; Location/{root f:\\www\\html; #//site root index index.html index.htm index.php; #//default Page} #error_page 404/404.html; # REDIRECT Server errorPages to the static page/50x.html # Error_page 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$ {# ProX Y_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 frame file location Fastcgi_pass127.0.0.1:9000;fastcgi_indexindex. php;includefastcgi.conf;set$real_script_name$fastcgi_script_name;fastcgi_paramscript_filename$document_root$ Fastcgi_script_name;fastcgi_paramscript_name$real_script_name;fastcgi_parampath_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; # } #}}
Create a Start service batch (. bat) file with the file name "Start_nginx.bat", which reads as follows:
@echo Offecho starting PHP FastCGI ... Runhiddenconsole. /php/php5328win32/php-cgi.exe-b 127.0.0.1:9000-c. /php/php5328win32/php.iniecho starting Nginx...nginx.exepause
Create a Stop service batch (. bat) file with the file name "Stop_nginx.bat", which reads as follows:
@echo Offecho stopping nginx...taskkill/f/im nginx.exe > Nulecho stopping PHP fastcgi...taskkill/f/im Php-cgi.exe & Gt Nulexit
Time To witness miracles:
Double click "Start_nginx.bat" to start the service, will open a DOS window, minimize or close;
Open the browser, enter the "http://localhost/index.php" in the Address field, enter, see a few characters?
Welcome to use thinkphp !
Congratulations, the environment has been successfully configured!