Laravel 在 CentOS 7 上返回服务器错误 500
Laravel returning server error 500 on CentOS 7
正如标题所说,我在 CentOS 7 上有一个 VPS 运行,我安装了 Laravel、PHP 7.3 的所有必需品,但它仍然提供我 'Server Error 500'。
请注意,这是 Laravel 与 composer 的全新安装。
- 我的 CentOS 版本是 CentOS Linux release 7.2.1511 (Core)
- PHP 版本是 PHP 7.3.6 (cli)
- 我从 PHP
手动安装了所有必要的模块
我已经试过了
我已经做了很多研究:
我按照那个问题的答案说的,对我来说还是一样。
我也确实按照其他 post:
正确设置了权限
还有这些
https://www.ionos.com/community/server-cloud-infrastructure/apache/how-to-fix-http-error-code-500-internal-server-error/
还有我在其他网站上阅读的更多文章。
这些是项目文件夹的权限:
drwxr-xr-x 13 apache apache 4096 May 31 05:23 laravel
对于存储:
drwxr-xr-x 5 apache apache 4096 May 31 04:44 storage
尝试生成密钥并得到这个:
[root@server laravel]# php artisan key:generate
ErrorException : file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory
at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
> 96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1 file_get_contents("/var/www/laravel/.env")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
2 Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:soTdeaCmsY1ELnpJLCcYkBJjY6SWiLYwY+Mvoxl9wOw=")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:80
Please use the argument -v to see more details.
[root@server laravel]#
您是否从 var/www/laravel/.env.example
文件创建了 var/www/laravel/.env
文件?
所以,我修复了它正确配置 .env
并生成了 @mdexp 提到的密钥。
因此,对于遇到问题的每个人,请检查我问题中的链接并正确设置所有内容
您似乎错过了 Laravel 环境配置文件。
在全新的 Laravel 安装中,您应该有一个 .env.example 文件。复制那个并将其重命名为 .env 然后 运行 php artisan key:generate
命令。
正如标题所说,我在 CentOS 7 上有一个 VPS 运行,我安装了 Laravel、PHP 7.3 的所有必需品,但它仍然提供我 'Server Error 500'。
请注意,这是 Laravel 与 composer 的全新安装。
- 我的 CentOS 版本是 CentOS Linux release 7.2.1511 (Core)
- PHP 版本是 PHP 7.3.6 (cli)
- 我从 PHP 手动安装了所有必要的模块
我已经试过了
我已经做了很多研究:
我按照那个问题的答案说的,对我来说还是一样。
我也确实按照其他 post:
正确设置了权限
还有这些
https://www.ionos.com/community/server-cloud-infrastructure/apache/how-to-fix-http-error-code-500-internal-server-error/
还有我在其他网站上阅读的更多文章。
这些是项目文件夹的权限:
drwxr-xr-x 13 apache apache 4096 May 31 05:23 laravel
对于存储:
drwxr-xr-x 5 apache apache 4096 May 31 04:44 storage
尝试生成密钥并得到这个:
[root@server laravel]# php artisan key:generate
ErrorException : file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory
at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
> 96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1 file_get_contents("/var/www/laravel/.env")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
2 Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:soTdeaCmsY1ELnpJLCcYkBJjY6SWiLYwY+Mvoxl9wOw=")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:80
Please use the argument -v to see more details.
[root@server laravel]#
您是否从 var/www/laravel/.env.example
文件创建了 var/www/laravel/.env
文件?
所以,我修复了它正确配置 .env
并生成了 @mdexp 提到的密钥。
因此,对于遇到问题的每个人,请检查我问题中的链接并正确设置所有内容
您似乎错过了 Laravel 环境配置文件。
在全新的 Laravel 安装中,您应该有一个 .env.example 文件。复制那个并将其重命名为 .env 然后 运行 php artisan key:generate
命令。