LoginSignup
3
0

More than 5 years have passed since last update.

Vagrantでlocalが全て同じサイトに飛んでしまう時の解決法

Posted at

Vagrantでlocalが全て同じサイト(ディレクトリ)に飛んでしまう時の解決法。

環境

  • MacOS
  • vagrant
  • vagrantのboxはubuntu17
  • vagrant内ではapacheが動作

現状

local.hogehoge.comでディレクトリを作成すると自動でlocal.hogehoge.comでアクセスできるようにVagrantFileを作ったのにも関わらず、ある日新しくディレクトリを追加するとlocalが全てそのディレクトリに繋がってしまうようになった。

  • local.hogehoge.com
  • local.hugahuga.com
  • local.exsample.com ← New!

解決法

/etc/apache2/sites-enabled/exsample.conf
<VirtualHost *:80>
    ServerName local.exsample.com
    DocumentRoot /share/local.exsample.com/htdocs
    <Directory "/share/local.exsample.com/htdocs">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

新しい環境のためにvagrant内のapacheに設定を追加していた。

$ ls

exsample.conf shared-virtual-hosts.conf

名前の順番(優先順位)の問題でshared-virtual-hosts.confより先に読み込まれている。

$ mv shared-virtual-hosts.conf 001-shared-virtual-hosts.conf

そのためshared-virtual-hosts.confが先に読み込まれるようにrenameする。

$ ls

001-shared-virtual-hosts.conf exsample.conf

これでひとまずは解決。

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