首先
下载nginx服务器 http://nginx.p2hp.com/
下载php https://www.php.net/downloads
然后下载完nginx服务器之后打开目录 打开conf目录 有一个nginx.conf文件nginx的配置文件 打开之后 在http{}里的server{}里 加上
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;
}
这段代码 如果有的话就取消注释就可以了 然后location里
location / {
root html;
index index.html index.php index.htm;
}
加上index.php 然后就是php 打开php配置文件php.ini
cgi.fix_pathinfo=0 这个设置0
doc_root = "C:UsersAdministratorDesktopnginx-1.22.0html"; 这个为nginx目录里的html目录
根据自己电脑安装的路径来就行 然后保存 重启nginx服务器 就是nginx目录的 nginx.exe
然后打开命令行切换到php安装目录 输入 php-cgi.exe -b 127.0.0.1:9000
也就是 fastcgi_pass 127.0.0.1:9000; 这一项 前面nginx配置文件配置过的 然后 回车
别关掉命令行
然后nginx配置文件 listen 80; 这一项配置的啥地址栏就输入啥 比如我的
127.0.0.1:80 然后在html目录 写php文件就可以运行解析了。
来源地址:nginx服务器解析php文件
转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:软师兄,谢谢!^^
- 本文来源链接地址: https://www.npspro.cn/1175.html