本文主要介绍如何用Nginx(engine x) 搭建php7的服务器。
1 StartUp
- Nginx http://nginx.org/en/download.html
- php7 : http://windows.php.net
- vc14: https://www.microsoft.com/zh-CN/download/details.aspx?id=48145 (vcruntime14)
- RunHiddenConsole: http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip
2 Install
1 安装vc14
2 解压nginx到D:\Portable\nginx-1.10.3
3 解压Php到D:\Portable\php-7.1.1x64
3 修改配置文件
3.1 nginx 配置文件
1 修改nginx.conf配置:
2 复制并注释掉fastcgi_param,修改/scripts
为$document_root
3.2 php配置文件
1 复制php.ini-development到php.ini 启用以下dll:
php_bz2.dll、php_curl.dll、php_gd2.dll、php_mbstring.dll、php_openssl.dll、php_pdo_mysql.dll、php_pdo_pgsql.dll
2 修改extension_dir 配置的路径:
extension_dir = "D:/Portable/php-7.1.1x64/ext"
4 创建Bat启动脚本
start_nginx.bat
@echo off
set PHP_FCGI_MAX_REQUESTS=1000
echo Starting PHP FastCGI...
RunHiddenConsole D:/Portable/php-7.1.1x64/php-cgi.exe -b 127.0.0.1:9000 -c D:/Portable/php-7.1.1x64/php.ini
echo Starting nginx...
set NGINX_HOME=D:\Portable\nginx-1.10.3
start /D %NGINX_HOME%\ %NGINX_HOME%\nginx.exe
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
5 测试脚本
<?php
echo "hello world";
echo phpinfo();
?>