0
0

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.

MacOSでの、ローカル開発環境の追加

Posted at

前提

Vagrantで仮想環境を複数用意する時のメモ

・VirtualBox インストール済
・Cyberduck インストール済

ディレクトリの整理

Home>MyVagrant のフォルダ内に、
・MyCentOS
・MyprojectA
というフォルダを作って、それぞれにサーバーを構築する。
今回は、MyCentOSは元々あるものとして、MyprojectAというフォルダを作成する。
MyprojectAフォルダを作成後、そこで下記コマンドを実行。

コマンド入力

仮想マシン設定用のVagrantfileを作る

vagrant init bento/centos-6.8

Vagrantfileを編集して仮想マシンのIPアドレスを192.168.33.11にする

sed -i '' -e 's/# config.vm.network "private_network", ip: "192.168.33.11"/config.vm.network "private_network", ip: "192.168.33.11"/' Vagrantfile

vagrant reload

(エラーを履く場合、IPアドレスの設定かも。.vagrantフォルダの、Vagrantfileに、以下の行のIPを書き換える。)

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

(複数環境が原因でエラーを吐いた場合、このタイミングでプラグインをインストールしておく)

vagrant plugin install vagrant-vbguest

仮想マシンを起動する(裏でVirtualBoxが動く)

vagrant up

仮想マシンの状態を確認する

vagrant status

仮想マシンにログインし、IPアドレスを確かめる

vagrant ssh
ip a

OSを最新状態にアップデート(時間かかります)

sudo yum -y update

スクリプトを入手するためのgitをインストール

sudo yum -y install git

gitを使ってアプリケーション設定用のスクリプトをダウンロード

git clone https://github.com/dotinstallres/centos6.git

centos6フォルダができるのでそちらに移動

cd centos6

スクリプトを実行(時間かかります)

./run.sh

もろもろの設定を反映

exec $SHELL -l

Cyberduckの接続

Cyberduckを起動し、新規接続をクリックして以下を設定して接続。
・プロトコル:SFTP
・サーバ:192.168.33.11
・ユーザー名:vagrant
・パスワード:vagrant
起動後、ブックマーク に登録(MyprojectA)

bash_profileの様子

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?