laravel - 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
有什么解决办法?
解决方案
首先,在共享托管中将项目设置在 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 项目的更多信息,您可以查看此链接
推荐阅读
- c++ - 如何从函数返回范围视图?
- wordpress - 可以从网站前端访问 WordPress 插件中的 CSV 文件吗?
- javascript - 如何获得一个月中的任何一天的日期?
- sql - SQL:第二旧的日期
- simics - Simics 使用的 BIOS 文件在磁盘的哪个位置?
- bash - 在 shell 中的电报机器人中发送内联按钮
- flutter - 无法配置 Flutter firebase 消息传递
- r - 对泊松族混合模型使用 merTools::predictInterval
- kubernetes - CronJob 在 k8s 1.19.11 中创建为作业
- django - Django Heroku:剩余的连接槽保留给非复制超级用户连接