Configure nginx + php (wnmp) in Windows. Part 1: preparation. (System: Windows 8.1)
1. First, download the software.
NGINX-1.3.8 official website download
PHP5.4.8 version: http://windows.php.net/download/
Mysql5.5.28 version: http://www.mysql.com/downloads/mysql/
2. Install mysql software.
3. Decompress NGINX and PHP to your own installation location. Here, I create a new folder named wnmp (windows, ngnix, myspq, php) on drive C and install the following software in this folder.
NGINX directory C: \ wnmp \ nginx
PHP Directory C: \ wnmp \ php
Part 2: Install nginx
1. Open the C: \ nginxdirectory and run nginx.exe under the folder.
2. Test whether to start nginx. Open a browser and access http: // localhost or http: // 127.0.0.1 to see if "Welcome to nginx!" is displayed !", It indicates that the startup is successful. If it is not started, check whether port 80 is occupied.
Note: The default directory of the website is under "C: \ wnmp \ nginx \ htm" l.
Part 3: install php (Here we mainly talk about nginx configuration to start php and run php with cgi)
The nginx configuration file is nginx. conf In the conf folder.
1. Modify it by about 43rd ~ Between 45 rows
location /{ root html; index index.html index.htm;}
Modify the path of the website file and add the hosts page of index. php.
location / { root D:/wnmp/nginx-1.5.8/html; index index.html index.htm inde.php; }
2. Support for php settings
Modify
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #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; #}
First remove the previous "#", also change the root html; To root C:/wnmp/nginx-1.5.8/html ;. Change "/scripts" to "$ document_root". Here, "$ document_root" refers to the site path indicated by "root", which is changed:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root C:/wnmp/nginx-1.5.8/html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # include fastcgi_params; #}
3. Modify the php. ini-development file under \ wnmp \ php \ ext, change the file name to php. ini, open the php configuration file php. ini, and save the file.
Search for "extension_dir" and find: e; xtension_dir = "ext". Go to the semicolon and change it to extension_dir = "C: \ wnmp \ php \ ext"
Search for "date. timezone" and find:; date. timezone = Go To The semicolon before changing it to date. timezone = Asia/Shanghai.
Search "enable_dl" and find: enable_dl = Off TO enable_dl = On.
Search for "cgi. force_redirect"; cgi. force_redirect = 1 first go to the semicolon before changing it to cgi. force_redirect = 0
Search "fastcgi. impersonate" and find:; fastcgi. impersonate = 1. Remove the semicolon from the front.
Search for "cgi. rfc2616_headers" and find:; cgi. rfc2616_headers = 0 first, and then change it to cgi. rfc2616_headers = 1.
Search for "php_mysql" and find: "extension = php_mysql.dll and extension = php_mysqli.dll to remove the preceding"; "extension = php_mysql.dll and extension = php_mysqli.dll (MYSQL databases supported)
Modify other configurations as needed.
Part 3 test run and edit the running configuration file
C:\wnmp\php-5.5.7-nts-Win32-VC11-x86>php-cgi.exe -b 127.0.0.1:9000-c C:\wnmp\php-5.5.7-nts-Win32-VC11-x86\php.ini
Run nginx.exe again.
C: \ wnmp \ nginx-1.5.8 \ html to create a new phpinfo. php,
Access http: // localhost/phpinfo. php
Or http: // 127.0.0.1/phpinfo. php
The following information indicates that php has been successfully installed:
Download a runhiddenconsole.exe, Baidu Network Disk.
Open php-cgiand nginx.exe and save it as start. bat.
@echo offecho Starting PHP FastCGI...C:\wnmp\nginx\RunHiddenConsole.exe C:\wnmp\PHP\php-cgi.exe -b 127.0.0.1:9000-c D:\PHP\php.iniecho Starting nginx...C:\wnmp\nginx\RunHiddenConsole.exe D:/nginx/nginx.exe -p D:/nginx
Stop php-cgiand nginx.exe and save as stop. bat.
@echo offecho Stopping nginx...taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit