2012年12月25日火曜日

Webサーバー 


pcre
yum install pcre-devel


OpenSSL


tar -zxmf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./config --prefix=/home/openssl-1.0.1c --openssldir=/home/openssl-1.0.1c --shared
make
make test
su
make install

httpd 2.4.3
tar -zxmf httpd-2.4.3.tar.gz


tar -zxmf apr-1.4.6.tar.gz
tar -zxmf apr-util-1.5.1.tar.gz
tar -zxmf apr-iconv-1.2.1.tar.gz

mv apr-1.4.6 apr
mv apr-util-1.4.1 apr-util
mv apr-iconv-1.2.1 apr-iconv

mv apr apr-util apr-iconv httpd-2.4.2/srclib/

./configure \
--prefix=/home/httpd-2.4.3 \
--enable-shared \
--enable-dav=yes \
--enable-ssl \
--with-ssl=/home/openssl-1.0.1c \
--enable-module=so \
--enable-rewrite \
--with-included-apr \
--with-expat=builtin
make
su
make install

2012年12月24日月曜日

さくらVPS Firewall設定

vim /etc/sysconfig/iptables


*filter
:INPUT    DROP    [0:0]
:FORWARD  DROP    [0:0]
:OUTPUT   ACCEPT  [0:0]
:SERVICES -       [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 4  -j ACCEPT
-A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -j SERVICES
-A INPUT -p udp --sport 53 -j ACCEPT
-A INPUT -p udp --sport 123 --dport 123 -j ACCEPT
-A SERVICES -p tcp --dport YOUR_PORT_NUMBER -j ACCEPT
-A SERVICES -p tcp --dport 80 -j ACCEPT
-A SERVICES -p tcp --dport 443 -j ACCEPT
COMMIT

service iptables start

確認コマンド
iptables -L

2012年12月23日日曜日

さくらVPS SSH設定

rootになる
sudo -s

# cp /etc/ssh/sshd_config /etc/ssh/ssh_config.org
#vi /etc/ssh/sshd_config


# diff /etc/ssh/sshd_config /etc/ssh/ssh_config.org
13c13
< Port ### ⬅ポートを設定
---
> #Port 22
42c42
< PermitRootLogin no
---
> #PermitRootLogin yes
66c66
< PasswordAuthentication no
---
> PasswordAuthentication yes


さくらVPS 秘密鍵

■VPS側の設定
ログイン
ssh user@hostname

mkdir .ssh
chmod 700 .ssh

■ローカル環境(Mac)
ssh-keygen -t rsa -v


Enter file in which to save the key (/Users/○○/.ssh/id_rsa): ⬅エンター
Enter passphrase (empty for no passphrase): ⬅パスワード
Enter same passphrase again: ⬅パスワード

cd .ssh
chmod 600 id_rsa.pub

転送
scp id_rsa.pub user@hostname:~/.ssh/authorized_keys

OK

2012年12月22日土曜日

さくらVPS 初期設定

■接続
ssh root@hostname
■アップデートするyum update
■日本語化
cd /etc/sysconfig/
バックアップ
cp i18n i18n.org
編集
vi i18n
差分
diff i18n i18n.org
1c1
LANG="jp_JP.UTF-8"
---
LANG="C"

エラーが出た
 su -
-bash: warning: setlocale: LC_CTYPE: cannot change locale (jp_JP.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (jp_JP.UTF-8): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (jp_JP.UTF-8): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (jp_JP.UTF-8): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (jp_JP.UTF-8): No such file or directory

原因 localeが設定できない
locale -a | grep ja
locale -a | grep ja
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
ja_JP
ja_JP.eucjp
ja_JP.ujis
ja_JP.utf8
japanese
japanese.euc

 ja_JP.utf8を使う
 vi /etc/sysconfig/i18n
LANG="ja_JP.utf8"
OK


■ユーザー作成
useradd user
passwd user

■sudoの設定
usermod -G wheel user
vi sudo
## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL  ⬅コメントアウトを外す