Ubuntu 10.04 (Lucid Lynx) server editionの初期設定メモ。
- このメモの目的と内容
- kvm仮想マシンを各種サーバとして使うための自分用メモ
- インストールにはubuntu-10.04-server-i386を使用
- インストールするマシンとして、192MBのメモリと10GBのストレージ(qcow2/virtio)2台が接続されている仮想マシンを使用
最新バージョンでの初期設定内容はUbuntuにて掲載しています。
仮想マシン設定の変更
インストールを始める前に、仮想マシンのキーマップ設定を修正しておく。 /etc/libvirt/qemu/にある各設定ファイル内の/domain/devices/graphics/@keymapの値をen-usからjaに変える。
<graphics type='vnc' port='-1' autoport='yes' keymap='ja'/>
インストール手順
ブート画面
- F2 Language: [English]を選択
- F3 Keymap: [Japan]を選択
- [Install Ubuntu Server]を選択
Choose language
- Choose a language: [English - English]を選択
- Choose a country, territory or area: [other] → [Asia] → [Japan]の順に選択
Ubuntu installer main menu
- Keyborard model: [Do not configure keyboard; keep kernel keymap]を選択
Configure the network
- Network configuration method: [Configure network manually]を選択
- (以下ダイアログに従ってIPアドレス等を入力)
Configure the clock
- Is this time zone correct?: 自動的に選択されたタイムゾーンでよければ<Yes>を選択
Partition disks
- Partitioning method: [Manual]を選択
- 以下のように設定
Virtual disk1 vda 10GB #1 primary 512M ext4 /boot Mount option: defaults #5 logical (max) ext4 /usr Mount option: defaults Virtual disk2 vdb 10GB #1 primary (max) ext4 / Mount option: defaults #5 logical 512M swap - - [Finish partitioning and write changes to disk]を選択
- Write the changes to disks?: パーティションのフォーマットを確認して<Yes>を選択
Installing the base system
- (インストールが終わるまで待つ)
Set up users and passwords
- (ダイアログに従ってユーザ名・パスワード等を入力)
- Encrypt your home directory?: <No>を選択
Configure the package manager
- HTTP proxy information: 空欄のままもしくは必要に応じて適切なURLを入力
Select and install software
- How do you want to manage upgrades on this system? [No automatic updates]を選択
Software selection
- (サーバの構成に従って適当なものを選択)
- [Mail server]の設定例
- Postfix Configuration
- General type of mail configuration: [Satellite system]を選択
- System mail name: 適当な名前を入力
- SMTP relay host: メール配送に用いるSMTPサーバのホスト名を入力
- Postfix Configuration
Configuring grub-pc
- Install the GRUB boot loader to the master boot record?: <Yes>を選択
Configuring console-setup
- Installation complete: ディスクを取り出して<Continue>を選択
- 再起動
インストール後の設定
キーボードの設定
sudo apt-get install console-data
インストール中に設定画面(Configuring console-data)が現れる。 この画面で、
- Policy for handling keymaps: [Select keymap from full list]を選択
- Keymap: [pc / qwerty / Japanese / Standard / Standard]を選択
キーマップが正しくないなど、再設定が必要な場合は、
sudo dpkg-reconfigure console-data
で再設定する。
デフォルトのエディタ変更
好みのエディタに変更する。
$ sudo update-alternatives --config editor There are 4 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ * 0 /bin/nano 40 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode 3 /usr/bin/vim.basic 30 manual mode 4 /usr/bin/vim.tiny 10 manual mode Press enter to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode.
~/.vimrc
以下の内容で作成。
set encoding=utf-8
set fileencoding=utf-8
"set fileencodings=iso-2022-jp,cp932,shift-jis,euc-jp,utf-8,utf-16,ucs-2le,ucs-2,japan
set fileencodings=utf-8,utf-16,japan
set backspace=2
set tabstop=2
set shiftwidth=4
set expandtab
highlight tabs ctermbg=green guibg=green
set list
set number
set ruler
set smartindent
~/.bashrc
以下の内容を追記。
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
PS1='\!> \[\033[0;33m\]\u\[\033[m\]@\[\033[0;36m\]\h\[\033[m\] [\[\033[0;32m\]\t\[\033[m\] \w]\$ '
case $TERM in
kterm|xterm|cygwin)
TITLEBAR="\u@\h:\w"
PS1="\[\033]0;${TITLEBAR}\007\]${PS1}"
;;
esac
/etc/aliases
root宛のメール送信先を変更する。
# 以下を追記
root: root@<mail-server>
変更を反映する。
sudo newaliases
GRUB 2
起動時にGRUB 2のメニュー画面が表示されるようにする。 GRUB_HIDDEN_TIMEOUTをコメントアウトし、GRUB_TIMEOUTにタイムアウト秒数を指定する。
#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=5
また、ブートプロセスをテキストで表示させるために、GRUB_CMDLINE_LINUX_DEFAULTからsplashを削除する。
GRUB_CMDLINE_LINUX_DEFAULT=""
変更内容を反映する。
$ sudo update-grub2 Generating grub.cfg ... Found linux image: /boot/vmlinuz-2.6.32-21-generic-pae Found initrd image: /boot/initrd.img-2.6.32-21-generic-pae Found memtest86+ image: /memtest86+.bin done
パッケージのインストールと設定
xineted + telnetd
sudo apt-get install xinetd telnetd
以下を追記。
in.telnetd : 127.0.0.1 192.168.0.0/24
ALL : ALL
/etc/xinetd.d/telnetを作成。
service telnet
{
disable = no
flags = REUSE
socket_type = stream
user = telnetd
wait = no
server = /usr/sbin/in.telnetd
server_args = -h
only_from = 192.168.0.0/24 127.0.0.1
log_on_failure += USERID
}
xinetdを再起動。
sudo service xinetd restart
NFS
sudo apt-get install nfs-common
マウントポイントを作成。
sudo mkdir -p /srv/nfs
/etc/fstabを編集後、マウントする。
sudo vi /etc/fstab
sudo mount -a
マウントされたかどうか確認する。
cat /etc/mtab
ls -l /srv/nfs
NTP
sudo apt-get install ntp
適当なNTPサーバを設定、再起動。
sudo vi /etc/ntp.conf
sudo service ntp restart
Logwatch
sudo apt-get install logwatch
Munin
sudo apt-get install munin-node
/etc/munin/pluginsから必要なプラグインだけを残す。
sudo unlink xxx
sudo ln -s /usr/share/munin/plugins/xxx
データを収集するマシンのみからのアクセスを許可するように変更する。
allow ^192\.168\.0\.10$
munin-nodeを再起動。
sudo service munin-node restart
データを収集するマシンからtelnetで接続できるか試す。
$ telnet server1.example.com 4949 Trying 192.168.0.20... Connected to server1.example.com. Escape character is '^]'. # munin node at server1.example.com nodes server1.example.com . quit Connection closed by foreign host.
AWStats
sudo apt-get install awstats
/etc/awstats以下の設定ファイルを編集後、ログが読み込まれデータが正しく収集されるかテストする。
sudo -u www-data /usr/share/doc/awstats/examples/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl -confdir="/etc/awstats/"
ls /var/lib/awstats
cronの設定を作成。
0,30 * * * * www-data /usr/share/doc/awstats/examples/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl -confdir="/etc/awstats/" > /dev/null
必要に応じてHTTPサーバの設定を更新したのち、「http://サーバ名/awstats/awstats.pl?config=設定ファイル名」を開いて収集されたデータが表示されるか確かめる。