【问题标题】:Error 500 when called index.php in laravel application (Windows environment)laravel 应用中调用 index.php 报错 500(Windows 环境)
【发布时间】:2018-02-14 13:03:25
【问题描述】:

我正在使用 IIS 在基于 Windows 的 docker 容器中部署一个 laravel 应用程序。 当我在运行 docker 容器后运行应用程序时,位于 C:\inetpub\wwwroot 的 server.php 页面工作正常。但是,C:\inetpub\wwwroot\public\index.php 返回 500 错误。我也启用了日志、运行 composer update 并应用了目录权限。但还是没有运气。

IIS10 PHP 7.0 Laravel 5.5

日志消息是

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 文件:

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

【问题讨论】:

  • 你能把你的日志贴在这里吗?
  • 由于某种原因,laravel.log 文件为空。
  • 您必须启用日志记录并在日志文件上设置正确的权限。你的 php display_error 开启了吗?
  • Display_error 已开启。当我使用 PS 检查日志文件的权限时,它显示 Access NT Authority\Interactive Allow FullControl
  • 我认为你必须检查/var/lib/docker/containers/&lt;container id&gt;/&lt;container id&gt;-json.log中的docker日志

标签: php docker iis laravel-5


【解决方案1】:

在我看来,这些是我在设置 laravel 时遇到的错误:

1- 目录存储权限

2- 目录引导权限

3-作曲家更新

4- .env 文件可用

5- .env 密钥生成

6- 数据库在那里

7- .env 中的数据库配置正确

8- php artisan serve 如果没有配置虚拟服务器

如果我得到其中任何一个,我会重新启动服务器以更新值。

如果应用程序是一个 repo 并给出了错误,有时下面的工匠命令可以节省一天的时间:

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

【讨论】:

    【解决方案2】:

    500.19 错误通常发生在您的配置文件格式不正确时。在 IIS 中启用详细错误并重现该问题。您将清楚地知道出了什么问题。

    要在 IIS 中启用详细错误 - 单击网站 ---> HTTP 错误--->编辑功能设置---->详细错误。

    或者你也可以关注这个 - 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/

    【讨论】:

    • 我正在将映像部署在 docker 容器(基于 Windows)中。所以除非有一些 PS 脚本可用,否则这将不起作用。
    【解决方案3】:

    您可以在 IIS 上使用导入规则View Apache Import Rule

    看看stackoverflow线程Laravel .htaccess rewrite rule convertion to IIS

    如果没有任何帮助,请检查项目中的“存储”文件夹权限。一般500自带写权限或者服务器配置错误,可能是写权限错误,laravel.log可能为空!

    【讨论】:

      【解决方案4】:

      500 错误是服务器错误。看到您的 server.php 页面工作正常,我认为您的配置文件中的任何内容都不会导致错误。更可能的是,您的 index.php 页面中有一些导致错误的 php 代码。我建议使用 xdebug 单步调试您的代码以定位错误。

      【讨论】:

        猜你喜欢
        • 2017-07-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多