简体   繁体   中英

Laravel and Azure Error: Internal Server Error

I have an App Service on Microsoft Azure that uses Laravel 5.2 and PHP 7. The problem that I have is that sometimes while I'm browsing the site I get the error:

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

This happens randomly but when it happens it blocks the route, for example I'm browsing without problems the address http://elsitio.com/details/12 then I click again and it throws the error.

To get rid of the error I have to restart the App Service and it will work fine so I think that it has something to do with the Views Cache in the app.

Aside from setting the Laravel .env I haven't done any configurations.

Using phpinfo I found that the site appears to be running on FastCGI, but I'm not really sure about that, since the error shown appears to be managed by IIS.

My questions are:

  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 .

UPDATE 1

It's a very strange error, sometimes I get the error that some componentes are missing: Interface 'Illuminate\\Contracts\\Queue\\QueueableCollection' not found then I do $: composer install and it starts to work, then I reload the page and I get another error related to a missing component.

If I change the PHP version it starts to work again :(.

Usually, when you get a 500 http error, it means that you may occur a php fatal error. You can enable the display errors configuration to diagnosis the error. Meanwhile, considering you are facing a randomly issue, you can also enable the error log, for tracing the issue.

You can refer to Info About PHP Fatal Error and Error Log on Azure Website for more info. Also you can refer to How to: Change the built-in PHP configurations .

Any further concern, please feel free to let me know.

I had a problem when migrating to Azure that Composer wouldn't pull certain files when I ran composer install . Try downloading the file manually from here and run composer dump-autoload .

If everything is done correctly, just do the following.

  1. Create a web.conf under public .
  2. Copy the code below.

     <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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM