CentOS5をインストールしてそれからのちょい設定をまとめてみた
相変わらずインストールするのが好きなid:kopugなわけで、Ubuntuに引き続きCentOS5をインストールしたので、
インストール後の基本設定をまとめてみた。
(1) CentOSのインストール。チョイスしたアプリは"エディタ"と"開発環境"のみ。
(2) 一般ユーザの作成
# adduser kopug # passwd kopug
(3) kopugを管理者とし、kopug以外rootにsuできないようにする
# usermod -G wheel kopug # vi /etc/pam.d/su
下記のコメントを解除し、有効化する
auth required /lib/security/$ISA/pam_wheel.so use_uid
# echo "SU_WHEEL_ONLY yes" >> /etc/login.defs
(4) wheelグループの人はsudoを使えるようにしておく
# visudo
下記のコメントを解除し、有効化する
## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL
(5) yumの設定をちょいちょいと
# yum -y install yum-fastestmirror <- 最適のミラーサーバを自動で探す # yum -y update <- インストール済みのパッケージを最新版に # service yum-updatesd stop <- パッケージの自動更新を止める # chkconfig yum-updatesd off <- サーバ再起動時に上のが立ち上がらないように。
(6) SELinuxを使いこなせないので無効化
# setenforce 0 # getenforce Permissive <- これが出てれば無効化されたってこと。Enforcingと表示されている場合は有効になっているので注意
起動時にSELiunxを無効化
# vi /etc/sysconfig/selinux
SELINUX=disabled <- enforcing となっているので変更する
(7) 自動でサーバの時間を合わせる(NTP)
# yum -y install ntp # mv /etc/ntp.conf /etc/ntp.conf.org # echo "driftfile /var/lib/ntp/drift" > /etc/ntp.conf # echo "server ntp.dnsbalance.ring.gr.jp" >> /etc/ntp.conf # ntpdate ntp.dnsbalance.ring.gr.jp # service ntpd start # chkconfig ntpd on
(8) SSHの設定
# vi /etc/ssh/sshd_config
Protocol 2 <- SSH2のみ接続させる PermitRootLogin no <- rootでログインする必要はない PermitEmptyPasswords no <- パスワード無しをNG PasswordAuthentication no <- パスワードじゃなく鍵を使いたい場合はこれを設定
# service sshd restart
(9) TCP Wrapperでアクセス制限
# echo "ALL:ALL" >> /etc/hosts.deny <- 全て禁止に # echo "sshd:127.0.0.1" >> /etc/hosts.deny <- 自分自身と # echo "sshd:192.168.1." >> /etc/hosts.allow <- LAN内のマシンはsshで接続OK
(10) ネットワーク設定を変更したい場合は以下のファイルを。(Redhat系OS共通)
windowsにもあるのと同じhostsファイル
/etc/hosts
DNSサーバの場所を指定するのであれば
/etc/resolv.conf
サーバのホスト名の設定等。
/etc/sysconfig/network
ネットワーク基本設定はこちらへ
/etc/sysconfig/network-scripts/ifcfg-eth0
ここから先は自分の好み。
(20) vimrcを用意
# vi ~/.vimrc
set autoindent "set textwidth=78 set backspace=indent,eol,start set tabstop=4 set expandtab set shiftwidth=4 set shiftround set matchpairs+=<:> set foldmethod=marker set mouse=a set ttymouse=xterm2
(21) screenのインストール
# yum -y install screen # echo 'hardstatus alwayslastline "%H %`%-w%{=b bw}%n %t%{-}%+w"' > ~/.screenrc
(22) プロンプトのフォーマットを変更
$ echo "export PS1='[\u@\h:\w]$ '" >> ~/.bash_profile # echo "export PS1='[\u@\h:\w]# '" >> ~/.bash_profile
(23) rootでもvimを使いたい。
# echo "alias vi='vim'" >> ~/.bash_profile
後は任意のユーザのホームディレクトリにコピーしたり、/etc/skel にコピーして新しく作ったユーザのホームディレクトリにコピーされるようにしておくとか。
(24) yum に RPMforge リポジトリを追加する
# wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm # rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm # vi /etc/yum.repos.d/rpmforge.repo enabled = 0 <- 変更 # wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt # rpm --import RPM-GPG-KEY.dag.txt