前提
- VagratでCentOS6 + Apacheの環境を構築
- 共有フォルダをDocumentRootに指定したい
VagrantFile
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos/6" config.vm.network "private_network", ip: "192.168.33.10" if Vagrant.has_plugin?("vagrant-vbguest") config.vbguest.auto_update = false end config.vm.synced_folder "./src", "/home/vagrant/workspace", :owner => "apache", :group => "apache", :mount_options => ["dmode=775,fmode=775"] end
httpd.conf、抜粋
<VirtualHost *:80> ServerName test.localhost.com DocumentRoot /home/vagrant/workspace/test <Directory "/home/vagrant/workspace/test"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /home/vagrant/workspace/logs/test-apache-error.log CustomLog /home/vagrant/workspace/logs/test-apache-access.log combined </VirtualHost>
自分のPCの/etc/hostsで以下を定義
192.168.33.10 test.localhost.com
発生している問題
ブラウザで http://test.localhost.com/ にアクセスした際、403エラーが発生する。
試したこと
- SELINUX を無効にする
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
[vagrant@localhost ~]$ getenforce Disabled
- フォルダのownerをapacheに変更
[vagrant@localhost test]$ pwd /home/vagrant/workspace/test [vagrant@localhost test]$ ls -l 合計 4 -rwxrwxr-x 1 apache apache 12 2月 23 05:09 2020 index.html [vagrant@localhost test]$ ls -ld drwxrwxr-x 1 apache apache 96 2月 23 05:09 2020 .
以前の質問やGoogle検索の結果ではselinuxやフォルダーの権限設定で解決されていることが多く、
403エラーを解決する方法が他に思いつきません。何かご助言でいただければ幸いです。
追記
/home/vagrantのパーミッションは以下のようにしています。
[vagrant@localhost ~]$ pwd /home/vagrant [vagrant@localhost ~]$ ls -ld drwxr-xr-x. 4 vagrant vagrant 4096 2月 23 04:36 2020
回答2件
あなたの回答
tips
プレビュー