Laravel 使用 apache 和 php 7 在 centos 7 上给出 500 个内部错误

Laravel giving 500 internal error on centos 7 with apache and php 7

我是centos的新手。我已经安装了 apache 和 php 7。我还安装了 laravel 所需的所有 php 扩展。

我有一个 laravel 应用程序在 windows.I 上运行良好刚刚将我的代码从 windows 转移到 centos 7.The 问题是现在它在控制台中显示 500 内部错误在每条路线上。 我已经按照此处的说明更改了 .htaccess 代码:

https://laravel.com/docs/5.0/configuration#pretty-urls

文件夹存储权限和 bootstrap 设置为 777,也启用 mod_rewrite。

另外,当我安装新的 laravel 时,它无法正常工作。当我从

更新 web.php 中的主要路线时
Route::get('/', function () {
    return view('welcome');
});

Route::get('/', function () {
    return 'welcome';
});

它显示欢迎信息,但是对于

Route::get('/', function () {
    return view('welcome');
}); 

在控制台中出现 500 内部错误并出现空白页面。

httpd Error log

如您的错误日志文件所示,写入日志文件时存在权限问题。

你可以试试 :-

1- 禁用日志记录,或者换句话说禁用 Monolog 包“Unrecommended

2- 跟踪您的错误日志显示,如您所说,写入日志时存在权限问题:-

folder rights to storage and bootstrap is set to 777

因此请确保您已将 storage 目录权限更改为 777 递归

第一步: 您必须通过将此添加到您的虚拟主机来启用 .htaccess:

<Directory /var/www/html/yourfoldername/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

第 2 步:并永久禁用 SELinux。 Click here