首页 > 解决方案 > Godaddy 上的 Laravel 5.5。产生错误 500。内部服务器错误

问题描述

我已将我的 laravel 文件上传到 Godaddy 共享主机。

我的文件夹结构是这样的

/mediservices
    all-other-laravel-files-and-folders

/public_html
    public
       index.php

public_html 中 public 文件夹中 index.php 的内容已被编辑为指向 medsirvices 文件夹,如下所示 -

22. require __DIR__.'/../../mediservices/bootstrap/autoload.php';
34. $app = require_once __DIR__.'/../../mediservices/bootstrap/app.php';

我已将以下内容添加到 public_html 文件夹中的 .htaccess 文件中

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_URI} !^mediservices
 RewriteRule ^(.*)$ mediservices/$1 [L]
</IfModule>

当我转到域时,我仍然收到 500 内部服务器错误。

完整的信息是

Internal Server Error
The server encountered an internal error or misconfiguration and was 
unable to complete your request.

Please contact the server administrator at webmaster@medcommhospital.com to 
inform them of the time this error occurred, and the actions you performed 
just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying 
to use an ErrorDocument to handle the request.

标签: phplaravelshared-hosting

解决方案


在评论之后,我可以提出以下建议。您需要明确是要在域根目录下还是在域上的文件夹下提供站点。

密切关注您的日志,它们会告诉您问题所在。并确保它实际上是相同的错误,即使是细节上的微小变化也可以为您提供更多信息。

在域根目录下服务站点

如果你想在域根目录下服务你的站点/Laravel 项目,那么example.org/它应该配置如下。

# Contains  all other laravel files
mediservices/
  ...

public_html/ <webserver root> <laravel public dir>
  index.php
  .htaccess

您对引导程序的引用index.php应该是。

__DIR__ . '/../mediservices/bootstrap/autoload.php'

您的.htaccess文件不需要重写规则,因此您可以删除该配置。

在域上的文件夹下服务站点

但是,如果您希望从mediservices/URL 中域部分之后的文件夹中为您的项目提供服务,例如example.org/mediservices/,并将用户重定向到该文件夹​​,您可以保留.htaccess您拥有的重写规则,但您必须将您的 Laravel 公用文件夹移动到以下:

# Contains  all other laravel files
mediservices/
  ...

public_html/ <webserver root>
  mediservices/ <laravel public dir>
    index.php
  .htaccess <should stay under the public_html/ folder>

您使用的引用index.php应该与您的引用相同,如下所示。

__DIR__ . '/../../mediservices/bootstrap/autoload.php'

推荐阅读