For more information about how to configure Nginx + php + mysql in Windows 7, see windows7nginx.
I recently learned php and want to record my learning experience and write some experiences for reference only. This article is suitable for those who are new to php and want to learn and build their own Nginx + php + mysql environment.
Of course, you can also choose the integrated installation package, such as wamp, but I recommend that you manually build the environment to better understand php and its running process. Next, go to the topic.
Steps:
1. Prepare the installation package.
(1)nginx-1.10.1.zip, download link for http://nginx.org/en/download.html. I personally chose the stable version.
(2)php-5.6.25-nts-win32-vc11-x86.zipor x64.zip download link: http://windows.php.net/download?php-5.6;.
(3) the mysql-installer --------. msi download link is.
2. Install the mysql Service(If you have installed mysql before, you do not need to download and install it. You can start the mysql service during the operation .)
Double-click mysql-install -------. msi installation package to enter the installation environment interface, select the default option to install, use Typical (Typical installation), and start the MySQL Configuration Wizard, select the default option configuration, Here encoding select UTF-8, after setting the Database Password (usually root), Run "Execute" and click "Finish" to complete the installation. To enable the mysql service, run the following command to check whether the service is enabled: win + R, enter services. msc, and press enter to check whether the mysql service is in the starting state as shown in.
3. Install nginx-1.10.1
(1) decompress the nginx-1.10.1.zip file to C: \ wnmp \ nginx, and enter the folder to find nginx.exe. double-click nginx.exe and start nginx.
The access card of the task manager. If the nginx.exe process is found, nginx is started.
Open the browser and type http: // 127.0.0.1 in the address bar of the browser. If you see the interface shown in, nginx works properly.
.
(2) Go to the C: \ wnmp \ nginx \ conf folder, and open the nginx configuration file nginx. conf in notepad or wordpad.
Find the following two parts and modify the content as follows:
server {listen 80;server_name localhost;#modify by lee 20160902 for php -slocation / {root C:/wnmp/www;index index.html index.htm index.php;}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ {root C:/wnmp/www;fastcgi_pass 127.0.0.1:9001;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}#modify by lee 20160902 for php -e}
4. Install php-5.6.25-nts-Win32-VC11-x64/x86
(1) decompress the php-5.6.25-nts-Win32-VC11-x64/x86.zip file to C: \ wnmp \ php.
(2) Go to the C: \ wnmp \ php Directory, back up php. ini-development, and rename php. ini-development to php. ini.
Locate and modify:
; Extension_dir = "ext", delete the semicolon and change it to: extension_dir = "C:/wnmp/php/ext"
; Extension = php_gd2.dll, delete the semicolon: extension = php_gd2.dll
; Extension = php_mbstring.dll, delete the semicolon: extension = php_mbstring.dll
; Extension = php_mysql.dll, delete the semicolon: extension = php_mysql.dll
; Extension = php_mysqli.dll, delete the semicolon: extension = php_mysqli.dll
; Extension = php_pdo_mysql.dll, delete the semicolon: extension = php_pdo_mysql.dll
; Cgi. force_redirect = 1, delete the semicolon above: cgi. force_redirect = 1
; Cgi. fix_pathinfo = 1. Delete the semicolon cgi. fix_pathinfo = 1.
; Cgi. rfc2616_headers = 0. Delete the semicolon cgi. rfc2616_headers = 1.
(3) Configure environment variables:
Open the environment variable configuration window,
Add the variable name PHP_HOME to the system environment variable. The variable value is C: \ wnmp \ php.
Add the variable name NGINX_HOME to the system environment variable. The variable value is C: \ wamp \ nginx.
Add % PHP_HOME %; % NGINX_HOME %; at the end of the path variable. (add a semicolon)
(4) Start the php-cgi service:
Win + R Enter cmd and press enter to enter the command prompt interface, enter C: \ wnmp \ php>,
Use the command php-cgi.exe-B 127.0.0.1: 9001-c php. ini
Open a new command prompt interface,
Run the following command: netstat-ano | findstr "9001" to check whether the port number occupies 9001.
Run tasklist | findstr "2892" again (Note: 2892 indicates the process number displayed in the last column after the previous command is executed)
As shown in: indicates that the php-cgi service is successfully started.
(5) Compile the startup script start. bat (in fact, the configuration has been completed until the previous step, but in order to facilitate the startup of various services in the future, we hereby write a STARTUP script .)
Create a text document and rename it start. bat
After opening it with notepad, make the following edits:
(If the file directory is exactly the same as the one described in this tutorial, This script can be used directly. If there is a difference, you need to modify NGINX_DIR and PHP_DIR to use it)
@echo offrem the use of batecho ==================begin========================cls SET NGINX_PATH=C:SET NGINX_DIR=C:\wnmp\nginx\SET PHP_DIR=C:\wnmp\php\color 0a TITLE Nginx ManagerCLS ECHO. ECHO. * * Nginx Manage App * ECHO. :MENU ECHO. * nginx process list * tasklist|findstr /i "nginx.exe"ECHO. ECHO. [1] start Nginx ECHO. [2] stop Nginx ECHO. [3] restart Nginx ECHO. [4] exit ECHO. ECHO.Please input the number:set /p ID=IF "%id%"=="1" GOTO start IF "%id%"=="2" GOTO stop IF "%id%"=="3" GOTO restart IF "%id%"=="4" EXITPAUSE :start call :startNginxcall :startPhpFastCGIGOTO MENU:stop call :shutdownNginxGOTO MENU:restart call :shutdownNginxcall :startNginxGOTO MENU:shutdownNginxECHO. ECHO.Stop Nginx...... taskkill /F /IM nginx.exe > nulECHO.Stopping PHP FastCGI......ECHO.OK,Stop all nginx process and php fastcgigoto :eof:startNginxECHO. ECHO.Start Nginx...... IF NOT EXIST "%NGINX_DIR%nginx.exe" ECHO "%NGINX_DIR%nginx.exe" is not exists %NGINX_PATH% cd "%NGINX_DIR%" IF EXIST "%NGINX_DIR%nginx.exe" (echo "start '' nginx.exe"start "" nginx.exe)ECHO.OKgoto :eof:startPhpFastCGIECHO. ECHO.Start PHP FastCGI......IF NOT EXIST "%PHP_DIR%php-cgi.exe" ECHO "%PHP_DIR%php-cgi.exe" is not exists %NGINX_PATH% cd "%PHP_DIR%" IF EXIST "%PHP_DIR%php-cgi.exe" (echo "start '' php-cgi.exe"start /b php-cgi.exe -b 127.0.0.1:9001 -c php.ini)ECHO.OKgoto :eof
(6) test successful
Create a www folder under C: \ wnmp, create a php file index. php under the www folder, and edit the file as follows:
The following mysqli_connect () code must be changed accordingly.
Double-click the above start. bat script file, enter 1 on the keyboard, and press the Enter key.
As shown in, nginx-php is successfully started.
Open the browser and type http: // 127.0.0.1 in the address bar of the browser. The page shown in shows that wnmp is successfully configured.
So far, WNMP configuration is successful!
The above is a detailed tutorial on how to configure Nginx + php + mysql in Windows 7. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!