鍍金池/ 問答/PHP  Linux/ laravel上線之后nginx報500,什么問題?

laravel上線之后nginx報500,什么問題?

上線了項目之后,報這個錯;

clipboard.png

已經(jīng)配置了storage和bootstrap文件夾的權(quán)限;

clipboard.png

這個是.env的配置文件,應該也沒有什么問題;

clipboard.png

這個是nginx的二級域名的配置文件,截圖截不全,就直接貼代碼了;


server
    {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;
        server_name laravel.killlol.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/laravel/public;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        #  include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }
        
        location /'
        {
          try_files $uri $uri/ /index.php?$query_string;
        }

    try_files $uri $uri/ @rewrite; 
  
        location @rewrite { 
          rewrite ^/(.*)$ /index.php?_url=/$1; 
        } 
        access_log  /home/wwwlogs/access.log;
    }

這個是我namesilo上的解析地址;

clipboard.png

我覺得是Nginx的解析有問題,因為跑了幾次,Nginx的日志文件都沒有相應的記錄,是這個問題嗎?求助;

ps:

nginx的配置文件如下;

clipboard.png

把.env里的APP_URL的內(nèi)容刪掉了,但是還是不行;

clipboard.png

最新進展

應該是Nginx配置的問題,但是我這個Nginx配置,之前在阿里云也上線過幾個Laravel的項目,現(xiàn)在在用vultr的VPS,但是這個為什么不行了呢?求助;

server
    {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;
        server_name zhihu.jeffcottlu.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/laravel_zhihu/public;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        #  include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }
        
        location /
        {
          try_files $uri $uri/ /index.php?$query_string;
        }

    try_files $uri $uri/ @rewrite; 
  
        location @rewrite { 
          rewrite ^/(.*)$ /index.php?_url=/$1; 
        } 
        access_log  /home/wwwlogs/access.log;
    }

回答
編輯回答
萌小萌

500就是你代碼有錯 要么就php版本不兼容 和nginx沒關系

2017年11月1日 02:48
編輯回答
糖豆豆

兩個方面
1.storage權(quán)限配置了那么它的子目錄是否也是可以讀寫的權(quán)限,如果你在配置權(quán)限的時候少了-R那么里面的子目錄還是不能寫的
2.你的.env里面的APP_URL=“http://localhost”,但是你的nginx配置的卻是“l(fā)aravel.killlol.com“”;直接把.env中的APP_URL=http://localhost注釋掉

nginx配置

clipboard.png
這個是我自己的linux下的配置,運行l(wèi)aravel沒問題。如果再有問題那你就要去找運維了

2018年7月2日 02:03
編輯回答
凝雅

剛好我今天也遇到這個問題,我一般都會從這幾個方面查找
1.文件需要讀寫權(quán)限
2.nginx配置錯誤
3.php版本不對應
你可以去php.ini把display_errors = OFF修改成On 會打印出錯誤信息

2018年3月6日 19:48
編輯回答
還吻

加 nginx 錯誤日志查看,

clipboard.png

nginx用lravel注意這個東西

2017年1月30日 03:53
編輯回答
脾氣硬

排除方法:

1.確認 nginx 的配置是正確有效的。

嘗試訪問:http://laravel.killlol.com/robots.txt,如果該文本文件能夠訪問,說明 nginx 配置有效,能正常映射到 Laravel 目錄。

2.如果第一步訪問也是 500 或者 404 ,說明是 nginx 的配置問題。

3.如果第一步能正常訪問,但是訪問 Laravel 路由 500 錯誤,說明是 Laravel 引起的錯誤,但是這種 500
錯誤,不會記錄到 Laravel 的日志上,只會記錄到 nginx 或者 PHP 上。但是看你的 nginx 配置,并沒有配置 ,可以加上下面這段配置。

error_log /data/logs/yoursite.error.log;

加好記得 nginx reload 后,再進行排錯嘗試。

4.PHP 層面的錯誤日志默認是關閉的,可以開啟。具體方法自行百度。

希望能幫到你。

2018年1月30日 16:09
編輯回答
絯孑氣

還有一種個能是需要關閉selinux (centos)

2018年1月8日 21:41