First, download the relevant software
Nginx Download: http://nginx.org/en/download.html
Nginx Common Exceptions: http://feiger.cn/?p=2719
PHP Download: http://windows.php.net/download#php-7.0
Download runhiddenconsole:http://www.xdowns.com/soft/1/71/2012/soft_89261.html
Second, the configuration
nginx.conf file, my editing results are as follows, the specific configuration process to note what to see note:
server {
Listen 80;
server_name localhost;
CharSet Utf-8;
Location/{
Root D:\work\soft\php\www; #网站目录
Index index.html index.php; #加上对php的支持
AutoIndex on; #如果文件不存在列出目录结构;
}
Location ~ \.php$ {
Root D:\work\soft\php\www;
Fastcgi_param Script_filename D:\work\soft\php\www$fastcgi_script_name;
Fastcgi_index index.php;
Fastcgi_pass 127.0.0.1:9000;
Include Fastcgi_params;
}
}
PHP Configuration:
Specify the directory where docroot--php files are stored, that is, your documentroot. Doc_root = "F:/wamp/www"
The extended store directory extension_dir--changed to the real extension store address. Extension_dir = "./ext"
Default time zone change-added in [Date]: Date.timezone = asia/chongqing
Because the nginx need is the CGI way PHP, so the following several places is the key, otherwise nginx cannot open the PHP file:
ENABLE_DL = On
Cgi.force_redirect = 0
Cgi.fix_pathinfo=1
Fastcgi.impersonate = 1
Cgi.rfc2616_headers = 1
Iii. edit PHP and Nginx startup scripts:
@echo off
Set root=%~dp0
Set php_home=%root% ... /.. /php-7.0.6-win32-vc14-x86
Set nginx_home=%root%
Invalid under REM Windows
REM Set php_fcgi_children=5
REM the maximum number of requests processed per process, or set as Windows environment variable
Set php_fcgi_max_requests=1000
echo Starting PHP FastCGI ...%php_home%/php-cgi.exe-b 127.0.0.1:9000-c%php_home%/php.ini
Runhiddenconsole%php_home%/php-cgi.exe-b 127.0.0.1:9000-c%php_home%/php.ini
Echo Starting Nginx ...%nginx_home%/nginx.exe
Runhiddenconsole%nginx_home%/nginx.exe
If you are running during the report: You cannot start this program because the computer is missing VCRUNTIME140.dll attempt to reinstall the program to resolve this issue
32-bit version download address: http://download.microsoft.com/download/9/E/1/9E1FA77A-9E95-4F3D-8BE1-4D2D0C947BA2/enu_INREL/vcredistd14x86 /vc_redist.x86.exe
http://www.microsoft.com/en-us/download/details.aspx?id=46881
64-bit version download address: http://download.microsoft.com/download/9/E/1/9E1FA77A-9E95-4F3D-8BE1-4D2D0C947BA2/enu_INREL/ Vcredistd14x64/vc_redist.x64.exe
Iv. edit PHP and Nginx stop scripts:
@echo off
echo Stopping Nginx ...
taskkill/f/im nginx.exe > nul
echo Stopping PHP FastCGI ...
taskkill/f/im php-cgi.exe > nul
Exit
V. Create a index.php under D:\work\soft\php\www
<?php
2 echo "Hello php7!";
3?>
VI. Visit the browser
http://localhost/index.php