LoginSignup
2
6

More than 5 years have passed since last update.

Mac OSX Linux(CentOS) 環境メモ

Last updated at Posted at 2017-12-30

OSX Linux(CentOS) 環境メモ

MacBook上OSXのLinux(CentOS7)環境のメモを残します。
Vagrant/VirtulboxでCentOS7の環境を構築します。provisionerはansibleを使用します。
本エントリーの各ソフトウェアのバージョンを以下に示します。

Software version
Vagrant 2.2.4
Virtual Box 6.0.4
Centos 7.x

Vagrantの互換Virtual Boxバージョンは以下です。
https://www.vagrantup.com/docs/virtualbox/

homebrew/ansible install

Mac OSXのパッケージマネージャであるhomebrewを
以下のコマンドでインストールします。

# https://brew.sh/より
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew doctor
Your system is ready to brew.
$ 

brewコマンドで、Mac OSX側で必要なパッケージ(ruby,python,git)、他をインストールします。

$ brew install ruby
$ brew install python
$ brew install git
$ brew install ansible
...
$ brew list

PATHを設定します。

$ echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/opt/python/bin:$PATH"'  >> ~/.bash_profile
$ . ~/.bash_profile
$ which ruby
/usr/local/opt/ruby/bin/ruby
$ which python3
/usr/local/opt/python/bin/python3
$ 

Virtual Box install

Virtual Boxをインストールします。
以下よりダウンロードしてインストーラーに従いインストールします。(VirtualBox 6.0.4)
https://www.virtualbox.org/wiki/Downloads

または、brew caskでインストールします。

$ brew cask install virtualbox

インストールに失敗する場合は、Security & Privacyの設定で"Oracle America, Inc"を許可します。

Vagrant install

Vagrantをインストールします。以下手順に従います。(Vagrant 2.2.4)
https://www.vagrantup.com/intro/getting-started/install.html

Vagrantコマンドで、Guest OS(CentOS7)の起動・ログイン確認を行います。
https://www.vagrantup.com/intro/getting-started/project_setup.html

BOXは以下を使用します。
https://app.vagrantup.com/centos/boxes/7

$ mkdir ~/vagrant_getting_started
$ cd ~/vagrant_getting_started
$ vagrant init centos/7
$ vagrant up
...
$ vagrant ssh
$ exit
$ vagrant halt

Vagrantfileのprovision設定に、ansible_localを指定し、playbook.ymlを構成します。
それぞれのファイルを~/vagrant_getting_startedに配置します。
* Vagrantfile
* playbook.yml

それぞれのファイルのサンプルは以下になります。
https://github.com/keikmobile/vagrant_centos6

$ cd ~/vagrant_getting_started
$ vagrant up
$ vagrant provision
$ vagrant ssh

ログインして、Guest OSが期待通りに構成されていることを確認します。
確認にvagrant-serverspecを使用する場合、vagrant-serverspecをインストールします。

$ vagrant plugin install vagrant-serverspec

おまけ : Mac OSXでtmuxを使う準備

tmuxをインストールします。

$ brew install tmux

おまけ : Mac OSXでコードを読む準備

ack, globalをインストールします。

$ brew install ack
$ brew install global

ack

grobal

以下を参考にvimのgrobal設定をします。キーバインドはお好みで設定します。
https://www.gnu.org/software/global/globaldoc_toc.html#Vim-editor

$ mkdir -p ~/.vim/plugin
$ cp /usr/local/share/gtags/gtags.vim $HOME/.vim/plugin
$ echo 'map <C-h> :Gtags -f %<CR>' >> ~/.vimrc
$ echo 'map <C-j> :GtagsCursor<CR>' >> ~/.vimrc
$ echo 'map <C-n> :cn<CR>' >> ~/.vimrc
$ echo 'map <C-p> :cp<CR>' >> ~/.vimrc
$ cp /usr/local/share/gtags/gtags.conf $HOME/.globalrc

pygments

$ pip install pygments

おまけ : user local ruby/python install

ユーザローカルにRubyをインストールします。xbuildを使わせて頂いています。
xbuildの詳細は"https://github.com/tagomoris/xbuild"

$ mkdir ~/local
$ cd ~/local
$ git clone https://github.com/tagomoris/xbuild.git
$ xbuild/ruby-install 2.4.2 ~/local/ruby-2.4.2
$ ln -sf ~/local/ruby-2.4.2 ~/local/ruby
$ xbuild/ruby-install 2.7.14 ~/local/python-2.7.14
$ ln -sf ~/local/python-2.7.14 ~/local/python
$ echo 'PATH=~/local/ruby/bin:~/local/python/$PATH' >> ~/.bash_profile 
$ . ~/.bash_profile 
$ ruby -v

おまけ : tmuxinator インストール

$ gem install tmuxinator
$ tmuxinator new ssh_sample
$ tmuxinator start ssh_sample
name: ssh_sample
root: ~/
windows:
 - server1: ssh user@server1
 - server2: ssh user@server1
 - server3: ssh user@server1

おまけ : tmux-xpanes インストール

$ brew install tmux-xpanes

host1,2,3,4にssh。

$ xpanes -c "ssh user@{}" host{1..4}

おまけ : gitbucket インストール

$ brew install gitbucket
...
$ brew services start gitbucket
...
$ brew services list

ブラウザでhttp://127.0.0.1:8080にアクセス。

おまけ : asciidoctor インストール

$ brew install asciidoctor
$ asciidoctor -v

おまけ : redpen インストール

$ brew install redpen
$ redpen -v
$ vi /usr/local/Cellar/redpen/1.10.1/libexec/bin/redpen-server

Redpen-serverのport変更。(Option)

# Port number for RedPen server
REDPEN_PORT=9080

ブラウザで "http://127.0.0.1:9080" にアクセスし、任意の設定でexport押下。redpen-conf.xmlのダウンロード。

$ redpen-server start

target.txtにredpenを実行。

$ redpen -c redpen-conf.xml target.txt 

更新履歴

  • 2019/03/17 CentOS7に変更
2
6
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
2
6