Win7配置Nginx+PHP7
echo "Hello PHP7!";
?>
修改F:\server\nginx-1.10.3\conf\下的nginx.conf文件
listen 80;
server_name localhost;
root html;
index index.html index.htm;
}
root F:/server/demo;
index index.html index.htm index.php;
}
#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;
#}
root D:/soft/PHP/demo;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
去掉注释;号,并修改dir目录为./ext
extension_dir = "./ext"
enable_dl = On
去掉注释;号,并修改为
去掉注释;号:
cgi.fix_pathinfo=1
去掉注释;号:
cgi.fix_pathinfo=1
去掉注释;号:
fastcgi.impersonate = 1
去掉注释;号,并修改为
去掉注释;号,并修改为
PHP7貌似已经取消了支持,编译都没有了--with-MySQL参数,只支持--with-mysqli和--with-pdo-mysql, 故libmysql.dll已经不需要
如果提示api-ms-win-crt-runtime-l1-1-0.dll丢失, 请安装 visual c++ redistributable 2015, 从微软官网上可以下载. 安装对系统的要求必须在win7 sp1以上, 如果win7还未升级的, 安装会失败.
echo Starting PHP FastCGI...
F:\server\nginx-1.10.3\RunHiddenConsole.exe F:\server\php-7.1.1-nts-Win32-VC14-x64/php-cgi.exe -b 127.0.0.1:90 -c F:\server\php-7.1.1-nts-Win32-VC14-x64/php.ini
echo Starting PHP FastCGI...
F:\server\nginx-1.10.3\RunHiddenConsole.exe F:\server\php-7.1.1-nts-Win32-VC14-x64/php-cgi.exe -b 127.0.0.1:9000 -c F:\server\php-7.1.1-nts-Win32-VC14-x64/php.ini
echo Starting PHP FastCGI...
F:\server\nginx-1.10.3\RunHiddenConsole.exe F:\server\php-7.1.1-nts-Win32-VC14-x64/php-cgi.exe -b 127.0.0.1:9001 -c F:\server\php-7.1.1-nts-Win32-VC14-x64/php.ini
echo Starting nginx...
F:\server\nginx-1.10.3\RunHiddenConsole.exe F:\server\nginx-1.10.3/nginx.exe -p F:\server\nginx-1.10.3
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit
http://127.0.0.1/ 或者 http://localhost/index.php 同理 http://localhost/
就可以访问到demo文件夹下的index.php了。
起PHP的时候,可能会爆
php-cgi.exe - 系统错误
---------------------------
无法启动此程序,因为计算机中丢失 VCRUNTIME140.dll。尝试重新安装该程序以解决此问题。
这个错误在Windows下运行php7需要Visual C++Redistributable 2015而之前的版本不需要那么高的,最新版的Apache可能也需要这个组件,这个组件是运行Visual Studio 2015所建立的C++应用的必要组件,安装一次即可解决环境问题,那么去微软官网下载安装程序,安装一遍即可。有64位版和32位版,根据计算机配置进行下载,下面是下载链接:
下载之后运行,根据提示安装即可,安装成功之后就立即生效了,再次运行start_nginx.bat即可成功!
附上RunHiddenConsole.exe的下载链接:http://download.youkuaiyun.com/detail/a101307046/9754026
Nginx1.10.3+PHP7.1.1 下载链接http://download.youkuaiyun.com/detail/a101307046/9754047