安装windows 下 php7+nginx+fastcgi
php环境安装很多次了,这次还是整了半天,记录下后面好少走弯路.
开始
先下载东西?
php7 : http://windows.php.net/download#php-7.0
vc14: https://www.microsoft.com/zh-CN/download/details.aspx?id=48145 (vcruntime14)
nginx: http://nginx.org/en/download.html
RunHiddenConsole: http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip
创建目录
D盘创建了个 nmp的目录
php安装
解压到 D:/nmp/php
复制一份php.ini-development 为php.ini
更改php.ini extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_pgsql.dll
这些前面的分号注释去掉
extension_dir = "ext"
nginx 安装
解压到 D:/nmp/nginx
更改config/nginx.conf
location / {
root D:/nmp/www;
index index.html index.htm;
}
#这里最好多个,否则会有curl localhost不成功的情况
upstream myfastcgi {
server 127.0.0.1:9000 weight=1;
server 127.0.0.1:9001 weight=1;
server 127.0.0.1:9002 weight=1;
server 127.0.0.1:9003 weight=1;
}
注意 这里的 D:/nmp/www; 不要写成 D:\nmp\www; 否则\n 会被转义。
location ~ \.php$ {
root D:/nmp/www;
fastcgi_pass myfastcgi;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
制作启动,停止脚本
RunHiddenConsole 解压到D:\nmp
启动脚本 start.bat
@ECHO OFF
ECHO Starting PHP FastCGI...
set PHP_FCGI_MAX_REQUESTS=100
D:\nmp\RunHiddenConsole.exe D:\nmp\php\php-cgi.exe -b 127.0.0.1:9000 -c D:\nmp\php\php.ini
D:\nmp\RunHiddenConsole.exe D:\nmp\php\php-cgi.exe -b 127.0.0.1:9001 -c D:\nmp\php\php.ini
D:\nmp\RunHiddenConsole.exe D:\nmp\php\php-cgi.exe -b 127.0.0.1:9002 -c D:\nmp\php\php.ini
D:\nmp\RunHiddenConsole.exe D:\nmp\php\php-cgi.exe -b 127.0.0.1:9003 -c D:\nmp\php\php.ini
echo Starting nginx...
RunHiddenConsole D:\nmp\nginx\nginx.exe -p D:\nmp\nginx
ping 127.0.0.1 -n 1>NUL
echo .
echo .
echo .
ping 127.0.0.1 >NUL
停止脚本 stop.bat
@ECHO OFF
taskkill /f /IM nginx.exe
taskkill /f /IM php-cgi.exe
EXIT
直接双击 start.bat 启动, stop.bat 停止。 启动如果提示,找不到vcruntime14.dll 记得安装vc14 哈,如果你常用vs 直接安装个vs2015吧
来源:oschina
链接:https://my.oschina.net/u/104204/blog/542752