2014-11-04 20 views
2

我試圖安裝laravel(嘗試過5和4),但我不斷收到502錯誤的網關錯誤。502運行默認的laravel應用時出現錯誤的網關,而其他php文件正常運行

在網上搜索導致了一些關於unix-socket錯誤權限的答案。但我的PHP設置爲其他域使用完全相同的參數功能,你所期望的。

這是經由

/data/$ laravel new myapp 

nginx的配置的框架的後一個乾淨的設置/配置安裝:

server { 
    listen 80; 

    root /data/myapp/public/; 
    index index.php index.html index.htm; 

    server_name example.net; 

    location/{ 
      try_files $uri $uri/ index.php?$query_string; 
    } 

    location ~ \.php$ { 
      try_files $uri /index.php =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include fastcgi_params; 
    } 

}

LS -ahl的/ var /運行/ php5- fpm.sock

srw-rw---- 1 www-data www-data 0 Nov 4 10:05 /var/run/php5-fpm.sock 

在www.conf(PHP的一部分的配置)

listen = /var/run/php5-fpm.sock 
listen.owner = www-data 
listen.group = www-data 

如前所述這種配置工作只是完全相同的設置罰款。唯一更改爲服務器指令的是server_nameroot

這怎麼可能?

+0

laravel日誌中有什麼? – Jerodev 2014-11-04 10:29:16

+0

我在哪裏可以找到這個日誌?/myapp/storage/logs文件夾完全是空的。 – stUrb 2014-11-04 10:32:50

+0

'app/storage/logs' – Jerodev 2014-11-04 10:55:29

回答

3

Zend的OPCache顯然有些問題。如果你在php.ini中禁用它,像這樣

opcache.enable=0 

該應用程序突然工作。

爲什麼?我不知道,那讓我困擾。但現在它工作。如果有人知道背後的原因:我會接受你的答案,而不是我的答案。

+1

只是想補充一點:我爲Nginx和PHP-FPM設置了單獨的Docker容器的Laravel 5。我已經用盡了所有關於這個502壞網關問題的所有其他答案。他們都沒有爲我工作。這個人做到了,我和你一樣不安,我不知道爲什麼。我希望能在未來找到答案。無論如何感謝提示。 – brism 2015-03-24 07:14:17

+0

同樣發生在我身上。我不得不在舊的php 5.3.2服務器上安裝Zend Opcache 7.0.5,並且我得到了502錯誤。只有禁用opcache纔會使錯誤消失。 – YOMorales 2015-06-19 22:10:41

+0

Laravel真的很爛嗎?那麼,如果你的屁股無法正常安裝框架,那麼是的,它非常糟糕。 – 2016-05-26 10:42:07

0


我想你的nginx配置可能會出現一些錯誤。
因此,我使用您的nginx配置在我的VPS上創建了一個全新的應用程序。就像你一樣,我得到了502錯誤的網關錯誤。然後我複製了一個配置文件,工作正常,我得到了「異常處理程序錯誤」。運行後出錯。它表明nginx可以和我的Laravel應用程序一起工作,但只有一些權限問題。
這裏是我的配置:

server { 
    listen 80; 
    server_name yourdomain.com; 
    root /root/to/yourapp/public; 
    index index.html index.php; 

    location/{ 
     try_files $uri $uri/ /index.php$is_args$query_string; 
    } 

    location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
    } 
} 

然後我跑

sudo chmod -R 777 /root/to/yourapp/app/storage/ 

然後應用程序完美的作品。 希望這可以幫助你。

+0

這沒有奏效。與此配置文件不同的是fast_cgi_pass參數表示IP:port而不是套接字。我的PHP設置爲通過unix套接字來運行;因爲這對其他非laravel項目工作得很好...... – stUrb 2014-11-04 12:36:17

相關問題