Windows7 a detailed tutorial on configuring Nginx+php+mysql

Source: Internet
Author: User
Tags db connect goto win32

Windows7 a detailed tutorial on configuring Nginx+php+mysql

Vincent. Li font: [Increase decrease] Type: Reprint time: 2016-09-04 I want to comment

This article mainly introduces the Windows7 configuration Nginx+php+mysql Detailed tutorial of the relevant information, the need for friends can refer to the following

Recently in the study of PHP, want to record their learning experience, and write some experience, only for reference exchange. This article is suitable for those students who have just contacted PHP, want to learn and want to build their own nginx+php+mysql environment.

Of course, you can also choose to integrate a good installation package, such as Wamp, but I recommend you to manually set up a good environment, so that better understand PHP and its running process. The following goes straight to the chase.

Steps:

1. Preparing the installation package, etc.

(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.zip or x64.zip download link is http://windows.php.net/download#php-5.6, select the appropriate version according to the system type.

(3) mysql-installer--------. msi download link for http://dlsw.baidu.com/sw-search-sp/soft/ea/12585/ Mysql-5.6.24-win32.1432006610.zip, because the MySQL official website needs to register, so I directly posted Baidu's address.

2. Installing the MySQL service (If you have previously installed MySQL, you may not have to download the installation and start the MySQL service at the time of operation.) )

Double-click the Mysql-install-------. MSI installation package to enter the installation environment interface, select the default option to install, take typical (typical installation), and start the MySQL Configuration Wizard, select the default option configuration, here encoding select UTF-8, after setting the database password ( typically root), execute executes, and click Finish to complete the installation. To ensure that the MySQL service is turned on, check that the service is turned on by: Win+r Enter services.msc carriage return to see if there is a MySQL service as shown and is in the start state.

3. Installing nginx-1.10.1

(1) Extract Nginx-1.10.1.zip file to C:\wnmp\nginx, and enter the folder, find Nginx.exe, mouse double-click Nginx.exe, start Nginx.

Go to the Task Manager Process tab, if you find the Nginx.exe process, confirm that Nginx is started.

Open the browser, type: http://127.0.0.1 in the browser address bar, as shown in the interface, stating that Nginx is working properly.

(2) Enter the C:\wnmp\nginx\conf folder, Notepad or WordPad open the Nginx configuration file nginx.conf

Find the following two places to modify the content as follows

?
123456789101112131415161718 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. Installing php-5.6.25-nts-win32-vc11-x64/x86

(1) Unzip the Php-5.6.25-nts-win32-vc11-x64/x86.zip file to C:\wnmp\php.

(2) Enter C:\wnmp\php directory, backup php.ini-development one copy, rename php.ini-development to PHP.ini

Find location and modify:

; Extension_dir = "ext", delete the preceding semicolon and modify it to: Extension_dir = "C:/wnmp/php/ext"

; extension=php_gd2.dll, remove the preceding semicolon: Extension=php_gd2.dll

; extension=php_mbstring.dll, remove the preceding semicolon: Extension=php_mbstring.dll

; extension=php_mysql.dll, remove the preceding semicolon: Extension=php_mysql.dll

; extension=php_mysqli.dll, remove the preceding semicolon: Extension=php_mysqli.dll

; extension=php_pdo_mysql.dll, remove the preceding semicolon: Extension=php_pdo_mysql.dll

; cgi.force_redirect = 1, remove the preceding semicolon: Cgi.force_redirect = 1

; cgi.fix_pathinfo=1, remove the preceding semicolon: cgi.fix_pathinfo=1

; cgi.rfc2616_headers = 0, remove the preceding semicolon: Cgi.rfc2616_headers = 1

(3) Configure environment variables:

Open the Environment Variables Configuration window,

Add variable variable name to system environment variable: Php_home variable value: C:\wnmp\php

Add variable variable name to system environment variable: Nginx_home variable value: C:\wamp\nginx

Added at the end of the path variable:%php_home%;%nginx_home%; (Note add semicolons)

(4) Start php-cgi service:

Win+r input cmd Enter, enter the command prompt interface, enter C:\WNMP\PHP>

Use the command php-cgi.exe-b 127.0.0.1:9001-c php.ini

Re-open a new command prompt interface,

Input command: NETSTAT-ANO|FINDSTR "9001" will appear 9001 port number occupancy

Enter the command again: Tasklist|findstr "2892" (Note: 2892 is the process number shown in the last column after execution of the previous command)

As shown: Indicates that the PHP-CGI service started successfully

(5) Write the startup script Start.bat (in fact, up to the previous step, has been configured to complete, but in order to facilitate the start of various services later, write a startup script.) )

New text document, renamed to Start.bat

After opening with Notepad, make the following edits:

(If the file directory is exactly the same as described in this tutorial, then this script can be used directly, if there is a difference, you need to make the appropriate changes to Nginx_dir and Php_dir to use)

?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 666768697071 @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 success

Create a new WWW folder under C:\WNMP, create a new php file index.php under www folder and edit it as follows

The following mysqli_connect () code sections need to be changed accordingly.

?
1234567891011121314151617 <title>test mysql+php+nginx</title><body><?php$link = mysqli_connect("localhost","root","root");if($link){echo "db connect success!";}else{echo "db connect failed!";}?><br><?php phpinfo();?></body>

Double-click the Start.bat script file above, press ENTER after keyboard input 1

As shown, it indicates that the nginx-php started successfully

Open the browser, type: http://127.0.0.1 in the browser address bar, as seen in the interface shown, stating that the WNMP configuration was successful.

At this point, WNMP configuration is successful!

The above is a small series to introduce you to the Windows7 configuration nginx+php+mysql detailed tutorial, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for the support of the Scripting House website!

Original link: http://www.cnblogs.com/vincent-li666/archive/2016/09/03/5836784.html

Windows7 a detailed tutorial on configuring Nginx+php+mysql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.