The first part: preparation work. (System: Windows 8.1)
1. First, download the software.
NGINX-1.3.8 official website Download: http://nginx.org/en/download.html
PHP5.4.8 version: http://windows.php.net/download/
Mysql5.5.28 version: http://www.mysql.com/downloads/mysql/
2. Install the MySQL software.
3. Unzip the Nginx and PHP to your own installation location. Here I create a new folder in the C drive: Wnmp (windows,ngnix,myspq,php), install the following software into this folder.
Nginx Directory C:\wnmp\nginx
PHP directory C:\wnmp\php
Part Two: Installing Nginx
1. Open the C:\nginx directory and run the Nginx.exe under this folder
2. Test if Nginx is activated. Open the browser to access http://localhost or http://127.0.0.1 to see if "Welcome to nginx!" appears, the proof has been started successfully. If not, see if Port 80 is occupied.
Note: The default directory for this site is under "C:\wnmp\nginx\htm" L
Part III: Install PHP (here is the main nginx configuration to start PHP, to run PHP with CGI)
The Nginx configuration file is the nginx.conf in the Conf folder.
1. Modify the approximate 43rd to 45th line
Location/{ root html; Index index.html index.htm;}
Modify the path to the Web site file, and add the default page for index.php.
Location/{ root d:/wnmp/nginx-1.5.8/html; Index index.html index.htm inde.php; }
2. Support for PHP settings
Modified about the 第63-71 line.
# 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 the "#" is removed, the same root HTML, to root c:/wnmp/nginx-1.5.8/html;. Then the "/scripts" to "$document _root", where the "$document _root" refers to the front "root" refers to the site path, which is changed after:
# 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.c:\wnmp\php\ext Modify the Php.ini-development file, change the file name to PHP.ini, open the PHP configuration file php.ini, save.
Search "Extension_dir", find: E;xtension_dir = "ext" First to go to the front of the semicolon and then change to Extension_dir = "C:\wnmp\php\ext"
Search "Date.timezone", find:;d Ate.timezone = First go to the front semicolon and change to Date.timezone = Asia/shanghai
Search "Enable_dl", find: Enable_dl = Off to Enable_dl = On
Search "Cgi.force_redirect"; cgi.force_redirect = 1 First go to the front semicolon and change to Cgi.force_redirect = 0
Search "Fastcgi.impersonate", find:; fastcgi.impersonate = 1 Remove the preceding semicolon
Search "Cgi.rfc2616_headers", find:; cgi.rfc2616_headers = 0 First, go to the front semicolon and change to Cgi.rfc2616_headers = 1
Search for "Php_mysql" and find: "Extension=php_mysql.dll and Extension=php_mysqli.dll remove the front"; Extension=php_mysql.dll and Extension=php_mysqli.dll (MySQL database support)
Other configurations should be changed according to your needs.
Part III trial run and edit run configuration file
c:\wnmp\php-5.5.7-nts-win32-vc11-x86>PHP-CGI. -127.0. 0.1:9000-c C:\wnmp\php-5.5.7-nts-Win32-VC11-x86\php. INI
Re-run Nginx.exe.
C:\wnmp\nginx-1.5.8\html a new phpinfo.php,
<?php phpinfo ();?>
Visit http://localhost/phpinfo.php
or http://127.0.0.1/phpinfo.php.
The following information appears to indicate that PHP has been successfully installed:
Download a RunHiddenConsole.exe, Baidu network disk.
Open php-cgi and Nginx.exe, save 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-cgi and Nginx.exe, save as Stop.bat
@echo Offecho stopping nginx...taskkill/f/im nginx.exe > Nulecho stopping PHP fastcgi...taskkill/f/im Php-cgi.exe & Gt Nulexit
Under Windows configuration nginx+php (WNMP)