dongzhong5573 2019-06-05 09:51
浏览 268

无法使用nginx加载php页面 - 502 Bad gateway

I have PHP 7.2.17 and Nginx 1.15.9 on Ubuntu 19.04. I have this nginx configuration :

server {  
  listen 80;
  listen [::]:80;
  server_name dev.frameworkcms.com;

  set $rootpath "/var/www/html/perso/framework-cms test";  

  error_log "/var/www/html/perso/framework-cms test/logs/error.log" error;
  # combined by default
  access_log "/var/www/html/perso/framework-cms test/logs/access.log";

  root $rootpath/web;

  location ~ \.php$ {
    fastcgi_intercept_errors on;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index Resources.php;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/var/run/php7.2-fpm.sock;
  }
}

I tried with the port 9000 as well. i can see the index.html at the project root but not the file web/Resources.php.

I always have a 502 Bad Gateway. Logs are empty.

Edit

I just added a line try_files \$uri /Resources.php; at the beginning of the location block. Now the php file is offered for download...

Edit

Thanks to @Pete Cooper, I have found that the .sock file is not the good one.

Here is the new version of the file :

server {  
  listen 80;
  listen [::]:80;
  server_name dev.frameworkcms.com;

  set $rootpath "/var/www/html/perso/framework-cms test";  

  error_log "/var/www/html/perso/framework-cms test/logs/error.log" error;
  # combined by default
  access_log "/var/www/html/perso/framework-cms test/logs/access.log";

  root $rootpath/web;

  location ~ \.php$ {
    try_files \$uri /Resources.php;
    fastcgi_intercept_errors on;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index Resources.php;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  }
}

I now have a 500 Internal Server Error. I precise that I work locally.

  • 写回答

1条回答 默认 最新

  • duanna5749 2019-06-05 10:09
    关注

    Try restarting your php-fpm service.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器