Recently try to configure nginx+ph under Windows and summarize here.
1, download the Windows version of Nginx, official website?: http://nginx.org/en/download.htm
Download the Windows version of PHP, official website: http://windows.php.net/download/,php will be run in CGI mode
? 2, configure PHP
Unzip the downloaded PHP package to the F-disk Wnmp directory (D:\WNMP) and rename the extracted folder to PHP5. Go to Folder modify Php.ini-development file to PHP.ini?.
、
Open PHP.ini and find the following code
Extension_dir ="./ext" changes to Extension_dir ="d:/wnmp/php5/ext".
; extension=php_mysql.dll; extension=php_mysqli.dll Remove the preceding semicolon (Open database dynamic link library)
Then copy the Libmysql.dll file from the PHP5 directory to the C:\Windows directory, or set the environment variable path, and find the following code
Cgi.fix_pathinfo=0 Remove the front semicolon and change it to cgi.fix_pathinfo=1 .
3. Configure Nginx
After unpacking, open the nginx.conf file in the Conf directory to find
Location/{root HTML; Index index.html index.htm; } #error_page404/404. html; # REDIRECT Server error pages to theStaticPage/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root html; } # Proxy The PHP scripts to Apache listening on127.0.0.1: the# #location~\.php$ {# Proxy_pass http://127.0.0.1;#} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000; # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name; # include Fastcgi_params; #}
Switch
Location/{root d:/www; Set your own directory index index.html index.htm; } error_page404/404. html; Redirect Server error pages to theStaticPage/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root d:/www; } proxy the PHP scripts to Apache listening on127.0.0.1: the Location~\.php$ {proxy_pass http://127.0.0.1;} pass the PHP scripts to FastCGI server listening on127.0.0.1:9000 Location~\.php$ {root d:/www; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root $fastcgi _script_name; Include Fastcgi_params; }
Save the configuration file.
4. Running Nginx and PHP
Enter the command:
127.0. 0.1:9000 -C D:/wnmp/php5/php.ini
Run PHP in CGI to listen for nginx data sent from Port 9000. Double-click Nginx.exe to run Nginx.
Quick Launch settings: First download RunHiddenConsole.exe this file into the Nginx directory, and then save the following code as Start_nginx.bat
@echo off set php_home=. /php/set nginx_home=./echo starting php FastCGI ... 127.0. 0.1:9000 -c%php_home%/php.ini echo starting Nginx ... %nginx_home%/nginx.exe-p%nginx_home%Exit
Save the following code as Stop_nginx.bat
@echo off echo stopping Nginx ... /f/im nginx.exe > nul echo stopping PHP FastCGI ... /f/im php-cgi.exe > nul exit
The final file is this, double-click Start_nginx.bat can start Nginx and PHP.
Configuring WNMP under Windows