1. The application package to be prepared first. Nginx: nginxWindows-1.0.4php: php-5.2.16-nts-Win32-VC6-x86.zip (nginx php is run in FastCGI mode, so we download non-thread security is the php package of ETS) (also used) RunHiddenConsole: runHiddenConsole.zip 2. installation and configuration. 1
1. The application package to be prepared first. Nginx: nginx/Windows-1.0.4 php: php-5.2.16-nts-Win32-VC6-x86.zip: runHiddenConsole.zip 2. installation and configuration. 1
1. The application package to be prepared first.
Nginx: nginx/Windows-1.0.4
Php: php-5.2.16-nts-Win32-VC6-x86.zip (php under nginx is run in FastCGI mode, so we download non-thread security, that is, the php package of ETS)
(Also used) RunHiddenConsole: RunHiddenConsole.zip
2. installation and configuration.
1) install and configure php.
Directly decompress the downloaded php package to the wnmp directory (D: \ wnmp) on the D Drive. Here, rename the decompressed folder to php5. Go to the folder and modify the php. ini-recommended file to php. ini, and open it with Editplus or Notepad ++. Find
extension_dir = "./ext"
Change
extension_dir = "D:/wnmp/php5/ext"
Look down and find again
;extension=php_mysql.dll;extension=php_mysqli.dll
After specifying the php ext path, you only need to remove the ";" corresponding to the extension package. Open php_mysql.dll and php_mysqli.dll to allow php to support mysql. Of course, do not forget the important step is to put libmysql under the php5 directory. copy the dll file to the C: \ Windows directory. You can also specify the path in the system variables. Of course, here I chose a more convenient method ^_^.
Now, php supports mysql.
Next we will configure php so that php can be combined with nginx. Find
;cgi.fix_pathinfo=1
We will remove the title here.
cgi.fix_pathinfo=1
This step is very important. Here is the CGI setting of php.
2) install and configure nginx.
Decompress the downloaded nginx-1.0.4 package to the wnmp directory of the d disk and rename it nginx. Next, configure nginx to work with php. Go to the nginx conf directory, open the nginx configuration file nginx. conf, and find
Location/{root html; # Here is the site's root directory index index.html index.htm ;}
Change root html; To root D:/wnmp/www;
Next, find
# 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 "#" And change root html; To root D:/wnmp/www ;. Change the/scripts marked in red to "$ document_root". Here, "$ document_root" refers to the site path referred to by "root". This is changed:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ { root D:/wnmp/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}
Save the configuration file.
The nginx + php environment has been initially configured. We can enter the command
To start php and manually start nginx. Of course, you can also use the script.
First, decompress the downloaded runhiddenconsole.zippackage to the nginxdirectory. runhiddenconsole.exe automatically closes the script after executing the command line script, but the process enabled from the script is not closed. Create a script named "start_nginx.bat". Edit it in Notepad ++.
@ Echo offREM in Windows the REM set PHP_FCGI_CHILDREN is invalid = 5REM the maximum number of requests processed by each process, or set it to the Windows environment variable set PHP_FCGI_MAX_REQUESTS = 1000 echo Starting PHP FastCGI... runHiddenConsole D:/wnmp/php5/php-cgi.exe-B 127.0.0.1: 9000-c D:/wnmp/php5/php. ini echo Starting nginx... runHiddenConsole D:/wnmp/nginx/nginx.exe-p D:/wnmp/nginx
Create another script named stop_nginx.bat to disable nginx.
@echo offecho Stopping nginx... taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit
This is the case.
In this way, all our service scripts have been created. Double-click start_nginx.batto check whether the process manager has two nginx.exepaths and a php-cgi.exe process?
In this way, the nginx service is started and php runs in fastCGI mode.
Go to the site directory, create a phpinfo. php file, and edit it in it.
After saving, open the browser and enter "http: // localhost/phpinfo. php". If you see
The nginx + php environment has been configured ~
Problems I encountered during installation:
1. I have installed apache and used port 80. What should I do?
Solution: Method 1: If you do not want to change the nginx http default port (that is, 80), do not start apache when using nginx.
Method 2: Modify the listen port value under the server (for example, my listen 81) in nginx. conf to access the webpage using apache and nginx at the same time.
2. nginx can be started normally. You can access the page http: // 127.0.0.1: 81/index.html, but cannot access the PHP file ???
My configuration is all configured by a dedicated user, but I find that php-cgi.exe cannot be started in the resource manager. Why ???
Find the cause: Enter netstat-anob In the cmd command window to check that port 9000 is occupied by KugouService, so it cannot be started properly. Close codoy and click start_nginx.bat. Everything is OK.
After nginx is installed, you can check whether the nginx and mysql are properly installed. Check the phpinfo () information, check whether php and nginx are properly connected, run the php file, and do it manually !!!!