nginx 启动php失败,求助

服务器环境为
PHP 7.1.9-1+ubuntu16.04.1

在nginx的配置文件里这么写的:

server{

  listen   80;
    server_name www.xxxx.cn;
    root /home/kuangcs/sites/www.xxxx.cn;
    index index.html index.htm index.php;
  location ~ \.php$ {
  fastcgi_pass unix:/run/php/php7.1-fpm.sock;
  #fastcgi_index index.php;
  include fastcgi_params;
  } }

重启nginx后房屋域名可访问该目录下txt文件,访问php文件为一片空白,特询问如何正常配置,谢谢。

阅读 3.4k
2 个回答

按下面的方法写,自行搞定。
可能的原因是在php7.1下建议不用9000端口解决。

server{

listen 80;
server_name www.xxx.cn;
root /home/kuangcs/sites/www.xxx.cn;
autoindex on;   location ~ \.php$ {
root           /home/kuangcs/sites/www.xxx.cn;
fastcgi_pass    unix:/run/php/php7.1-fpm.sock;
fastcgi_index  index.php;
fastcgi_intercept_errors        on;
fastcgi_param  SCRIPT_FILENAME  /home/kuangcs/sites/www.xxx.cn/$fastcgi_script_name;
include        fastcgi_params;
} }
   location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            try_files $uri $uri/ /index.php?$query_string;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题