win7下配置nginx+php+mysql开发环境
发表时间:2014-4-9 评论:0 点击 2,050+
Windows7下配置nginx+mysql+php开发环境,所需软件包如下
nginx-1.5.13.zip
http://nginx.org/download/nginx-1.5.13.zip
mysql-5.5.15-win32.msi
http://pan.baidu.com/s/1pJnYid9
php-5.5.11
http://windows.php.net/downloads/releases/php-5.5.11-nts-Win32-VC11-x86.zip
nginx解压即可使用,
mysql按步骤安装
php解压即可
把3个软件最好放在一个地方
接下来配置服务器打开D:\lamp\nginx-1.5.12\conf 下nginx.conf文件
找到43行左右改为
location / {
root D:\lamp\www;
index index.html index.htm index.php;
}
找到65行左右改为
location ~ \.php$ {
root D:\lamp\www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
配置PHP参考
nginx需要的是cgi方式的php,所以如下几个地方是重点,否则nginx无法打开php文件:
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
下载RunHiddenConsole方便用来启动服务器
http://pan.baidu.com/s/1sjEs3db
开启服务器
@echo off
echo Starting PHP FastCGI…
RunHiddenConsole.exe D:\lamp\php54\php-cgi.exe -b 127.0.0.1:9000 -c D:\lamp\php54\php.ini
echo Starting nginx…
cd /d D:\lamp\nginx-1.5.12
start nginx.exe
停止服务器
@echo off
echo Stopping nginx…
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI…
taskkill /F /IM php-cgi.exe > nul
exit
以上注意相关路径,自己修改。
最后写入phpinfo文件测试一下,我不是用的最新版本。