>백엔드 개발 >PHP 튜토리얼 >windows下配置wnmp,windows配置wnmp_PHP教程

windows下配置wnmp,windows配置wnmp_PHP教程

WBOY
WBOY원래의
2016-07-12 08:52:29868검색

windows下配置wnmp,windows配置wnmp

最近尝试windows下配置nginx+php+mysql,在这里总结一下。

1、下载windows版本的nginx,官网​下载地址:http://nginx.org/en/download.htm,下载好后解压到D:\wnmp

​2、配置php

​下载windows版本的php,官网下载地址:http://windows.php.net/download/,php将会以cgi的方式运行,解压下载好的php包,到D盘wnmp目录(D:\wnmp),这里把解压出来的文件夹重命名成php5。

进入文件夹修改php.ini-development文件为php.ini​。

打开php.ini,找到以下代码

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 去掉分号(打开数据库动态链接库)

然后把php5目录下的libmysql.dll文件复制到C:\Windows目录下,或者设置环境变量路径也可以,然后找到以下代码

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

3、配置nginx

解压后打开conf目录下的nginx.conf文件,找到

        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>

改为:

        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>

 保存配置文件。

4、运行nginx和php

输入命令:

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

以cgi的方式运行php,监听nginx从9000端口发来的数据。双击nginx.exe运行nginx。 

快捷启动设置:先下载RunHiddenConsole.exe这个文件放入nginx目录中,然后将以下代码保存为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>

将以下代码保存为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>

最后文件是这样的,双击start_nginx.bat就可以启动nginx和php了。

 

 

5、安装配置mysql 下载mysql:http://dev.mysql.com/downloads/mysql/,然后解压到D:/mnmp目录下 在my-default.ini中找到
basedir=<span>C:\Program Files\MySQL\ </span>去掉#<span>(mysql所在目录)<br />datadir</span>=C:\Program Files\MySQL\data 去掉#(mysql所在目录\data)

命令行进入目录:cd C:\Program Files\MySQL\bin,输入以下命令安装mysql:mysqld -install  (安装后可以在服务中找到)

启动服务:net start mysql,关闭服务:net stop mysql 。也可以在服务中启动或者关闭。

添加path变量:在计算机>属性>高级系统中设置>环境变量中添加:F:\phpenv\mysql\bin 登录命令:mysql -h 主机ip -u 用户名 -p 用户密码    

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126846.htmlTechArticlewindows下配置wnmp,windows配置wnmp 最近尝试windows下配置nginx+php+mysql,在这里总结一下。 1、下载windows版本的nginx,官网​下载地址:http://ngi...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.