Configure wnmp in windows and wnmp in windows
Recently, I tried to configure nginx + php + mysql in windows. Here is a summary.
1. Download nginx for windows. Official Website: http://nginx.org/en/download.htm. download it and decompress it to d:\wnmp.
2. Configure php
Download php for windows, Official Website: composer (D: \ wnmp). Here, rename the decompressed folder to php5.
Go to the folder and modify the php. ini-development file to php. ini.
Open php. ini and find the following code:
Extension_dir = "./ext" changed to extension_dir = "D:/wnmp/php5/ext ".
; Extension = php_mysql.dll remove the semicolon
; Extension = php_mysqli.dll remove the semicolon (open the dynamic database link)
Copy the libmysql. dll file under the php5 directory to the C: \ Windows Directory, or set the environment variable path. Then find the following code:
; Cgi. fix_pathinfo = 0 remove the semicolon and change it to cgi. fix_pathinfo = 1
3. Configure nginx
Decompress the package, open the nginx. conf file in the conf directory, and find
location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # 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; #}
Changed:
Location/{root d:/www; // set the Directory index index.html index.htm;} error_page 404/404 .html; redirect server error pages to the static page/50x.html # error_page 500 502 503 x.html; location =/50x.html {root d:/www;} proxy the PHP scripts to Apache listening on 127.0.0.1: 80 location ~ \. Php $ {proxy_pass http: // 127.0.0.1;} pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 location ~ \. Php $ {root d:/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.
4. Run nginx and php
Enter the following command:
D:\wnmp\php5>php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini
Run php In cgi Mode and listen for data sent from nginx port 9000. Double-click nginx.exe to run nginx.
Quick Start setting: first download the runhiddenconsole.exe file into the nginx directory, and then save the following code as start_nginx.bat
@echo off set php_home=../php5/set nginx_home=./echo Starting PHP FastCGI... RunHiddenConsole %php_home%/php-cgi.exe -b 127.0.0.1:9000 -c %php_home%/php.ini echo Starting nginx... RunHiddenConsole %nginx_home%/nginx.exe -p %nginx_home%exit
Save the following code as 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
The final file is like this. Double-click start_nginx.bat to start nginx and php.
5. install and configure mysql to download mysql: mysql
Basedir = C: \ Program Files \ MySQL \ remove # (mysql directory)
Datadir = C: \ Program Files \ MySQL \ data removed # (mysql directory \ data)
Run the command line to enter the directory cd C: \ Program Files \ MySQL \ bin, and enter the following command to install mysql: mysqld-install (which can be found in the service after installation)
Start Service: net start mysql, disable service: net stop mysql. You can also enable or disable the service.
Add the path variable: Go to computer> Properties> advanced system Settings> environment variables and add the "F: \ phpenv \ mysql \ bin" Logon command: mysql-h Host ip address-u user name-p User Password