部署laravel应用程序后出现500内部服务器错误

c6ubokkw  于 2023-05-08  发布在  其他
关注(0)|答案(3)|浏览(221)

我得到500内部服务器错误后,部署laravel应用程序共享主机。主页只工作。当我点击主页导航栏上的其他页面链接时,我得到了错误。
我正在粘贴错误日志,可能会有帮助

#18 /home/sham/auction/app/Providers/AppServiceProvider.php(28): Illuminate\\Database\\Eloquent\\Builder->get()
#19 [internal function]: App\\Providers\\AppServiceProvider->boot()
#20 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#21 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#22 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#23 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#24 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#25 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\\Container\\Container->call(Array)
#26 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(839): Illuminate\\Foundation\\Application->bootProvider(Object(App\\Providers\\AppServiceProvider))
#27 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}(Object(App\\Providers\\AppServiceProvider), 20)
#28 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): array_walk(Array, Object(Closure))
#29 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#30 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
#31 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(156): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#32 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#33 /home/sham/auction/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#34 /home/sham/public_html/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#35 {main}

AppServiceProvider Boot 方法

public function boot()
    {
        $categories = Category::take(10)->latest()->get();
        View::share('categories', $categories);
    }
oaxa6hgo

oaxa6hgo1#

您需要阅读错误。
最上面一行告诉您错误在文件home/shamcgav/auction/app/Providers/AppServiceProvider.php的第28行。
特别是调用Illuminate\\Database\\Eloquent\\Builder->get()时出错。
如果您可以在AppServiceProvider.php的第28行的数据库查询中找到对->get()的调用,则可能会看到错误。如果您无法找到错误,请将该文件的内容发布在这里!

7gyucuyw

7gyucuyw2#

我们必须得到最新的数据,然后我们得到前10个元素。代码如下:

public function boot()
{
  $categories = Category::latest()->take(10)->get();
  View::share('categories', $categories);
}
fhity93d

fhity93d3#

上次我在Linux操作系统中创建了一个Laravel项目并将其上传到共享主机时,我很难修复500内部错误问题。所以,我将项目克隆到Windows PC上,更新Composer,然后压缩项目并将其上传到共享主机,它工作得很好。
你也可以尝试更新联赛/flysystem,因为这是主要的区别,当我更新 composer 后,克隆Laravel应用程序到Windows PC。
我希望这对你也有效

相关问题