MacにVagrantを用いた、Linux(CentOS7.0)仮想マシンのセットアップ、CentOS7.0のAppach、ファイアウォールの設定メモです。
1. Vagrantの導入
Macの場合は、以下のリンクからダウンロードし、インストール
https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.dmg?_ga=2.87800600.167939265.1495594964-220527035.1491880955
公式サイト
http://www.vagrantup.com/
2. CentOS7.0のBOX(テンプレート)を追加
CentOS7.0x64のパッケージを追加する
$vagrant box add CentOS7.0 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
Boxのサイト(非公式)、ここには数多くのBOXが公開されている
http://www.vagrantbox.es/
※vagrant関連機能一覧
- box(テンプレート)の追加
$vagrant box add ボックスの名前 パッケージ
- box一覧
$vagrant box list
- box削除
$vagrant box remove ボックスの名前
- その他関連コマンドを確認
$vagrant box -h
3. CentOS7.0の仮想マシンを作成
新しいフォルダを作り、その中に仮想マシンを作成し、起動する
$mkdir ~/myOS/CentOS7.0
$cd ~/myOS/CentOS7.0
$vagrant init CentOS7.0
$vagrant up
※vagrant関連機能一覧
- boxを用いて、仮想マシンを作成
$vagrant init ボックスの名前
- 仮想マシンを起動
$vagrant up
4. 作成した仮想マシンに接続する
接続
$vagrant ssh
4. Webサーバーの設定(Apache)
Apacheをインストールする
$sudo yum -y install httpd
Apacheを起動し、常時起動にする
$sudo systemctl start httpd.service
$sudo systemctl enable httpd.service
ファイアウォールを切る(ローカルの場合のみ)
$sudo systemctl stop firewalld
$sudo systemctl disable firewalld
※関連機能一覧
- 特定サービスの状態を確認する
$sudo systemctl status サービス名
- 特定サービスを起動/停止する
$sudo systemctl start/stop サービス名
- 特定サービスの自動起動状態を確認する
$sudo systemctl is-enabled サービス名
- 特定サービス自動起動をon/offする
$sudo systemctl enable/disable サービス名