13

I am deploying a laravel application inside windows based docker container using IIS. When I run the application after running docker container the server.php page present at C:\inetpub\wwwroot works fine. However, C:\inetpub\wwwroot\public\index.php returns 500 error. I have enabled the logs, run composer update and applied directory permissions as well. But still no luck.

IIS10 PHP 7.0 Laravel 5.5

The log message is

GET /public/index.php - 80 - 172.18.224.1 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+Touch;+rv:11.0)+like+Gecko - 500 19 13 1

web.config file:

<configuration>

<staticContent>
    <remove fileExtension=".woff" />
    <remove fileExtension=".woff2" />

    <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
    <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />

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

Usama Aslam
  • 437
  • 7
  • 18
  • Can you paste your log here? – Mohammad Zare Moghadam Feb 14 '18 at 13:06
  • The laravel.log file is empty due to some reason. – Usama Aslam Feb 14 '18 at 13:21
  • You have to enable logging and set right permissions on log file. Is your php display_error on? – Mohammad Zare Moghadam Feb 14 '18 at 13:24
  • Display_error is on. When I check permissions of log file using PS it shows Access NT Authority\Interactive Allow FullControl – Usama Aslam Feb 14 '18 at 13:31
  • I think you have to check docker log that is in `/var/lib/docker/containers//-json.log` – Mohammad Zare Moghadam Feb 14 '18 at 13:37
  • This is the log generated GET /public/index.php - 80 - 172.18.224.1 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+Trident/7.0;+Touch;+rv:11.0)+like+Gecko - 500 19 13 1 – Usama Aslam Feb 14 '18 at 14:08
  • Can you please check permission on 'index.php' file, it should be 644 – Sachin Vairagi Feb 14 '18 at 15:18
  • {"log":"ERROR ( message:Cannot find requested collection element. )\r\n","stream":"stdout","time":"2018-02-14T15:25:28.4315622Z"} {"log":"Applied configuration changes to section \"system.applicationHost/applicationPools\" for \"MACHINE/WEBROOT/APPHOST\" at configuration commit path \"MACHINE/WEBROOT/APPHOST\"\r\n","stream":"stdout","time":"2018-02-14T15:25:29.565562Z"} {"log":"ERROR ( message:Cannot find requested collection element. )\r\n","stream":"stdout","time":"2018-02-14T15:25:30.027562Z"} Logs obtained from json.log file – Usama Aslam Feb 15 '18 at 07:26

4 Answers4

2

From the top of my head, these are the errors that I faced when setting up laravel:

1- Directory storage permissions

2- Directory bootstrap permissions

3- composer update

4- .env file is available

5- .env key is generated

6- database is there

7- database is configured correctly in .env

8- php artisan serve if the virtual server not configured

and if i got any of those i restart the server to update the values.

if the application was a repo and gave an error, sometimes the below artisan commands save the day:

php artisan cache:clear php artisan route:clear php artisan config:clear php artisan view:clear

Hamza Mohamed
  • 1,373
  • 1
  • 12
  • 28
0

500.19 errors usually occur when you have configuration files that are not well formed. Enable Detailed errors in IIS and reproduce the issue. You will get a clear idea as to what is going wrong.

To enable Detailed errors in IIS - Click on the website ---> HTTP Errors--->Edit Feature Settings---->Detailed Errors.

Or you can follow this as well - https://blogs.msdn.microsoft.com/rakkimk/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers/

Parvez Mulla
  • 526
  • 4
  • 7
  • I am deploying the image inside a docker container (Windows based). So this won't work unless there is some PS script available. – Usama Aslam Feb 15 '18 at 07:21
0

You can use the import rule on IIS View Apache Import Rule

Take a look on stackoverflow thread Laravel .htaccess rewrite rule convertion to IIS

If nothing will helpful check the "storage" folder permission in your project. Usually 500 comes with write permission or mis-configuration of server, may be due write permission error, the laravel.log may be empty!

0

A 500 error is a Server Error. Seeing that your server.php page works fine, I would not think anything in your configuration files is causing the error. More likely that not, there is some php code in your index.php page that is causing the error. I suggest using xdebug to step through your code to locate the error.

Keith Becker
  • 556
  • 1
  • 6
  • 16