首页 文章

在laravel应用程序中调用index.php时出错500(Windows环境)

提问于
浏览
13

我正在使用IIS在基于Windows的docker容器中部署laravel应用程序 . 当我在运行docker容器后运行应用程序时,C:\ inetpub \ wwwroot中的server.php页面工作正常 . 但是,C:\ inetpub \ wwwroot \ public \ index.php返回500错误 . 我已启用日志,运行编辑器更新和应用目录权限 . 但仍然没有运气 .

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),如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>

4 回答

  • 0

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

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

    如果没有任何帮助,请检查项目中的“storage”文件夹权限 . 通常500自带写入权限或服务器配置错误,可能是由于写入权限错误,laravel.log可能为空!

  • 0

    从头到尾,这些是我在设置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

  • 1

    如果配置文件格式不正确,通常会发生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/

  • 0

    500错误是服务器错误 . 看到你的server.php页面工作正常,我不认为配置文件中的任何内容导致错误 . 更可能的是,你的index.php页面中有一些导致错误的php代码 . 我建议使用xdebug逐步执行代码来查找错误 .

相关问题