本次实验主要是完成基于windows 独立安装nginx 独立安装php 并配置 nginx能够解析php脚本
1.下载nginx windows版本
http://10.247.192.74:81/2Q2WEF556DDB25BCF8FC1D5A653D2B4FE59488302DFA_unknown_FDBD76C8763381D56E5ADB89E774142D97D7BD3D_6_116.77.76.201_81/nginx.org/download/nginx-1.16.1.zip
2.下载 php7
https://windows.php.net/downloads/releases/php-7.4.0-src.zip
如果网速不快按下面套路走
https://dl-sh-ctc-2.pchome.net/0e/of/php-7.3.5-Win32-VC15-x64.zip?key=4418587b7671ef611bb040405f23f75e&tmp=1575382206616
3.编写自动化启动cgi脚本
@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=D:\softerware\php;%PATH%
D:\softerware\php\php-cgi.exe -b 127.0.0.1:9123
那个表示php安装目录
4.配置nginx 文件
location / {
root html;
index index.html index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
5.相关目录一览
6.启动
6.1 先启动 php-cgi 需要进入nginx目录
.\start-php-fcgi.bat
6.2 启动nginx
ps 结束windows相关进程命令:
taskkill /f /im nginx.exe
参考文献:
https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/
http://www.xdowns.com/soft/1/71/2012/Soft_89261.html