您的位置:首页 > 运维架构 > Nginx

安装windows 下 php7+nginx+fastcgi

2016-03-07 17:34 549 查看
摘要: 安装windows 下 php7+nginx+fastcgi

安装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.dllextension=php_curl.dllextension=php_gd2.dllextension=php_mbstring.dllextension=php_openssl.dllextension=php_pdo_mysql.dllextension=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吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php7 nginx vcruntime14