酢ろぐ!

カレーが嫌いなスマートフォンアプリプログラマのブログ。

さくらVPSの優待乗り換えキャンペーンに参加してみた

さくらVPSの乗り換えキャンペーンの事をすっかり忘れていました。

弊社では、2012年3月29日(木)に実施する「さくらのVPS」リニューアルに伴い、既に「さくらのVPS」をご利用中で、リニューアル後のプランにお乗り換えをご希望のお客様を対象に、下記の優遇施策を実施いたします。

http://vps.sakura.ad.jp/news/sakurainfo/newsentry.php?id=628

現在、旧VPSを運用している目的としては3つで、Redmine/Subversion/Wordpressです。軌道に乗せるまでのログを書けたら良いなと思います(飽きたら止めます)。

rootのパスワードを変更する

# passwd
Changing password for user root.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.

ユーザーを作成する

rootのままで作業するのは良くないので実際に触るユーザーを作成します。ここではu393というユーザーを作成することにします。

まずはユーザーu393の作成とパスワードの設定。

# useradd u393
# passwd u393
Changing password for user wada.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.

sudoを使う為、usermodコマンドを使用してグループwheelにu393を参加させる。きちんと設定が出来たかどうかをidコマンドを使って所属を調べる。10(wheel)となっていればOK。

# usermod -G wheel u393
# id u393
uid=500(u393) gid=500(u393) groups=500(u393),10(wheel)

次にグループwheelに所属するユーザーに対してsudoの利用を許可させます。visudoコマンドでsudoの設定ファイルを開くことが出来ます。

# visudo

割りと後ろの方にコメントアウトされている下記の設定があります。

## Allows people in group wheel to run all commands
# %wheel  ALL=(ALL)       ALL

コメントアウトを外して保存します。

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

ここで一旦ルートを抜けて、ユーザーu393でログインしなおします。

sudo用にコマンドにパスを通す

$ cd
$ ls -l -a
total 20
drwx------  2 u393 u393 4096 May  6 23:29 .
drwxr-xr-x. 3 root root 4096 May  6 23:29 ..
-rw-r--r--  1 u393 u393   18 Dec  2 23:27 .bash_logout
-rw-r--r--  1 u393 u393  176 Dec  2 23:27 .bash_profile
-rw-r--r--  1 u393 u393  124 Dec  2 23:27 .bashrc

パスの定義のために.bash_profileに書かれている設定を変更する。

$ vi .bash_profile

.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

下記のように書き換えた。

# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=$PATH:/sbin
PATH=$PATH:/usr/sbin
PATH=$PATH:/usr/local/sbin

export PATH

sourceコマンドで変更を反映させる。

source ~/.bash_profile

環境を日本語表示されるように変更する

ユーザーの作成、sudoでのコマンドのパスを通したので、言語設定を変更する。

# vi /etc/sysconfig/i18n

/etc/sysconfig/i18nを開くと、下記のような設定となっている。このLANG部分を変更する。

LANG="C"
SYSFONT="latarcyrheb-sun16"

具体的には、下記の通りLANG部分を「ja_JP.UTF-8」とします。

LANG="ja_JP.UTF-8"
SYSFONT="latarcyrheb-sun16"

ログを監視させる

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

# sudo yum install logwatch
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * epel: ftp.kddilabs.jp
Setting up Install Process

(中略)

Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-YAML-Syck-1.07-4.el6.x86_64                             1/3
  Installing : perl-Date-Manip-6.24-1.el6.noarch                            2/3
  Installing : logwatch-7.3.6-49.el6.noarch                                 3/3

Installed:
  logwatch.noarch 0:7.3.6-49.el6

Dependency Installed:
  perl-Date-Manip.noarch 0:6.24-1.el6     perl-YAML-Syck.x86_64 0:1.07-4.el6

Complete!
$ logwatch --mailto ch3cooh393+logwatch@example.com
# sudo vi /etc/logwatch/conf/logwatch.conf
# Local configuration options go here (defaults are in /usr/share/logwatch/default.conf/logwatch.conf)
MailTo=ch3cooh393+logwatch@example.com

Apacheをインストールする

# yum -y install httpd
Loaded plugins: fastestmirror, security
Determining fastest mirrors

(中略)

Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : httpd-tools-2.2.15-15.el6.centos.1.x86_64                    1/3
  Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                         2/3
  Installing : httpd-2.2.15-15.el6.centos.1.x86_64                          3/3

Installed:
  httpd.x86_64 0:2.2.15-15.el6.centos.1

Dependency Installed:
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
  httpd-tools.x86_64 0:2.2.15-15.el6.centos.1

Complete!

Apacheをサービス登録する

# chkconfig httpd
# chkconfig --list httpd
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off

Apacheの設定を変更する

$ cd
$ mkdir backup
$ sudo cp /etc/httpd/conf/httpd.conf ./backup

バックアップを取った上で、設定を変更します。

$ sudo vi /etc/httpd/conf/httpd.conf