linux nginx 无法执行php文件

linux nginx 无法执行php文件,第1张

为以前没有接触过nginx ,所以查了一天,查处原因有二:

一、网站根目录

默认是在 /usr/local/nginx/html文件

配置在

location / {

root /home/www/wwwroot

index index.html index.htm

}

二、修改文件中对应的php配置部分

location ~ \.php$ {

root /home/www/wwwroot

fastcgi_pass 127.0.0.1:9000

fastcgi_index index.php

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

includefastcgi_params

}

特别需要注意的是:fastcgi_param这个参数默认的是$fastcgi_script_name最好改为$document_root$fastcgi_script_name我在实际配置中出现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root

因为kali自带apache2和php,所以只要开启apache服务就可以访问php文件。

开启apache服务

service apache2 start

然后在浏览器中输入

localhost

如果显示apache的信息页面就是成功了。

apache默认网站地址目录 /var/www/html/


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8444868.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-16
下一篇2023-04-16

发表评论

登录后才能评论

评论列表(0条)

    保存