1
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrantでLAMP環境構築(バーチャルホスト)

Last updated at Posted at 2017-08-07

#vagrant vhostの設定

ターミナル
#プラグインをインストール
$ vagrant plugin install vagrant-hostsupdater
$ vagrant plugin list

vi Vagrantfile
# 好きなホスト名を入れます。
config.vm.hostname = "localhost"
# 好きなバーチャルホスト名を入れます。
config.hostsupdater.aliases = ["vagrant.test", "vagrant.test2"]

Macの場合、/etc/hostsが自動的に書き換わる。
/private/etc/hostsとシンボリックリンクされ、vagrant haltで自動的に破棄されるようです。

ゲストマシンのhttpd.confを設定する

Centos
vi /etc/httpd/conf/httpd.conf

# 好きなサーバーネームを入れます。
ServerName vagrant

#コメントを外す
NameVirtualHost *:80

# ServerNameは、Vagrantfileのバーチャルホスト名に合わせます
<VirtualHost *:80>
DocumentRoot "/var/www/html/test"
ServerName vagrant.test
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/var/www/html/test2"
ServerName vagrant.test2
</VirtualHost>
Centos
#httpd.conf文法チェック
apachectl configtest
#apache再起動
service httpd restart
1
8
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
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?