【问题标题】:Laravel 500 server error on shared hosting共享主机上的 Laravel 500 服务器错误
【发布时间】:2021-10-18 20:06:50
【问题描述】:

我正在尝试使用 namecheap 部署我的 laravel 项目,但出现 500 服务器错误。我已更新 server.php 和 index.php 以指向正确的目录,但仍然出现错误。我已经检查了 public_html 目录中的 error.log 文件,但是在加载站点时它没有给出任何错误。我还仔细检查了 .env 文件以确保输入了正确的数据库凭据。

index.php

if (file_exists(__DIR__.'/../nue/storage/framework/maintenance.php')) {
    require __DIR__.'/../nue/storage/framework/maintenance.php';
}
require __DIR__.'/../nameofproject/vendor/autoload.php';

$app = require_once __DIR__.'/../nameofproject/bootstrap/app.php';

server.php

require_once __DIR__.'/../nameofproject/public_html/index.php';

【问题讨论】:

  • 您不应编辑 server.phpindex.php 文件。此类配置应通过您的 apachenginx 配置文件完成。

标签: sql laravel shared-hosting


【解决方案1】:

每当我在共享主机中部署我的 Laravel 项目时。我做的这些事情

  1. 在 public_html 中复制整个应用程序目录(appname)

  2. 域的路径将是“public_html/appname/public”

  3. 使用 ssh 链接存储路径

【讨论】:

    【解决方案2】:

    如果您的 Laravel 项目安装在 webroot 中(假设为 public_html),请执行以下操作:

    1. public/ 的内容向上移动一个目录到webroot。 index.phpserver.php 现在应该与您的 .env 位于同一目录中。
    2. index.php 中,将../vendor/autoload.php 更改为vendor/autoload.php,将../bootstrap/app.php 更改为bootstrap/app.php
    3. server.php 中,将 public/index.php 更改为 index.php

    【讨论】:

    • 我做了更多的挖掘并再次检查了错误日志。我可以看到它在 public_html 文件夹中寻找 vendor/autoload.php 文件(PHP 致命错误:require(): Failed opening required '/home/.../public_html/nameofproject/vendor/autoload.php') .但是,我的项目位于 public_html 文件夹之外的单独目录中。我应该更改哪个文件以将其指向正确的路径?
    • “我的项目位于 public_html 文件夹之外的单独目录中” - 那可能是什么实际目录?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 1970-01-01
    • 2021-01-11
    • 2019-12-08
    • 2018-05-26
    • 1970-01-01
    • 2019-09-20
    相关资源
    最近更新 更多