1. Download and install nginx:
Nginx official website:http://nginx.org/en/download.html
Download any version (I downloaded the stable1.12.1 version) extracted to the D:\wnmp\nginx(own directory) directory, run the extracted directory under the Nginx.exe, visit
http://localhost or http://127.0.0.1 , the following interface instructions appear Nginx installed successfully:
]
If 403 Forbiddenappears, the portmay be occupied, execute the following command at the command line view:Netstat-ano | Findstr "80"
If the port is actually occupied by other processes, you can modify the nginx configuration file D:\wnmp\nginx\conf\nginx.confto find Listen, Change to another unused port number
For example Listen 8080 , and then restart Nginx Access the http://localhost:8080.
2. Download the installation and configure php:
For the installation and configuration of PHP, you can refer to my other blog post-windows7 build wamp Environment , except here the installation path is D:\wnmp\php, the other operations are the same,
Don't repeat it here.
3. Configure nginx to support php:
Modify nginx configuration file D:\wnmp\nginx\conf\nginx.conf:
(1)
Location/{
root HTML;
Index index.html index.htm;
}
Switch
Location/{
Root d:/wnmp/nginx/html;
Index index.html index.htm index.php;
}
(2)
#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# Fastcgi_param Script_filename/scripts$fastcgi_script_name;
# include Fastcgi_params;
#}
Switch
Location ~ \.php$ {
Root d:/wnmp/nginx/html;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
4. Test if nginx successfully supports PHP:
This is different from Apache and requires both PHP and nginx to be open .
(1) command line to open php:
(2) command line open nginx:
(3) create a php file and access:
Create and edit a php file to be placed in the d:/wnmp/nginx/html directory, for example: Create a new phpinfo.php file, content:
<?php phpinfo ();?>
To access http://localhost/phpinfo.php( If you do not use port number to remember to add a port), the following interface shows Nginx PHP has been successfully supported :
Given the hassle of opening PHP and nginx at the same time , and opening php cmd The window can not be closed, the window is closed, PHP will be closed, a more convenient way to start and close both php and nginx .
Note: The following references are from https://www.inbeijing.org/archives/1181.
First you need to download a runhiddenconsole file, and then create a new two bat batch file with the following content:
Start_nginx.bat:
@echo off
REM Set php_fcgi_children=5
Set php_fcgi_max_requests=1000
Echo starting PHP FastCGI ...
Runhiddenconsole d:/wnmp/php/php-cgi.exe-b 127.0.0.1:9000-c D:/wnmp/php/php.ini
Echo starting Nginx ...
Runhiddenconsole d:/wnmp/nginx/nginx.exe-p D:/wnmp/nginx
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
Keep these two files in the same directory as the Runhiddenconsole file, and then click start_nginx.bat file to open php at the same time. with the Nginx , click Stop_nginx.bat They are closed at the same time.
Attach this three file download link (also from https://www.inbeijing.org/archives/1181, here to thank the blogger!) ):
Http://www.inbeijing.org/wp-content/uploads/2015/06/RunHiddenConsole.zip
5. Download and install mysql:
Also refer to my other blog post-windows7 to build the wamp Environment , which is not repeated here.
At this point,wnmp development environment successfully completed!
Windows Build Wnmp