Laravel项目部署给出HTTP错误500



在你假设之前,我确实阅读了关于这个问题的所有其他帖子,但我无法找到解决问题的方法。

所以问题是,无论何时何地,我在虚拟主机上上传文件和文件夹,我都会得到相同的结果,给我"目前无法处理此请求。HTTP 错误 500"。我正在使用 000webhostapp。

所以我把我的根目录"/"中的项目上传了,公众的内容上传到了public_html项目,它给了我上面的文字。然后我尝试将我的整个项目移动到public_html(public 是 public_html 中自己的目录),它给了我相同的结果。我已经尝试了一些带有.htaccess文件的解决方案,但是无论我尝试什么都不会使其正常工作。在我的本地主机项目中,安装有点像这个"htdocs/kola/..",但在网络托管上它只是在根目录中,没有其他目录(我认为这可能会有所帮助,但我无法使用)。因此,经过 30 个小时的尝试并重新上传了 5 次项目,仍然无法使其正常工作,如果有人能尝试帮助我解决这个问题,我将不胜感激。

提前致谢

正确的方法是找到文件夹的根目录...即/home/并为您的项目创建一个文件夹。 然后将项目的所有内容移动到此文件夹中,但公用文件夹除外。 现在转到public_html文件夹并在那里添加公用文件夹的所有内容。

按如下方式更新您的index.php

<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package  Laravel
* @author   Taylor Otwell <taylor@laravel.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../(name of your root folder)/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../(name of your root folder)/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(IlluminateContractsHttpKernel::class);
$response = $kernel->handle(
$request = IlluminateHttpRequest::capture()
);
$response->send();
$kernel->terminate($request, $response);

配置.env文件并具有正确的数据库配置。

不需要创建新的目录。只需删除index.php文件的内容并粘贴上述代码,然后将您的(根文件夹的名称)替换为public_html。

最新更新