首页 > 解决方案 > Laravel 不在主机中运行

问题描述

我有一个在本地主机上运行良好的 laravel 项目。但是传输到主机后,报如下错误。它运行了几分钟,但几次后错误被执行。

当前无法处理此请求。HTTP ERROR 500

在error_log中发现以下错误

[14-Oct-2018 11:26:33 Asia/Tehran] PHP Warning:
 include(/home/httprami/public_html/local/vendor/composer/../laravel/framework/src/Illuminate/Filesystem/Filesystem.php): failed to open stream: No such file or directory in /home/httprami/public_html/local/vendor/composer/ClassLoader.php on line 444
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Stack trace:
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   1. {main}() /home/httprami/public_html/index.php:0
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   2. require_once() /home/httprami/public_html/index.php:38
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   3. Illuminate\Foundation\Application->__construct() /home/httprami/public_html/local/bootstrap/app.php:15
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   4. Illuminate\Foundation\Application->registerBaseBindings() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:144
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   5. spl_autoload_call() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   6. Composer\Autoload\ClassLoader->loadClass() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   7. Composer\Autoload\includeFile() /home/httprami/public_html/local/vendor/composer/ClassLoader.php:322
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Warning:  include(/home/httprami/public_html/local/vendor/composer/../laravel/framework/src/Illuminate/Filesystem/Filesystem.php): failed to open stream: No such file or directory in /home/httprami/public_html/local/vendor/composer/ClassLoader.php on line 444
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Stack trace:
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   1. {main}() /home/httprami/public_html/index.php:0
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   2. require_once() /home/httprami/public_html/index.php:38
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   3. Illuminate\Foundation\Application->__construct() /home/httprami/public_html/local/bootstrap/app.php:15
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   4. Illuminate\Foundation\Application->registerBaseBindings() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:144
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   5. spl_autoload_call() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   6. Composer\Autoload\ClassLoader->loadClass() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   7. Composer\Autoload\includeFile() /home/httprami/public_html/local/vendor/composer/ClassLoader.php:322
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Warning:  include(): Failed opening '/home/httprami/public_html/local/vendor/composer/../laravel/framework/src/Illuminate/Filesystem/Filesystem.php' for inclusion (include_path='.:/opt/alt/php72/usr/share/pear') in /home/httprami/public_html/local/vendor/composer/ClassLoader.php on line 444
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Stack trace:
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   1. {main}() /home/httprami/public_html/index.php:0
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   2. require_once() /home/httprami/public_html/index.php:38
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   3. Illuminate\Foundation\Application->__construct() /home/httprami/public_html/local/bootstrap/app.php:15
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   4. Illuminate\Foundation\Application->registerBaseBindings() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:144
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   5. spl_autoload_call() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   6. Composer\Autoload\ClassLoader->loadClass() /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
[14-Oct-2018 11:26:33 Asia/Tehran] PHP   7. Composer\Autoload\includeFile() /home/httprami/public_html/local/vendor/composer/ClassLoader.php:322
[14-Oct-2018 11:26:33 Asia/Tehran] PHP Fatal error:  Uncaught Error: Class 'Illuminate\Filesystem\Filesystem' not found in /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:175
Stack trace:
#0 /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(144): Illuminate\Foundation\Application->registerBaseBindings()
#1 /home/httprami/public_html/local/bootstrap/app.php(15): Illuminate\Foundation\Application->__construct('/home/httpramin...')
#2 /home/httprami/public_html/index.php(38): require_once('/home/httpramin...')
#3 {main}
  thrown in /home/httprami/public_html/local/vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 175

有什么解决办法?

标签: laravel

解决方案


首先,在共享托管中将项目设置在 public_html 后面会更好、更安全。你的 laravel 公用文件夹必须作为 public_html 工作。

如您所见,php 警告如此清晰,找不到路径:

/home/httprami/public_html/local/vendor/composer/../laravel/framework/src/Illuminate/Filesystem/Filesystem.php

我可以发现您将项目放在“本地”文件夹中,所以您是否像这样在公共文件夹中更新了 index.php:

require __DIR__.'/../bootstrap/autoload.php';

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

require __DIR__.’/../local/bootstrap/autoload.php’;

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

public/index.php 第 22 和 36 行中的以下 2 行。

有关如何在共享主机上部署 laravel 项目的更多信息,您可以查看此链接


推荐阅读