LoginSignup
1
0

More than 5 years have passed since last update.

[CentOS7]Laravel5がWebサーバ上で500を返してきた時に確認してほしいこと

Last updated at Posted at 2017-08-08

はじめに

CentOS7にてLaravel5.2を動かそうとしましたが,500 Internal Sever Errorが返されてしまいました.
それを解決した方法をメモがてら残しておきたいと思います.

以下は実行環境です

  • CentOS 7.3.1611
  • PHP 7.1.8
  • Laravel 5.2

本題

一つ一つ確認していきたいと思います.

1.インストールの要件を満たしているか?

公式に書いてある通りですが,Laravelを動作させるためにはいくつかのモジュールを読み込む必要があります(下記はLaravel5.2の場合).

- PHP >= 5.5.9
- OpenSSL PHP拡張
- PDO PHP拡張
- Mbstring PHP拡張
- Tokenizer PHP拡張

これらを読み込んでない方は読み込みましょう.

$ yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ yum -y install httpd php71 php71-php
$ yum install -y --enablerepo=remi-php71 php-mcrypt php-mbstring php-pdo php-mysqlnd php-tokenizer php-pear php-fpm php-devel php-xml

/etc/php.ini 編集も忘れずに!

2. .envファイルのミス

.envファイルにはDB系の設定を記入しますが,ここがマルチバイトでも500が返されます.

3. 権限エラー

私はズバリこれが原因でした.
Laravelは bootstrap/cache/ や storage/ に対して書き込みを行います.
なので,Laravelからの書き込み権限を与えてあげる必要があります.

$ chmod 777 -R [projectName]/bootstrap/cache
$ chmod 777 -R [projectName]/storage/

Laravelは権限にうるさいらしいので,エラーが出たらまずこの辺りを疑ってみるといいのかもしれません.
また,初めにプロジェクト自体を chmod 777 -R で設定してしまってから,徐々に権限を狭めていく形でもいいと思います.


以上,快適な開発生活を送りましょう!

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