登录  /  注册
首页 > php教程 > php手册 > 正文

windows下配置wnmp,windows配置wnmp

php中文网
发布: 2016-06-13 08:39:58
原创
1161人浏览过

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 ="./ext"更改为extension_dir ="D:/wnmp/php5/ext"
;extension=php_mysql.dll 去掉分号
;extension=php_mysqli.dll 去掉分号(打开数据库动态链接库)
登录后复制

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

;cgi.fix_pathinfo=0 去掉分号并改为 cgi.fix_pathinfo=1
登录后复制

3、配置nginx

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

        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # 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;
        #}
登录后复制

改为:

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

保存配置文件。

4、运行nginx和php

输入命令:

D:\wnmp\php5>php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini
登录后复制

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

快捷启动设置:先下载RunHiddenConsole.exe这个文件放入nginx目录中,然后将以下代码保存为start_nginx.bat

@echo off  
set php_home=../php5/
set nginx_home=./
echo Starting PHP FastCGI...  
RunHiddenConsole %php_home%/php-cgi.exe -b 127.0.0.1:9000 -c %php_home%/php.ini  
echo Starting nginx...  
RunHiddenConsole %nginx_home%/nginx.exe -p %nginx_home%
exit
登录后复制

将以下代码保存为stop_nginx.bat

@echo off  
echo Stopping nginx...    
taskkill /F /IM nginx.exe > nul  
echo Stopping PHP FastCGI...  
taskkill /F /IM php-cgi.exe > nul  
exit
登录后复制

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

5、安装配置mysql 下载mysql:http://dev.mysql.com/downloads/mysql/,然后解压到D:/mnmp目录下 在my-default.ini中找到
basedir=C:\Program Files\MySQL\ 去掉#(mysql所在目录)
datadir
=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 用户密码
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学