2024/02/13 22:13:39

sakura VPS CentOS6 構築メモ

lang

$ sudo su
# vi /etc/sysconfig/i18n
LANG="ja_JP.UTF-8"
LC_CTYPE="ja_JP.UTF-8"
SYSFONT="latarcyrheb-sun16"

ユーザ追加

# useradd NAME
# passwd NAME
# usermod -G wheel NAME

vi etc/sysctl.conf

net.core.somaxconn = 1024
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_keepalive_time = 15
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_max_syn_backlog = 2048

sudo sysctl -p

limits.conf

sudo vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536

ssh

sudo vi /etc/ssh/sshd_config

sshd 再起動

# /sbin/service sshd restart

# su - NAME
$ mkdir .ssh
$ chmod 0700 .ssh
$ ssh-keygen -t rsa
$ vi ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

authorized_keys は全サーバ同期しておく

sudo

# /usr/sbin/visudo
%wheel  ALL=(ALL)       NOPASSWD: ALL
Defaults:NAME    !requiretty

iptables

# /root/setup/iptables.sh

root パスワード無効

# passwd -l root

不要サービス停止

# ntsysv

yum パッケージ

全体 update

# yum update

旧サーバで list 吐き出す

# yum list installed | grep --color=never '\.' | cut -d' ' -f1 | sort | uniq > yumlist

新サーバでまとめてインスコ

# for p in `cat yumlist`; do echo $p; sudo yum install $p -y; done

~

$ scp -r ~/* NewServer:/home/NAME/

ミドルウェア

git

yum のはだいたい古いので最新 stable をソースからビルド。man も入れる。

git に必要なパッケージ

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

nginx

stable 最新をソースからビルド

./configure --with-http_ssl_module --with-http_realip_module --with-http_sub_module --without-http_autoindex_module --without-http_ssi_module

daemontools

ソースからビルド

CentOS6 の upstart 対応

/etc/init/svscan.conf

start on runlevel [12345]
respawn
exec /command/svscanboot

SVDIR はアプリで利用する環境変数

以下のように upstart 起動する

initctl reload-configuration
initctl start svscan

cpan

perlbrew + cpanm 入れて cpanm --installdeps

cron

コピって終了。

サイト内検索