94
70

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

No application encryption key has been specified.となったときの対応方法

Last updated at Posted at 2019-05-08

事象 : Laravelプロジェクトでhttp://127.0.0.1:8000/にアクセスしたらエラーになった

スクリーンショット 2019-05-08 22.37.49.png

原因 : encryption keyが未設定だから

参考 : [Laravel]エラー"No application encryption key has been specified."が出るとき - akamist blog
エラーになったときの.env.env.exsampleをコピーしただけの状態だった

.env
APP_NAME=Laravel
APP_ENV=local
# ↓encryption keyが未設定の状態
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
# 省略

対応 : encryption keyを設定する

# encryption keyをartisanコマンドで生成する
$ php artisan key:generate
Application key set successfully.

# .envに自動で追記される
$ cat .env | grep ^APP_
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxx/xxxxxxxx/xxxxx=
APP_DEBUG=true
APP_URL=http://localhost

# 設定ファイルのキャッシュを再作成する
$ php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!

エラーが解消された

スクリーンショット 2019-05-08 22.54.38.png

94
70
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
94
70

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?