0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Laravel 画像の`403 forbidden` エラーの修正手順

Posted at

Laravel 画像の403 forbidden エラーの修正手順

スクリーンショット 2025-03-13 17.18.18.png

上の画像のように画像を入力フォームに入れたが、表示されない時があります。

スクリーンショット 2025-03-13 17.21.55.png

このように入力した画像へのurlを見てみると403 forbiddenと表示られてしまいます。

1. コンテナ内に入る

まず以下のコードを実行してコンテナ内に入ります。

./vendor/bin/sail shell

2. public/storage のシンボリックリンクを作成

Laravelでは、public/storage は storage/app/public にリンクされている必要があります。
以下のコマンドを実行して、シンボリックリンクを作成してください。

php artisan storage:link

スクリーンショット 2025-03-13 17.28.14.png


3. パーミッションの設定

以下のコマンドで、適切なパーミッションを設定します。

chown -R sail:sail storage storage
chmod -R 775 storage storage
chown -R sail:sail storage public/storage
chmod -R 775 storage public/storage

5. 確認

sail down
sail up -d

上のコードを実行した後もう一度サイトを見ると、、、スクリーンショット 2025-03-13 17.37.46.png

これで public/storage のエラーが解決したことを確認できました。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?