您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

windows下配置wnmp - 蜀都小一

2024/3/14 7:04:15发布19次查看
最近尝试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=d:\wnmp\mysql\ 去掉#(mysql所在目录)
datadir=d:\wnmp\mysql\data 去掉#(mysql所在目录\data)
命令行进入目录:cd d:\wnmp\mysql\bin,输入以下命令安装mysql:mysqld -install  (安装后可以在服务中找到)
启动服务:net start mysql,关闭服务:net stop mysql 。也可以在服务中启动或者关闭。
添加path变量:在计算机>属性>高级系统中设置>环境变量中添加:d:\phpenv\mysql\bin
登录命令:mysql -h 主机ip -u 用户名 -p 用户密码
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product