Install and configure the Nginx + php + mysql environment on the win platform

Source: Internet
Author: User
This article will share with you the methods and steps for installing and configuring the Nginx + php + mysql environment on the win platform. if you have any need, refer. 1. preparations

(1) PHP 5.6.17 PHP official website

(2) Nginx 1.8.0 official Nginx website

(3) MySQL 5.7.10 official website

2. install and configure php

Directly decompress the downloaded php package to the wnmp Directory (D: \ wnmp) on the D drive. here, rename the decompressed folder to php5. Go to the folder and modify the php. ini-delelopment file to php. ini, and open it with Editplus or Notepad ++. Find

Extension_dir = "ext" changed to extension_dir = "D:/wnmp/php5/ext"

Common extensions, remove the previous ";"

  extension=php_curl.dll  extension=php_gd2.dll  extension=php_mbstring.dll  extension=php_mcrypt.dll  extension=php_mysql.dll  extension=php_mysqli.dll  extension=php_pdo.dll  extension=php_pdo_mysql.dll  extension=php_xmlrpc.dll

Nginx supports configuration. remove the preceding ";"

; Cgi. fix_pathinfo = 1

; Cgi. force_redirect = 1

; Cgi. rfc2616_headers = 0 first go to the front semicolon and then change to cgi. rfc2616_headers = 1

3. install and configure Nginx

Decompress the downloaded package to D: \ wnmpand directly run nginx.exe in the directory to start.

1. there are three startup methods

(1)double-click the nginx.exe icon. the black window flashed through and started.

(2) run the command line to the nginx directory and enter nginx to start. (Note: the command line window in this mode has no prompt and is locked)

(3) run the command line to the nginx directory and enter start nginx to start. this mode is not locked.

2. support for PHP configuration modification

Go to the nginx conf Directory, open the nginx configuration file nginx. conf, and find

Location/{root html; # Here is the site's root directory index index.html index.htm index. php ;}

Change root html; to root D:/wnmp/www;

Next, find

    # pass the PHP scripts to FastCGI serverlistening 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;    #}

First remove "#" and change root html; to root D:/wnmp/www ;. Change the/scripts marked in red to "$ document_root". here, "$ document_root" refers to the site path referred to by "root". this is changed:

    # pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000    #    location ~ \.php$ {        root      D:/wnmp/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.

The nginx + php environment has been initially configured. We can enter the command

To start php and manually start nginx. of course, you can also use the script.

First, decompress the downloaded runhiddenconsole.zippackage to the nginxdirectory. runhiddenconsole.exe automatically closes the script after executing the command script, but the processes enabled from the script are not disabled. Create a script named "start_nginx.bat ".

@ Echooff
Invalid REMWindows
REM set PHP_FCGI_CHILDREN = 5

REM the maximum number of requests processed by each process, or set it to a Windows environment variable
Set setPHP_FCGI_MAX_REQUESTS = 1000

Echo Starting PHPFastCGI...
RunHiddenConsole D:/wnmp/php5/php-cgi.exe-B 127.0.0.1: 9000-cD:/wnmp/php5/php. ini

Echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe-p D:/wnmp/nginx

Create another script named stop_nginx.bat to disable nginx.

@echooffecho Stoppingnginx... taskkill /F /IM nginx.exe > nulecho Stopping PHPFastCGI...taskkill /F /IM php-cgi.exe > nulexit

In this way, all our service scripts have been created. Double-click start_nginx.batto check whether the process manager has two nginx.exepaths and a php-cgi.exe process?

In this way, the nginx service is started and php runs in fastCGI mode.

Go to the site directory, create a phpinfo. php file, and edit it in it.

  <?php echo phpinfo();?>

After saving, open the browser and enter "http: // localhost/phpinfo. php". if you see

The nginx + php environment has been configured ~

4. install and configure MySQL

(Simple) install and download MySQL, one way to install next.

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.