Category: Apache / Tags:
WEBサーバーのセットアップ Red Hat Enterprise Linux 5 とか
yum コマンド や up2date とかで入っているものを一度最新にしておきます。
# yum check-update
# yum update
必要であれば、その後各種rpm等をインストールしてください。
どうしても、最新バージョンとかでソースから入れる必要があるのであれば
一度 rpmをインストールして依存関係があるものをいれていまって、
アンインストールしたのち、ソースから入れるとかすると依存関係に悩む事が少なく
なります。ただし、要らないものもはいると言われればそうなので、
そういうのが嫌な人はしないほうがいいです。
webサーバーはすでに入っている場合は、ログの場所を修正
アパッチのログを修正
www.example.com の場合、ぼくは
/var/log/httpd/www.example.com//var/log/httpd/www.example.com/
となるようにフォルダを作成します。
アクセスログは
/var/log/httpd/www.example.com/www.example.com-access_log
/var/log/httpd/www.example.com/www.example.com-error_log
となる感じです
場合によって、 www.example.com-access_log env=nolog
とかで、jpugとかを取らないようにします。(nologは別途設定がひつようですよ)
httpd.confの修正
# cd /etc/httpd/conf/
# mkdir backup
# mv httpd.conf.rpmsave backup/
# mv httpd.conf.rpmnew backup/
# cp httpd.conf backup/httpd.conf.080610
# vi httpd.conf
–ここから
ServerAdmin root@exsample.com
ServerName exsample.com:80
Options -Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
UserDir disable
DirectoryIndex index.html index.htm index.html.var
ErrorLog logs/www.exsample.com/www.exsample.com-error_log
CustomLog logs/www.exsample.com/www.exsample.com-access_log combined
ServerSignature Off # varsionによる
#vhosts
NameVirtualHost 000.000.000.00:80
–ここまで
ついでに、テスト用のサブドメインのサイトをつくっておきます
# cd ../conf.d/
# vi test.exsample.com.conf
–ここから
ServerAdmin webmaster@test.exsample.com
DocumentRoot “/var/www/vhosts/test.exsample.com/html”
ServerName test.exsample.com
Options All -Indexes
AllowOverride All
ErrorLog logs/test.exsample.com/test.exsample.com-error_log
CustomLog logs/test.exsample.com/test.exsample.com.com-access_log combined
–ここまで
フォルダ等を作成
# mkdir /var/www/vhosts
# mkdir /var/www/vhosts/test.exsample.com
# mkdir /var/www/vhosts/test.exsample.com/html
# cp test.exsample.com www.exsample.com // 設定をまねして作成
(省略、すべてバーチャルで管理するので)
sslの設定もついでに
# vi ssl.conf
-#DocumentRoot “/var/www/html”
-#ServerName www.example.com:443
+DocumentRoot “/var/www/html”
+ServerName www.exsample.com:443
-ErrorLog logs/ssl_error_log
-TransferLog logs/ssl_access_log
+ErrorLog logs/www.exsample.com.com/www.exsample.com-error_log
+CustomLog logs/www.exsample.com/www.exsample.com-access_log combined
#httpと同じ出力先になるように設定
-CustomLog logs/ssl_request_log \
+CustomLog logs/www.exsample.com/www.exsample.com.com-ssl_request_log \
確認
# apachectl -t
Syntax OK
vhostsの設定も確認
# apachectl -t -D DUMP_VHOSTS
VirtualHost configuration:
xxx.xxx.xxx.xxx:80 is a NameVirtualHost
default server test.exsample.com (/etc/httpd/conf.d/test.exsample.com.conf:1)
port 80 namevhost test.exsample.com (/etc/httpd/conf.d/test.exsample.com.conf:1)
port 80 namevhost www.exsample.com (/etc/httpd/conf.d/www.exsample.com.conf:1)
wildcard NameVirtualHosts and _default_ servers:
_default_:443 exsample.com (/etc/httpd/conf.d/ssl.conf:81)
Syntax OK
再起動
# apachectl restart
# ps ax | grep httpd
起動ができてなければ、エラーログをチェックして修正
ログローテーションの修正
# cd /etc/logrotate.d/
# cp httpd
httpd httpd.rpmnew
# cp httpd www.exsample.com
# cp httpd test.exsample.com
– デフォルトは
weekly
rotate 4
で一ヶ月ってところなので、1年とか2年とかに修正
rotate 105
/var/log/httpd/test.exsample.com/*log {
rotate 105
missingok
notifempty
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}