laravel编辑index.php后上传HTTP错误500

时间:2018-10-24 08:43:46

标签: php laravel cpanel

我的PHP版本是7.2 我已经将我的laravel 5.7.9上传到public_html文件夹中,然后将public文件夹的文件移动到public_html文件夹中。然后我编辑了index.php文件。 这是我的index.php文件的代码

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| 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__.'/vendor/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__.'/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(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

?>

但是仍然出现此错误。任何人都请帮助我

此页面无效 desktim.contents.management当前无法处理此请求。 HTTP错误500

2 个答案:

答案 0 :(得分:0)

将index.php文件恢复为原始状态,并使用以下方法

如Burak Erdem所述,另一种选择(也是更可取的选择)是将其放在\ App \ Providers \ AppServiceProvider register()方法中。

/**
 * Register any application services.
 *
 * @return void
 */
   public function register()
   {
    // ...

    $this->app->bind('path.public', function() {
        return base_path('public_html');
    });
}

答案 1 :(得分:0)

在您的index.php文件中更改此代码

$app = require_once __DIR__.'/../bootstrap/app.php';
require __DIR__.'/../vendor/autoload.php';
相关问题