CentOS6.5 vagrant 初期設定メモ

vagrantベアボーンを作ったあとの設定メモ。テスト用なのでセキュリティは適当。本来はprovisioningで自動化した方がいいのだが、とりあえず勉強を兼ねて手動で設定してみる。

ネットワーク設定

Vagrantfileでport fowardingとHost Only Networkを設定する。

config.vm.network "forwarded_port", guest: 80, host: 9999
config.vm.network "private_network", ip: "192.168.33.11"

シェルスクリプトでprovisioningする場合はVagrantfileに以下も追記。

config.vm.provision "shell", path: "provision.sh"

iptablesselinux の無効化

iptables

/etc/init.d/iptables stop
chkconfig iptables off 

selinux

setenforce 0
vi /etc/sysconfig/selinux
SELINUX=enforcing
   ↓
SELINUX=disabled 

Linuxのファイヤーウォール(iptables)とSELinuxを停止&無効化 - yummy-yummy

Proxyの設定

CentOS/RedHat/FedoraでProxyの設定をする (yum, wget, rpm 等) | OSCALOG

yum

vi /etc/yum.conf
proxy=http://proxy.mycompany.co.jp:8080/

wget

vi /etc/wgetrc
http_proxy=http://proxy.mycompany.co.jp:8080/

rpm

コマンド実行時にプロキシを指定する。

rpm --httpproxy proxy.mycompany.co.jp --httpport 8080 ~

rpmリポジトリの追加

mysql5.5をインストールするためにリポジトリを追加する。

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

CentOS6 に MySQL 5.5 をインストール | T.T.Soft Code Blog

ソフトウェアのインストール

mysqlphp-mysqlレポジトリにremiを指定する。

yum update -y
yum install wget -y
yum install httpd -y
yum install screen -y
yum install zsh -y
yum install php -y
yum install mysql-server --enablerepo=remi -y
yum install phpMyAdmin --enablerepo=remi -y
yum install php-mysql --enablerepo=remi

MySQL設定

vi /etc/my.cnf
character-set-server = utf8 #追加

/etc/rc.d/init.d/mysqld start
chkconfig mysqld on

mysql_secure_installation

データベースサーバー構築(MySQL) - CentOSで自宅サーバー構築

phpMyAdmin 設定

vi /etc/httpd/conf.d/phpMyAdmin.conf

# 23行目に追加
Allow from 192.168.33.

CentOS6.4にMySQLとphpMyadminをインストール | WinRoad徒然草

rc

.zshrc

# .zshrc

_MYPATH=$HOME/usr/bin
_SYSPATH=/usr/local/bin:/usr/X11R6/bin:/sbin:/bin:/usr/sbin:/usr/bin

case $CPUTYPE in
x86_64)
    _CPUPATH=/share/usr-x86_64/bin
    ;;
i686)
    _CPUPATH=/share/usr/bin
    ;;
esac

PATH=$_MYPATH:$_CPUPATH:$_SYSPATH
unset _MYPATH _CPUPATH _SYSPATH

PROMPT="[%m-(%~)] % "
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=$HOME/.zsh_history
WORDCHARS='*?_-.[]~&;!#$%^(){}<>'

export LANG=ja_JP.UTF-8
export EDITOR=emacsclient
export LS_COLORS=':no=00:fi=00:di=36:ln=35:pi=33:so=32:bd=34;46:cd=34;43:ex=31:'
export PERL5LIB=$HOME/usr/lib/perl
export CVSROOT=reed:/share/service/cvs
export CVS_RSH=ssh
export XMODIFIERS="@im=kinput2"

export TEXINPUTS=.:$HOME/TeX/inputs//:
export BIBINPUTS=.:$HOME/TeX/inputs//:
export BSTINPUTS=.:$HOME/TeX/inputs//:

# options
setopt auto_cd
setopt auto_param_slash
setopt auto_pushd
setopt auto_remove_slash
setopt extended_glob
setopt function_argzero
setopt ignore_eof
setopt list_types
setopt pushd_ignore_dups
setopt pushd_silent
setopt pushd_to_home
setopt sun_keyboard_hack
setopt print_eight_bit
setopt complete_in_word
setopt no_nomatch
setopt share_history
setopt extended_history
setopt nohup
setopt hist_ignore_dups
setopt hist_reduce_blanks

unsetopt promptcr

# aliases
alias ls='ls -F --color=tty'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias h='history'
alias -g L='| lv'
alias -g H='| head'
alias -g T='| tail'
alias -g W='| wc'
alias -g G='| grep'
alias gomi='rm -f *~'
alias cpan='perl -MCPAN -e shell'
alias j='juman -e2 -B'
alias jk='juman -e2 -B | knp'

# completion
autoload -U compinit
compinit

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}

# bindkey
bindkey "^[f" emacs-forward-word
bindkey "^[b" emacs-backward-word

autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[p" history-beginning-search-backward-end
bindkey "^[n" history-beginning-search-forward-end

autoload replace-string
zle -N replace-string
bindkey "^[%" replace-string

if [ "$EMACS" = t ]; then
    unsetopt zle
    stty -echo
    alias ls='ls -F --color'
fi

export http_proxy=http://proxy.mycompany.co.jp:8080/

.vimrc

set fileencoding=utf-8

"Vi 非互換モード
set nocompatible
filetype plugin indent on
syntax on

set tabstop=4
set shiftwidth=4

set number
set ruler

set title

set noexpandtab
set softtabstop=0
imap <c-j> <esc>

.screenrc

escape ^]]

startup_message off
hardstatus string "[screen %n%?: %t%?] %h"

defmonitor on
caption always "%{= wg} %-w%{=bu dr}%n %t%{-}%+w %= %{=b wb}%Y/%m/%d %{=b wm}%c"

defscrollback 100000