Home > Backend Development > PHP Tutorial > Configure wnmp under windows, configure wnmp under windows_PHP tutorial

Configure wnmp under windows, configure wnmp under windows_PHP tutorial

WBOY
Release: 2016-07-12 08:52:29
Original
877 people have browsed it

Configure wnmp under windows, configure wnmp under windows

Recently tried to configure nginx php mysql under windows, summarize it here.

1. Download the windows version of nginx. Official website download address: http://nginx.org/en/download.htm. After downloading, extract it to D:wnmp

​2. Configure php

Download the windows version of php, official website download address: http://windows.php.net/download/, php will run in cgi mode, unzip the downloaded php package, and go to the wnmp directory of the D drive (D :wnmp), rename the extracted folder to php5.

Enter the folder and modify the php.ini-development file to php.ini​.

Open php.ini and find the following code

extension_dir =<span>"</span><span>./ext</span><span>"</span>更改为extension_dir =<span>"</span><span>D:/wnmp/php5/ext</span><span>"</span>。  <br />;extension=php_mysql.dll 去掉分号<br />;extension=php_mysqli.dll 去掉分号(打开数据库动态链接库)
Copy after login

Then copy the libmysql.dll file in the php5 directory to the C:Windows directory, or set the environment variable path, and then find the following code

;cgi.fix_pathinfo=0 去掉分号并改为 cgi.fix_pathinfo=<span>1</span>
Copy after login

3. Configure nginx

After decompression, open the nginx.conf file in the conf directory and find

        location /<span> {
            root   html;
            index  index.html index.htm;
        }
        #error_page  </span><span>404</span>              /<span>404</span><span>.html;
        # redirect server error pages to the </span><span>static</span> page /<span>50x.html
        #
        error_page   </span><span>500</span> <span>502</span> <span>503</span> <span>504</span>  /<span>50x.html;
        location </span>= /<span>50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on </span><span>127.0</span>.<span>0.1</span>:<span>80</span><span>
        #
        #location </span>~<span> \.php$ {
        #    proxy_pass   http:</span><span>//</span><span>127.0.0.1;</span>
<span>        #}
        # pass the PHP scripts to FastCGI server listening on </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>
        #
        #location </span>~<span> \.php$ {
        #    root           html;
        #    fastcgi_pass   </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  </span>/<span>scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}</span>
Copy after login

changed to:

        location /<span> {
            root   <span>d:/www</span>;  //自行设置目录
            index  index.html index.htm;
        }
        error_page  </span><span>404</span>              /<span>404</span><span>.html;
         redirect server error pages to the </span><span>static</span> page /<span>50x.html
        #
        error_page   </span><span>500</span> <span>502</span> <span>503</span> <span>504</span>  /<span>50x.html;
        location </span>= /<span>50x.html {
            root   <span>d:/www</span>;
        }
         proxy the PHP scripts to Apache listening on </span><span>127.0</span>.<span>0.1</span>:<span>80</span><span>
        
        location </span>~<span> \.php$ {
            proxy_pass   http:</span><span>//</span><span>127.0.0.1;</span>
<span>        }
         pass the PHP scripts to FastCGI server listening on </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>
        
        location </span>~<span> \.php$ {
            root           <span>d:/www</span>;
            fastcgi_pass   </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  <span>$document_root</span></span><span>$fastcgi_script_name;
            include        fastcgi_params;
        }</span>
Copy after login

Save configuration file.

4. Run nginx and php

Enter command:

D:\wnmp\php5>php-cgi.exe -b <span>127.0</span>.<span>0.1</span>:<span>9000</span> -c D:/wnmp/php5/php.ini
Copy after login

Run php in cgi mode and listen to the data sent by nginx from port 9000. Double-click nginx.exe to run nginx.

Quick startup settings: First download the file RunHiddenConsole.exe and put it into the nginx directory, then save the following code as start_nginx.bat

<span>@echo off  
</span><span>set</span> php_home=../php5/
<span>set</span> nginx_home=./<span>
echo Starting PHP FastCGI...  
RunHiddenConsole </span>%php_home%/php-cgi.exe -b <span>127.0</span>.<span>0.1</span>:<span>9000</span> -c %php_home%/<span>php.ini  
echo Starting nginx...  
RunHiddenConsole </span>%nginx_home%/nginx.exe -p %nginx_home%<span>
exit</span>
Copy after login

Save the following code as stop_nginx.bat

<span>@echo off  
echo Stopping nginx...    
taskkill </span>/F /IM nginx.exe ><span> nul  
echo Stopping PHP FastCGI...  
taskkill </span>/F /IM php-cgi.exe ><span> nul  
exit</span>
Copy after login

The final file looks like this. Double-click start_nginx.bat to start nginx and php.

5. Install and configure mysql Download mysql: http://dev.mysql.com/downloads/mysql/, and then extract it to the D:/mnmp directory Found in my-default.ini
basedir=<span>C:\Program Files\MySQL\ </span>去掉#<span>(mysql所在目录)<br />datadir</span>=C:\Program Files\MySQL\data 去掉#(mysql所在目录\data)
Copy after login

Command line to enter the directory: cd C:Program FilesMySQLbin, enter the following command to install mysql: mysqld -install (can be found in the service after installation)

Start the service: net start mysql, close the service: net stop mysql. It can also be started or shut down in the service.

Add path variable: Add in Computer>Properties>Advanced System Settings>Environment Variables: F:phpenvmysqlbin Login command: mysql -h host ip -u username -p user password ​

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1126846.htmlTechArticleConfiguring wnmp under windows, configuring wnmp under windows. I recently tried to configure nginx php mysql under windows. Let’s summarize it here. 1. Download the windows version of nginx, official website download address: http://ngi...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template