nginx 解压至 D:/wnmp/nginx 文件夹下
mysql 安装到 D:/wnmp/mysql 文件夹
php 解压至 D:/wnmp/php 文件夹下
将php.ini-development 另存为php.ini ,打开php.ini 修改扩展所在路径
extension_dir = "D:\wnmp\php\ext"
打开需要的PHP扩展(视情况而定)
extension=php_mysql.dll
extension=php_mysqli.dll
设置CGI 跟nginx 通信
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
修改如下代码
location / {
root html;
index index.html index.htm;
}
改为
location / {
root D:/wnmp/nginx/html;
index index.php index.html index.htm;
}
让nginx支持PHP的设置,代码位置如下
# location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
修改为
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
cmd 打开dos 窗口
启动php内置的cgi程序,在9000端口监听nginx发过来的请求:
D:\wnmp\php>php-cgi.exe -b 127.0.0.1:9000 -c D:\wnmp\php\php.ini
在html 文件夹下新建index.php 文件,输入如下代码:
<?php phpinfo(); ?>
在浏览器地址栏输入 127.0.0.1 检测是否可以看到PHP相关信息
将RunHiddenConsole 移动到nginx.exe 同级目录
新建start_nginx.bat 输入如下代码:
@echo off
echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php/php.ini
echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx
echo Starting mysql...
RunHiddenConsole D:/wamp/bin/mysql/mysql5.7.14/bin/mysqld.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
echo Stopping mysql...
taskkill /F /IM mysqld.exe > nul
exit