Linode CentOS設定メモ

Linodeで仮想マシンを借りて、それにCentOS 5.2をインストールしたときのメモ。 Linode設定メモの続き。

Linodeに限らずCentOSなマシン全般にあてはまるはず。

timezone 変更

# cp /usr/share/zoneinfo/Japan /etc/localtime

SELinux無効化

# vi /etc/selinux/config

以下の部分を変更して

SELINUX=enforcing
↓
SELINUX=disabled

リブートする。

# reboot

一般ユーザを作る

rootじゃない一般ユーザを作る。wheel グループに所属させておく。

# useradd -g wheel user名
# passwd user名
Changing password for user xxxxx.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

visudoで 以下の行のコメントを外す。これでwheelグループに属する人はパスワードなしでsudoを実行できる。

# visudo
# %wheel        ALL=(ALL)       NOPASSWD: ALL
↓
%wheel        ALL=(ALL)       NOPASSWD: ALL

OSのアップデート

Linode申し込み時にはCentOS 5.2しかないのでyumでCentOS 5.3にアップデートする。

# yum -y install yum-fastestmirror
# yum -y update
# cat /etc/redhat-release
CentOS release 5.3 (Final)

iptables

とりあえず port 80 を空けておく。

/etc/sysconfig/iptablesを編集。

# vi /etc/sysconfig/iptables

したから2行めのREJECTの直前に以下を追加

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

iptablesを再起動。

# /etc/init.d/iptables restart

apache と PHP の設定、起動

apache を yumでインストール。

# yum -y install httpd

welcomeページ設定削除

# rm /etc/httpd/conf.d/welcome.conf

ディレクトリIndexをoffにする。

# vi /etc/sysconfig/iptables

以下の部分を変更

<Directory "/var/www/html">
...
    Options Indexes FollowSymLinks
↓
    Options FollowSymLinks
...
</Directory>

CentOS 5ではPHPが5.1系なので、リポジトリを追加してPHP 5.2系をインストールする。

# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

リポジトリファイルを編集

# vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

インストール

# yum -y install php php-mbstring php-mysql
# php -v
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

yum updateの対象とならないようにenabled=0にしておく。

# vi /etc/yum.repos.d/utterramblings.repo
enabled=1
↓
enabled=0

apache起動。

# /etc/init.d/httpd start
Starting httpd: [  OK  ]

マシン起動時に自動起動するように設定しておく。

# chkconfig httpd on

mysql

インストール

# yum -y install mysql-server mysql-devel

my.cnfを編集。

# vi /etc/my.cnf
[mysqld]
...
default-character-set = utf8

[mysql]
default-character-set = utf8

起動。

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

rootのパスワードを変更。

# mysql -u root
mysql> set password for root@localhost=password('xxxxxxxx');
mysql> set password for root@"127.0.0.1"=password('xxxxxxxx');
mysql> set password for root@"ホスト名"=password('xxxxxxxx');