Build nginx+php Environment under Php-windows

Source: Internet
Author: User
Tags phpinfo nginx server

Project in the light with Nginx, due to the operation and maintenance personnel, rarely set up Nginx server, development is also used Apache, a few times the nginx also forget the fast, every time to go to others blog, today re-set the record, before the best understanding of the next fastcgi (point I to learn)

1. First, you need to prepare the application package.

nginx:nginx/windows-1.7.6 (dot I go to the official website to choose version)

Php:php-5.3.29-nts-win32-vc9-x86.zip (click I go to the official website to choose version) (Nginx PHP is run in fastcgi way, so we download non-thread-safe is nts PHP package)

(will also be used) RunHiddenConsole:RunHiddenConsole.zip

2, installation and configuration.

1) Installation and configuration of PHP.

Directly unzip the downloaded PHP package, to the D disk Wnmp directory (D:\WNMP), here the extracted folder renamed to PHP5. Go to Folder to modify the Php.ini-production file to PHP.ini, and open it with EditPlus or notepad++. Found it

extension_dir = "./ext"

Change to

extension_dir = "d:/wnmp/php5/ext"

Look down, then find

; Extension=Php_mysql.dll
; extension=php_mysqli.dll ... Wait, wait, get rid of all the extensions you want .

  PHP load extensions need to be aware of dependencies, such as Php_exif.dll needs Php_mbstring.dll, you have to put Php_mbstring.dll in front of the Php_exif.dll to load successfully.

Next, let's configure PHP so that PHP can be combined with nginx. Find and remove comments from the following lines (that is, remove the beginning semicolon)

111

This step is very important, here is the CGI settings for PHP.

2) Installation and configuration of Nginx.

The downloaded nginx-1.0.4 package is also extracted to the D-disk Wnmp directory, and renamed Nginx. Next, let's configure Nginx to work with PHP. Enter the Nginx conf directory, open the Nginx configuration file nginx.conf, find

location / {
root HTML; #这里是站点的根目录
Index index.html index.htm;
}

The root html will be changed to root d:/wnmp/www;

go down, find

# pass the PHP scripts to FastCGI server listening on 127.0< Span style= "color: #000000;" >. 0.1:9000
#
#location ~ \.php$ {
# root HTML;
# fastcgi_pass 127.0.: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 d:/wnmp/www;. Then the marked red/scripts changed to "$document _root", where the "$document _root" refers to the previous "root" refers to the site path, this is changed:

#Pass the PHP scripts to FastCGI server listeningOn 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$< Span style= "color: #000000;" >fastcgi_script_name;
include Fastcgi_params;
} /span>

Save the configuration file and you're ready.

Nginx+php the environment is initially configured, to run to see. We can enter a command

To start PHP, and manually start Nginx, of course, you can also use the script to implement.

First, the downloaded Runhiddenconsole.zip package is extracted into the Nginx directory, the role of RunHiddenConsole.exe is to automatically close the script after executing the command line script, and the process opened from the script is not closed. Then create the script, named "Start_nginx.bat," and we'll edit it in notepad++.

@echo Off
RemNot valid under Windows
RemSet php_fcgi_children=5

RemThe maximum number of requests processed per process, or set to Windows environment variables
SetPhp_fcgi_max_requests=1000

EchoStarting PHP FastCGI...
Runhiddenconsole D:/Wnmp/PhP5/php-cgi.Exe-b127.0.0.1:9000-C D:/wnmp/php5/php.ini

starting Nginx...
Runhiddenconsole d:/ wnmp/nginx/nginx. Exe-p d:/wnmp/nginx

Create another script named Stop_nginx.bat to close Nginx

@echo Off
EchoStopping Nginx...
Taskkill/F /IM nginx. EXE > nul
echo stopping PHP FastCGI...
Taskkill /F /IM php-cgi. EXE > nul
exit

After doing it, it's like this.

In this way, our service scripts have been created. Double-click Start_nginx.bat to see if the process manager has two nginx.exe processes and a php-cgi.exe process?

This will start the Nginx service, and PHP will run in a fastcgi manner.

To the Site directory, create a new phpinfo.php file, edit it inside

<? PHP
phpinfo();

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

It shows that the nginx+php environment has been configured, hehe ~

Reference from: http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html

PS: Some of the above pictures are also used in this blog ..... ^_^

Build nginx+php Environment under Php-windows

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.