もともと別のレンタルサーバーで稼働していた Laravel のプロジェクトをさくら VPS に移動させる事にしました。
その際、Laravel を稼働させるためにキージェネレートしたのですが以下のようなパーミッション拒否されます。
エラー内容:
ErrorException
file_get_contents(/var/www/html/simple/.env): Failed to open stream: Permission denied
at 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▕ /**
+16 vendor frames
17 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
[m2@tk2-209-14402 simple]$
以下 chmd
コマンドで .env ファイルの権限を apache を有効にしました。
/bootstarap/cache/config.php を config.php.old にして無効化するなども試しましたがダメでした。
sudo chmod 722 .env
権限も以下の通り権限が付与されています。
-rwx-w--w- 1 apache apache 821 Jun 4 03:50 .env
何か考えられる原因があればご教授お願いします。私事ですが、VPS のセットアップだけでかなり苦労したのでここで何かをインストールし直すとかはしたくないです。
こんな事もできないのは向いてないのかもしれませんが、ここでやめたくはありません。
実行環境:
CentOS 8