Configure Nginx + PHP under Windows

Source: Internet
Author: User

The first part: preparation work. (System: Windows 8.1)

1. First, download the software.

Nginx official website Download: http://nginx.org/en/download.html

PHP Version: http://windows.php.net/download/

MySQL version: http://www.mysql.com/downloads/mysql/

2. Install the MySQL software.

3. Unzip the Nginx and PHP to your own installation location. Here I create a new folder in the C drive: Wnmp (windows,ngnix,myspq,php), install the following software into this folder.

Nginx Directory C:\wnmp\nginx

PHP directory C:\wnmp\php

Part Two: Installing Nginx

1. Open the C:\nginx directory and run the Nginx.exe under this folder

2. Test if Nginx is activated. Open the browser to access http://localhost or http://127.0.0.1 to see if "Welcome to nginx!" appears, the proof has been started successfully. If not, see if Port 80 is occupied.

Note: The default directory for this site is under "C: \wnmp\nginx\htm" L


Part III: Install PHP (here is the main nginx configuration to start PHP, to run PHP with CGI)

The nginx configuration file is the nginx.conf in the Conf folder.

1. Modify the approximate 43rd to 45th line

            Location/{            root   html;            Index  index.html index.htm;}

Modify the path to the Web site file, and add the default page for index.php.

        Location/ {            root   C:/wnmp/nginx/html;            Index  index.html index.htm inde.php;        }

2. Support for PHP settings

Modified about the 第63-71 line.

# Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000;        # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name;        # include Fastcgi_params; #}

First the "#" is removed, the same root HTML, to root c:/wnmp/nginx-1.5.8/html;. Then the "/scripts" to "$document _root", where the "$document _root" refers to the front "root" refers to the site path, which is changed after:

# Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# Location~\.php$ {root c:/wnmp/nginx/html; Fastcgi_pass127.0.0.1:9000;            Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi _script_name;        Include Fastcgi_params; }

3.c:\wnmp\php Modify the php.ini-development file, change the file name to PHP.ini, open the PHP configuration file php.ini, save.

Search "Extension_dir", find: E;xtension_dir = "ext" First to go to the front of the semicolon and then change to Extension_dir = "C:\wnmp\php\ext"

Search "Date.timezone", find:;d Ate.timezone = First go to the front semicolon and change to Date.timezone = Asia/shanghai

Search "Enable_dl", find: Enable_dl = Off to Enable_dl = On

Search "Cgi.force_redirect"; cgi.force_redirect = 1 First go to the front semicolon and change to Cgi.force_redirect = 0

Search "Fastcgi.impersonate", find:; fastcgi.impersonate = 1 Remove the preceding semicolon

Search "Cgi.rfc2616_headers", find:; cgi.rfc2616_headers = 0 First, go to the front semicolon and change to Cgi.rfc2616_headers = 1

Search for "Php_mysql" and find: "Extension=php_mysql.dll and Extension=php_mysqli.dll remove the front"; Extension=php_mysql.dll and Extension=php_mysqli.dll (MySQL database support)

other configurations should be changed according to your needs.


Download a RunHiddenConsole.exe, placed in the Nginx root directory, Baidu network disk .

Open php-cgi and Nginx.exe, save as Start.bat

@echo offEchoStarting PHP FastCGI ...c:/Wnmp/nginx/runhiddenconsole.exe c:/wnmp/php/php-cgi.exe-b 127.0.0.1:9000-c C:/wnmp/php/php.INIEchoStarting Nginx ...C:/wnmp/nginx/runhiddenconsole.exe c:/wnmp/nginx/nginx.exe-p C:/wnmp/nginx

Stop php-cgi and Nginx.exe, save as Stop.bat

@echo offEchoStopping Nginx ...Taskkill/f/imc:/wnmp/nginx/Nginx.exe >nulEchoStopping PHP FastCGI ...Taskkill/f/imc:/wnmp/php/php-cgi.exe >nulExit



Configure Nginx + PHP under Windows

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.