在 Windows 上使用 Laravel 5.7 出现 500 服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53915463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:13:49  来源:igfitidea点击:

Getting 500 server error with Laravel 5.7 on Windows

phplaravellaravel-5.7http-status-code-500

提问by domanskyi

I have cloned repo from git, and made composer install.

我已经从 git 克隆了 repo,并制作了composer install.

Then I am starting a server, but every time I get 500 server error.

然后我启动了一个服务器,但是每次我收到500 server error

Also, I tried to create a new project with composer create-project --prefer-dist laravel/laravel blogand this project works fine.

此外,我尝试创建一个新项目,composer create-project --prefer-dist laravel/laravel blog并且该项目运行良好。

In my error log i got an error like:

在我的错误日志中,我收到如下错误:

production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\OSPanel\domains\contact-fw-domanskyi\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:44) [stacktrace]

production.ERROR: 未指定应用程序加密密钥。{"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\OSPanel\domains\contact-fw-domanskyi\vendor\laravel\framework\src\Illuminate\Encryption \EncryptionServiceProvider.php:44) [堆栈跟踪]

回答by Udhav Sarvaiya

Answer based on your comment under in your question:

根据您在问题下的评论回答:

RuntimeException No application encryption key has been specified.

RuntimeException 未指定应用程序加密密钥。

set a value for the APP_KEYvariable.

APP_KEY变量设置一个值。

At the command line, the following Artisan command to generate a key:

在命令行中,使用以下 Artisan 命令生成密钥:

php artisan key:generate

This will generate a random key, you must restart the serverand you should no longer see the error message.

这将生成一个随机密钥,您必须重新启动服务器,您应该不会再看到错误消息。

回答by Anand Mainali

When you clone the git repo you must follow these steps to run the project:

克隆 git repo 时,您必须按照以下步骤运行项目:

  1. Create a Database locally
  2. Rename .env.examplefile to .envinside your project root and fill the database information. (windows won't let you do it, so you have to open your console cd your project root directory and run mv .env.example .env)
  3. Open the console and cd your project root directory
  4. Run composer install
  5. Run php artisan key:generate
  6. Run php artisan migrate
  7. Run php artisan db:seedto run seeders, if any.
  8. Run php artisan serve
  1. 在本地创建数据库
  2. 在项目根目录中将 .env.example文件重命名为.env并填写数据库信息。(windows 不会让你这样做,所以你必须打开你的控制台 cd 你的项目根目录并运行mv .env.example .env
  3. 打开控制台并cd你的项目根目录
  4. composer install
  5. php artisan key:generate
  6. php artisan migrate
  7. 运行php artisan db:seed以运行播种机(如果有)。
  8. php artisan serve

Now, your project will run. Good Luck!!

现在,您的项目将运行。祝你好运!!

回答by domanskyi

I just missed .envfile.

我只是错过了.env文件。

I have created new and generated a new key using php artisan key:generate

我创建了新的并使用生成了一个新的密钥php artisan key:generate