亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Configure nginx+php environment under windows
Home php教程 php手冊(cè) wnmp environment setup

wnmp environment setup

Sep 24, 2016 am 09:02 AM

Configure nginx+php environment under windows

I just saw the word nginx and I was very curious about its pronunciation (engine x). My literal translation is “engine "Extra effects)", then the whole word means something like "extreme effect", "extra performance". Of course, this is not a chat here, the above is a digression.

 The advantage of nginx compared to the familiar apache and IIS, as far as I understand it in a simple way, lies in "reverse proxy" and "load balancing". Therefore, considering the ability to save resources for the web server, it can replace apache to provide web services. So let’s get to the point, nginx has so many advantages, so how to configure the nginx+php environment under windows? There are still so many articles that are reprinted and reprinted online. Here is my configuration process:

1. The application package needs to be prepared first.

 nginx: nginx/Windows-1.0.4

  php: php-5.2.16-nts-Win32-VC6-x86.zip (php under nginx runs in FastCGI, so we download the non-thread-safe php package of nts)

 (Will also be used) RunHiddenConsole: RunHiddenConsole.zip

2. Installation and configuration.

 1) Installation and configuration of php.

  Directly decompress the downloaded php package and go to the wnmp directory on drive D (D:wnmp). Here, rename the decompressed folder to php5. Enter the folder and modify the php.ini-recommended file to php.ini, and open it with Editplus or Notepad++. Found

extension_dir = "./ext"

changed to

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

After specifying the ext path of php earlier, just remove the corresponding ";" in front of the required expansion package. Open php_mysql.dll and php_mysqli.dll here to let php support mysql. Of course, don't forget that a very important step is to copy the libmysql.dll file in the php5 directory to the C:Windows directory. You can also specify the path in the system variable. Of course, I chose the more convenient method here^_^.

At this point, php can already support mysql.

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

;cgi.fix_pathinfo=1

Let’s remove the ban here.

cgi.fix_pathinfo=1
This step is very important. Here are the CGI settings for php.

 2) Installation and configuration of nginx.

 Extract the downloaded nginx-1.0.4 package to the wnmp directory of the D drive and rename it to nginx. Next, we configure nginx so that it can work with php. Enter the nginx conf directory, open the nginx configuration file nginx.conf, and find

location / {<br>      root   html;      #這里是站點(diǎn)的根目錄<br>      index  index ?index.html index.htm index.php;<br>}

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

Go further down and find

wnmp environment setup
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br>#<br>#location ~ \.php$ {<br>#    root           html;<br>#    fastcgi_pass   127.0.0.1:9000;<br>#    fastcgi_index  index.php;<br>#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br>#    include        fastcgi_params;<br>#}
wnmp environment setup

First remove the "#" in front, and also change root html; to root D:/wnmp/www;. Then change the /scripts marked in red to "$document_root". The "$document_root" here refers to the site path pointed to by "root". This is after the change:

wnmp environment setup
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br>#<br>location ~ \.php$ {<br>      root           D:/wnmp/www;<br>      fastcgi_pass   127.0.0.1:9000;<br>      fastcgi_index  index.php;<br>      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;<br>      include        fastcgi_params;<br>}
wnmp environment setup

Save the configuration file and that’s it.

 The nginx+php environment has been initially configured, let’s take a look. We can enter the command

To start php and start nginx manually, of course, you can also use a script to achieve this.

First, unzip the downloaded RunHiddenConsole.zip package into the nginx directory. The function of RunHiddenConsole.exe is to automatically close the script after executing the command line script, and the process started from the script will not be closed. Then create a script and name it "start_nginx.bat". Let's edit it in Notepad++

wnmp environment setup
@echo off<br>REM Windows 下無效<br>REM set PHP_FCGI_CHILDREN=5<br><br>REM 每個(gè)進(jìn)程處理的最大請(qǐng)求數(shù),或設(shè)置為 Windows 環(huán)境變量<br>set PHP_FCGI_MAX_REQUESTS=1000<br> <br>echo Starting PHP FastCGI...<br>RunHiddenConsole D:/wnmp/php5/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini<br> <br>echo Starting nginx...<br>RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx
wnmp environment setup

再另外創(chuàng)建一個(gè)名為stop_nginx.bat的腳本用來關(guān)閉nginx

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

做好后,是這樣的

這樣,我們的服務(wù)腳本也都創(chuàng)建完畢了。雙擊start_nginx.bat看看進(jìn)程管理器是不是有兩個(gè)nginx.exe的進(jìn)程和一個(gè)php-cgi.exe的進(jìn)程呢?

這樣nginx服務(wù)就啟動(dòng)了,而且php也以fastCGI的方式運(yùn)行了。

到站點(diǎn)目錄下,新建一個(gè)phpinfo.php的文件,在里面編輯

<?php <br />    phpinfo();<br>?>

保存后,打開瀏覽器輸入“http://localhost/phpinfo.php”,如果看到

就說明,nginx+php的環(huán)境已經(jīng)配置好了,呵呵~

轉(zhuǎn)自http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72