2016-11-25 50 views
1

我有一個使用Laravel 5.2和PHP 7.我是,有時當我瀏覽該網站,我得到了錯誤的問題上微軟Azure的應用服務:Laravel和Azure的錯誤:內部服務器錯誤

this page cannot be displayed because an internal server error has occurred

這種情況是隨機發生的,但是當它發生時它會阻止路線,例如我瀏覽沒有問題的地址http://elsitio.com/details/12然後我再次單擊並引發錯誤。

爲了擺脫錯誤,我必須重新啓動應用服務,它會正常工作,所以我認爲它與應用中的視圖緩存有關。

除了設置Laravel .env我還沒有做任何配置。

使用phpinfo我發現該網站似乎在FastCGI上運行,但我不太確定,因爲顯示的錯誤似乎是由IIS管理的。

我的問題是:

  1. Any ideas on what may be causing the problem?

  2. How can I restart FastCGI/IIS service without restarting the App Service, for example in Apache over Linux would be service httpd restart .

更新1

這是一個非常奇怪的錯誤,有時我得到一些COMPONENTES缺少錯誤:Interface 'Illuminate\Contracts\Queue\QueueableCollection' not found然後我做$: composer install並開始工作,然後我重新加載頁面,我得到與缺失組件有關的另一個錯誤。

如果我改變PHP版本,它再次開始工作:(。

+0

它煤層您在ENV文件'APP_DEBUG = FALSE'已經設置,你不能看到實際的錯誤。也可以添加你的''。env'(沒有關於數據庫連接的信息) – Kliment

+0

APP_DEBUG設置爲true :) – JohnnyAce

回答

1

通常情況下,當你得到一個500 HTTP錯誤,這意味着你可能會出現一個PHP致命錯誤。你可以使顯示的錯誤配置對診斷錯誤。同時,考慮到你所面臨的隨機問題,您還可以啓用錯誤日誌,用於跟蹤問題。

您可以參考Info About PHP Fatal Error and Error Log on Azure Website獲得更多信息。您也可以參考How to: Change the built-in PHP configurations

如有任何問題,請隨時通知我。

+0

這是一個非常奇怪的錯誤,有時我得到某些Laravel元素丟失:'Interface'Illuminate \ Contracts \ Queue \ QueueableCollection'not找到'然後我做$:作曲家安裝,它開始工作,然後再次工作,然後我重新加載頁面,我得到另一個錯誤。如果我更改PHP版本,它開始再次工作:( – JohnnyAce

1

我在遷移到Azure時遇到了問題,即在運行composer install時,Composer不會拉動某些文件。嘗試手動下載文件 from here並運行composer dump-autoload

0

如果一切正常完成,只需執行以下操作。

  1. 創建一個web.confpublic
  2. 複製下面的代碼。

    <configuration> 
        <system.webServer> 
        <rewrite> 
         <rules> 
         <rule name="Imported Rule 1" stopProcessing="true"> 
          <match url="^(.*)/$" ignoreCase="false" /> 
          <conditions> 
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
          </conditions> 
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" /> 
         </rule> 
         <rule name="Imported Rule 2" stopProcessing="true"> 
          <match url="^" ignoreCase="false" /> 
          <conditions> 
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
          <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
          </conditions> 
          <action type="Rewrite" url="index.php" /> 
         </rule> 
         </rules> 
        </rewrite> 
        </system.webServer> 
    </configuration>