Before: Pre-planned directory structure
1. Installing Nginx
To the Nginx official website to download the latest stable version of Http://nginx.org/download/nginx-1.9.15.zip;
Decompression to the D:\WNMP\nginx;
Run the D:\WNMP\nginx\nginx.exe program test, open the browser to view http://127.0.0.1, see the following content, Nginx successfully run.
2. Install PHP
Download the latest stable version of PHP http://windows.php.net/downloads/releases/php-5.6.21-Win32-VC11-x64.zip on the PHP website
Unzip to D:\WNMP\php
Add the Php_home variable with the value D:\WNMP\php in the system's environment variable, append it to the path variable, and restart the computer after%php_home%.
After restarting, enter php-versoin at the cmd command prompt, and if the following message appears, PHP is installed successfully.
3. Configure Nginx
Common Nginx Commands:
Start Nginx//Startup service
Nginx-s Stop//Stop Nginx
Nginx-s Reload//Reload configuration file
Nginx-s quit//exit Nginx
Open the nginx.conf configuration file in the Conf folder under the Nginx directory.
Modify to the following configuration:
Will:
Location/{
root HTML;
Index index.html index.htm;
}
Switch
Location/{
Root d:/wnmp/nginx/html;
Index index.html index.htm index.php;
}
Will:
#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;
}
Notice the change of Fastcgi_param script_filename $document _root$fastcgi_script_name;
This configuration allows Nginx to hand PHP requests to fastcgi that run on port 9000 PHP.
4. Configure PHP
D:\WNMP\php 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 = "D:\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 Please change according to your needs
Test:
D:\wnmp\php>php-cgi.exe-b 127.0.0.1:9000-c D:\WNMP\PHP\php.ini
Create a new info.php file in the D:\WNMP\Nginx\html directory, enter: <?php phpinfo ();?>
Open the browser and enter the http://127.0.0.1/info.php test.
5. Install the configuration MySQL
Download Mysql-5.7.12-winx64.zip to MySQL website and unzip it to D:\WNMP\MySQL.
Add the Mysql_home variable with the value D:\MySQL in the system's environment variable, append it to the path variable, and restart the computer after%mysql_home%\bin.
In the D:\WNMP\MySQL directory, copy the My-default.ini to My.ini, modify the My.ini file, and replace [mysqld] with the content
[Client]
Port = 3306
[MySQL]
Default-character-set = UTF8
[Mysqld]
Basedir = D:\WNMP\MySQL
Port = 3306
Character_set_server = UTF8
Under the D:\WNMP\MySQL\bin directory
D:\wnmp\mysql\bin>mysqld-install
D:\wnmp\mysql\bin>mysqld--initialize
D:\wnmp\mysql\bin>net Start MySQL
Now MySQL automatically generates the Data folder in the D:\WNMP\MySQL directory
Under Data\, open the suffix. err file, search ' temporary password ' found: 2016-05-05t06:47:06.583726z 1 [Note] A temporary password is generated for [ Email protected]: pm%!*qipe4xk
copy: [email protected]: after the password.
Start MySQL
CMD-->mysql-u root-p
Enter PASSWORD:PM%!*QIPE4XK # The random password just copied
Set Password=password (' root '); # change your password to root
Create a new mysql.php file in the D:\WNMP\Nginx\html directory. Enter the following test content
<?php
$link =mysql_connect ("localhost", "root", "root");
if (! $link) echo "faild!";
else echo "ok!";
?>
Open the browser, enter the http://127.0.0.1/mysql.php test, if the output "OK", it means that the PHP connection has been transferred to MySQL.
6. Summarize the start-up steps
D:\wnmp\php>php-cgi.exe-b 127.0.0.1:9000-c D:\WNMP\PHP\php.ini
D:\wnmp\nginx>start Nginx
Admin: >net start MySQL
>mysql-u root-p
Enter Password:root
WNMP Environment Construction (win10+ndinx1.9.15+mysql5.7.12+php5.6.21)