LoginSignup
0
0

More than 5 years have passed since last update.

CentOS7.4+Apache2.4+Laravel5.5メモ

Posted at

Vagrant を使用する。synced_folder でドキュメントルートを設定する場合、httpd はスタートしていない場合があった。自動的に再起動するスクリプトを設定しておく。

zsh
vagrant init bento/centos-7.4
vi Vagrantfile
Vagrantfile
+   config.vm.network "private_network", ip: "192.168.33.10"
+   config.vm.synced_folder "./code", "/var/www/html/code", mount_options: ['dmode=777','fmode=777']

+  config.vm.provision "shell", run: "always", inline: <<-SHELL
+      sudo systemctl restart httpd.service
+  SHELL

Laravel では mod_rewrite や public/.htaccess などを使用するため AllowOverride の設定変更が必要。

/etc/httpd/conf/httpd.conf
# Further relax access to the default document root:
-<Directory "/var/www/html">
+<Directory "/var/www/html/code/public">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
-    AllowOverride None
+    AllowOverride All

ドキュメントルートを調整

-DocumentRoot "/var/www/html"
+DocumentRoot "/var/www/html/code/public"
...
# Further relax access to the default document root:
-<Directory "/var/www/html">
+<Directory "/var/www/html/code/public">

timezone を変更していないと migration ファイルなどのタイムスタンプがずれる場合がある。

-    'timezone' => 'UTC',
+    'timezone' => 'Asia/Tokyo',

debugbar を追加。

composer require barryvdh/laravel-debugbar --dev

mod_rewrite がうまく動いていないと以下のようなエラーがでる。

スクリーンショット 2018-05-26 11.45.34.jpg

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