LoginSignup
11
10

More than 5 years have passed since last update.

vagrant でディレクトリを共有するとブラウザから192.168.33.10がForbiddenになる

Last updated at Posted at 2014-04-04

vagrantとvirtualboxで仮想開発環境を作ってプログラミグを勉強したいです。

とりあえず、両方のインストールと設定は終えました。

sudo yum -y install httpd

sudo /sbin/service httpd start (/sbinを付けないとエラーになる為、付けたら成功しました)

sudo /sbin/chkconfig httpd on

sudo /sbin/service iptables stop

sudo /sbin/service iptables off

ここまでで、httpdのインストールとファイヤーウォールをオフにしました。

vi vagrantfile

#config.vm.network "private_network", ip: "192.168.33.10" 部分のコメントアウトを外します。

vagrantをexitして

vagrant reload

vagrant ssh

cd /var/www/html

vi index.html (hello woldを作成)

google chormeで192.168.33.10を開くと hello world が表示されました。

ここまでは、特に間違っていないと思いますが、ココからが問題です。
ホームと共有されている/vagrantを/var/www/htmlとリンクさせます。

sudo rm -rf /var/www/html

sudo ln -fs /vagrant /var/www/html

これでホーム・/vagrant・/var/www/htmlのどこにファイルを作成しても全てに反映されるようになりました。
しかし、この状態でブラウザから192.168.33.10を開いてもForbiddenが出て次のようなメッセージがでます。

You don't have permission to access / on this server.

その下にはこれが。

Apache/2.2.3 (CentOS) Server at 192.168.33.10 Port 80

ホーム・/vagrant・/var/www/htmlの全てのディレクトリとindex.htmlのパーミッションをls -lで調べたところ
"drwx-r-x-r-x" か"-rwx-r--r--"となり読み込みは可能なはずです。

私の知識ではもうお手上げ状態です。どなたか、分かる方がいらっしゃいましたら教えてください!
これが分からないと勉強が先に進みません。。。
どうか、お願いいたします。

11
10
8

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
11
10