LoginSignup
17
19

More than 5 years have passed since last update.

VagrantでCentOS7をhttpd/mysql/php でとりあえず動かしてホストから繋ぐまで、と思ってたらrubyとか入れている(WIP)

Last updated at Posted at 2015-03-22

Vagrantのインストールや起動など

http://qiita.com/inouet/items/b36638adc2b5772db457
このあたりとかを感謝しつつ見てやると初期設定はできる。

今回addしたのは下記のCentOS7box

vagrant box add mybox https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box

vagrant up するところで何か書いてある。

vagrant up
Failed to mount folders in Linux guest. This is usually beacuse
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group apache | cut -d: -f3`,dmode=777,fmode=777 /vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=777,fmode=777 /vagrant /vagrant

http://qiita.com/osamu1203/items/10e19c74c912d303ca0b
をありがたく見て、

vagrant ssh
sudo /etc/init.d/vboxadd setup

うまくいった様子だったら

vagrant reload

これでとりあえずミニマム起動

yum install からサービス起動

とりあえず仮想環境にガサガサ入れる。大丈夫。php-mbstringとか必要なら入れて。

sudo yum install httpd php php-mysql wget

httpd入れたので接続したいがfirewallのせいで出来ないのでオフ。二度と起動させない。

sudo systemctl stop firewalld
sudo systemctl disable firewalld

そしてhttpdは必ず起動させておく

sudo systemctl start httpd
sudo systemctl enable firewalld

ホスト側、Vagrantfileを修正。下記のコメントを外す。

config.vm.network "private_network", ip: "192.168.33.10"

vagrant reload

多分これでホストからWEBを見ることが出来るようになった(はず)。なので下記にホストのプラウザからアクセスしてみる。うまくいけばデフォルトの表示がされるッ。

http://192.168.33.10

MySQLのインストール

MariaDBはいらないので下記を見てMySQLを入れた。

sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
sudo yum -y install mysql mysql-devel mysql-server mysql-utilities
sudo service mysqld start
sudo systemctl enable mysqld

これでいつでも起動されるはず。

ホストとゲストのファイル共有

Vagrantfileを修正。[ホストのティレクトリ]が/vagrantとして公開される。

  config.vm.synced_folder "[ホストのディレクトリ]", "/vagrant"

大体以上。このVMをバックアップ取って、弄くり倒せる仮想マシンの完成。

ゲストからホストのIPを得る

http://qiita.com/ms2sato/items/a53ce0f48f08cfb839b8
とかどうぞ。

ruby のインストールとか

http://qiita.com/youcune/items/a5cc93313641b69b62f8
などを感謝しつつ利用する。

自分のところは rootの環境変数がうまく入らなかったので(本当はsudoでやりたいんだけど…)

export RBENV_ROOT="/usr/local/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"

/root/.bash_profile の最後にも追加してある。

17
19
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
17
19