Install Nginx + php + mysql in Windows, nginxmysql
System: Windows 7 64-bit
Before installation, download the software:
Nginx: http://nginx.org/en/download.html
PHP Stable PHP 5.6.26: http://php.net/downloads.php
Mysql: http://dev.mysql.com/downloads/utilities/
Step 1: Create a folder Nginx + php + Mysql on disk D. The path is D: \ Nginx + php + Mysql.
Step 2: Install Nginx. The installation directory is: D: \ Nginx + php + Mysql \ nginx
1. Open the D: \ Nginx + php + Mysql \ nginxdirectory and run the nginx.exe directory 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 the startup fails, check whether the port is in use.
Install PHP. Installation Directory: D: \ Nginx + php + Mysql \ php
Install mySQL. Installation Directory: D: \ Nginx + php + Mysql \ mysql
Step 3: Modify the conf file of Nginx: Directory D: \ Nginx + php + Mysql \ nginx \ conf
File Name: nginx. conf
1. Remove the # Before worker_processes and start a process.
2. Add events
3. Set http-> set server-> support for php
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root d:/Nginx+php+Mysql/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # 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 $document_root$fastcgi_script_name; include fastcgi_params; } }}
Test whether nginx is successfully installed.
Step 4: Modify the php. ini-development file in php, change the file name to php. ini, and open php. ini:
Search for "extension_dir" and find extension_dir = "ext". Go to the semicolon and change it to extension_dir = "./ext"
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)
Check whether php has been installed successfully:
Step 4: create a file php-cgi.vbs in the php Directory and start php-cgi with the php-cgi.vbs file:
Open the php-cgi.vbs and write the boot encoding:
set wscriptObj = CreateObject("Wscript.Shell")wscriptObj.run "php-cgi -b 127.0.0.1:9000",0
Step 5: Create a startup item in the D: \ Nginx + php + Mysql Directory: runServer. bat and stop item stopServer. bat
In the startup Item runServer. bat, enter:
@echo offecho Starting nginx...cd %~dp0nginxstart "" "./nginx.exe"echo Starting mysql...net start mysqlecho Starting PHP FastCGI...cd %~dp0PHPstart "" "php-cgi.vbs"pauseExit
Enter:
@echo offecho Stopping nginx...taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulecho Stopping mysql...net stop mysqlpauseexit
Finally, check whether the startup is successful:
Create phpinfo. php In the html Directory D: \ nginx + php + Mysql \ Nginx \ html.
Write:
<?phpphpinfo();?>
Enter the phpinfo. php path in the browser to check whether the configuration is successful: