Build the wnmp environment and build the wnmp Environment

Source: Internet
Author: User

Build the wnmp environment and build the wnmp Environment
Configure the nginx + php environment in windows

When I first saw the word nginx, I was curious about its reading method (engine x). My literal translation was "engine x", which generally introduced the performance of the "primary generation" table, while "x" is usually used to indicate "xtras (additional effect)", the entire term means "ultimate effect" and "additional performance ". Of course, this is not a question.

Compared with the advantages of apache and IIS that we are familiar with, nginx has a simple understanding of "reverse proxy" and "Server Load balancer ". Therefore, because it can save resources for the Web server, it can provide Web services instead of apache. So now that nginx has so many advantages, how can I configure the nginx + php environment in windows? There are still so many reposted articles on the Internet. Here I will introduce the configuration process:

1. The application package to be prepared first.

Nginx: nginx/Windows-1.0.4

Php: php-5.2.16-nts-Win32-VC6-x86.zip (php under nginx is run in FastCGI mode, so we download non-thread security, that is, the php package of ETS)

(Also used) RunHiddenConsole: RunHiddenConsole.zip

2. installation and configuration.

1) 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-recommended file to php. ini, and open it with Editplus or Notepad ++. Find

extension_dir = "./ext"

Change

extension_dir = "D:/wnmp/php5/ext"
Look down and find again
;extension=php_mysql.dll
;extension=php_mysqli.dll

After specifying the php ext path, you only need to remove the ";" corresponding to the extension package. Open php_mysql.dll and php_mysqli.dll to allow php to support mysql. Of course, do not forget the important step is to put libmysql under the php5 directory. copy the dll file to the C: \ Windows directory. You can also specify the path in the system variables. Of course, here I chose a more convenient method ^_^.

Now, php supports mysql.

Next we will configure php so that php can be combined with nginx. Find

 

;cgi.fix_pathinfo=1

We will remove the title here.

cgi.fix_pathinfo=1
This step is very important. Here is the CGI setting of php.

2) install and configure nginx.

Decompress the downloaded nginx-1.0.4 package to the wnmp directory of the d disk and rename it nginx. Next, configure nginx to work with php. Go to the nginx conf directory, open the nginx configuration file nginx. conf, and find

Location /{
Root html; # the root directory of the site
Index index.html index.htm index. php;
}

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

Next, find

 

# pass the PHP scripts to FastCGI server listening 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 server listening 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 line script, but the process enabled from the script is not closed. Create a script named "start_nginx.bat". Edit it in Notepad ++.

@ Echo off
Invalid in REM Windows
REM set PHP_FCGI_CHILDREN = 5

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

Echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5/php-cgi.exe-B 127.0.0.1: 9000-c D:/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.

@echo off
echo Stopping nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

This is the case.

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
phpinfo();
?>

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

The nginx + php environment has been configured ~

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.