0
0

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 1 year has passed since last update.

Laravelでpublicに置いた.htmlにアクセスできなかった時の対処

Posted at

だいぶ前にvagrantで作った環境でLaravelのpublicディレクトリにファイルを置いてアクセスしようとすると、.php や .txt なら普通にアクセスできるのだが、.htmlファイルだけ403 NotFound になった。それを解決した時のメモ。

環境

たぶん Vagrant Cloud からダウンロードしてきたBOX。/etc/os-release/etc/system-release には Amazon Linux 2 とある。
PHPのバージョンは 8.1。
Laravelのバージョンは9(9.48.0)。

php-fpmの場所

ググった情報によると問題を解決するには php-fpm の設定を変更して再起動する必要があるらしいが、php-fpm の設定ファイルが参考にしたページに記載されている場所にない。
自分の環境では以下にあった。

$ sudo find /etc -path '*php-fpm*'
/etc/logrotate.d/php81-php-fpm
/etc/systemd/system/multi-user.target.wants/php81-php-fpm.service
/etc/systemd/system/php81-php-fpm.service.d
/etc/opt/remi/php81/sysconfig/php-fpm
/etc/opt/remi/php81/php-fpm.conf
/etc/opt/remi/php81/php-fpm.d
/etc/opt/remi/php81/php-fpm.d/www.conf

/etc/opt/remi/php81/php-fpm.d/www.conf を編集して security.limit_extensions のコメントアウトを解除し末尾に .html を追記した。

php-fpmの再起動

sudo systemctl restart php-fpm ではダメだったので php-fpm のサービス名を探した。

$ sudo systemctl list-unit-files -t service | grep php-fpm
php81-php-fpm.service                         enabled

サービス名は php81-php-fpm だった。よく見たら先ほどの find の結果の中にあった。
ということで sudo systemctl restart php81-php-fpm で php-fpm を再起動したところ、Laravel の public にある .html ファイルにアクセスして200が返ってくるようになった。

参考ページ

CentOS8 + Apache2.4.37 + php7.2(php-fpm) で HTML ファイルの中で PHP を実行する
systemctlで有効・無効なサービス一覧を表示する | 晴耕雨読

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?