さくらVPSを契約したので、ちゃんと使ってみることにしました。
巷の他のVPSは、VPS(Virtual Private Server)と言っても最初からいろいろとインストールされていて、便利な反面、意外と使い勝手が悪かったりしました。
某社のVPSなんかは、そもそも使う用途の宣伝の仕方が違いますね。まぁまぁ安定してますが。
某社のVPSはアホみたいにサーバー障害が起こりまくって最悪でした。初期費用詐欺ですわ。
・・・すみません。愚痴ってしまいました。
しかし、某社のVPSのせいで、眠れない日々が続いたもので・・・
さくらVPSですが、契約初期状態は「CentOS5をインストールした状態」のようです。
まさに家にあるPCにインストールした直後のような状態です。Private Serverです。
瞬時に初期状態に戻せるので、Virtualって素晴らしい。良いおもちゃになりそうです。
以下、いわゆるLAMP環境を作りましたので、メモです。
※wordpressをインストールする目的です。
言語設定をUTF-8に設定。
vi /etc/sysconig/i18n LANG="ja_JP.UTF-8"
新しいユーザーを作成し、rootでのsshログインを禁止する。
useradd admin
passwd admin passwd
visudo admin ALL=(ALL) ALL
vi /etc/ssh/sshd_config Port [22以外の空いているポート番号に。3万なんぼとか] PermitRootLogin no PasswordAuthentication no UsePAM no
SSH公開鍵を、~/.ssh/authorized_keys に追加(cat keyfile.pub >> ~/.ssh/authorized_keys) 鍵作成:ssh-keygen -t "rsa"
メモリが少ないので余計なプロセスを削除
vi /etc/inittab #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6
chkconfig haldaemon off chkconfig yum-updatesd off chkconfig acpid off chkconfig messagebus off chkconfig cpuspeed off
iptables設定
cd ~ vi iptable-init.sh #!/bin/sh iptables -F iptables -X iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD DROP iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT iptables -A INPUT -s 10.0.0.0/8 -j DROP iptables -A INPUT -s 172.16.0.0/12 -j DROP iptables -A INPUT -s 192.168.0.0/16 -j DROP # iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A INPUT -p tcp --dport [sshd_configで指定したport] -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
./iptable-init.sh iptables-save > /etc/sysconfig/iptables
ここまでで基本的なOS設定終わり。
一度、再起動しました。
とりあえずLAMP環境
yum -y install httpd mod_ssl httpd-devel
yum -y install php
yum -y install mysql-server
vi /etc/httpd/conf/httpd.conf #ServerTokens OS ServerTokens Prod : #ServerSignature On ServerSignature Off : #Options Indexes FollowSymLinks Options FollowSymLinks : #AllowOverride None AllowOverride All
PHP,mysqlのバージョンを最新にする
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm rpm -Uvh epel-release-5* remi-release-5* wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm yum -y --enablerepo=remi,epel,rpmforge update php* mysql* yum -y --enablerepo=remi,epel,rpmforge install php-gd php-mbstring php-mysql php-odbc php-pdo php-pear mysql-server mysql-bench yum -y --enablerepo=remi,epel,rpmforge install phpMyAdmin
php.iniを設定
vi /etc/php.ini ;date.timezone = date.timezone = Asia/Tokyo
mysqlのキャラクターセットは、UTF-8にしておく。
vi /etc/my.cnf [mysqld] default-character-set=utf8 skip-character-set-client-handshake : [mysql] default-character-set = utf8
mysqlのrootのパスワードを設定
/etc/init.d/mysqld start mysqladmin -u root password [rootpassword] /etc/init.d/mysqld stop
phpMyAdminがローカルからしか繋がらないので外部から繋げられるように。
vi /etc/httpd/conf.d/phpMyAdmin.conf <Directory /usr/share/phpMyAdmin/> order deny,allow #deny from all #allow from 127.0.0.1 #allow from ::1 allow from all </Directory>
おわり。
chkconfig httpd on chkconfig mysqld on
/etc/init.d/httpd start /etc/init.d/mysqld start
参考サイト:ありがとうございます
「さくらのVPS」を使ってみる – さくらインターネット創業日記
さくらの VPS の設定ダダ流し – ゆっくり…して…イってネ!
CentOS 5.3 に php-5.2.9, mysql-5.1.35 をインストール(remi レポジットリより) – お試しlog4