What is the detailed operation of the Windows7 configuration Nginx+php+mysql?

Source: Internet
Author: User
Tags db connect goto win32

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. Install the MySQL service (if you have previously installed MySQL, you can not download the installation, 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

server {
Listen 80;
server_name localhost;
#modify by Lee 20160902 for Php-s
Location/{
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)

@echo off
REM The use of bat
Echo ==================begin========================
Cls
SET Nginx_path=c:
SET nginx_dir=c:\wnmp\nginx\
SET php_dir=c:\wnmp\php\
Color 0a
TITLE Nginx Manager
Cls
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" EXIT
PAUSE
: Start
Call:startnginx
call:startphpfastcgi
GOTO MENU
: Stop
Call:shutdownnginx
GOTO MENU
: Restart
Call:shutdownnginx
Call:startnginx
GOTO MENU
: Shutdownnginx
ECHO.
ECHO. Stop Nginx ...
taskkill/f/im nginx.exe > nul
ECHO. Stopping PHP FastCGI ...
ECHO. Ok,stop all Nginx process and PHP fastcgi
Goto:eof
: Startnginx
ECHO.
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. Ok
Goto:eof
: startphpfastcgi
ECHO.
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. Ok
Goto: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.

<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!

What is the detailed operation of the Windows7 configuration 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.