Kurohama
Apache(WEBサーバー)
■WEBブラウザからアクセスする場合
■サーバー自身
http://127.0.0.1
■LANから
http://※サーバーのローカルIP(http://192.168.1.3)等
■外部から
http://※ドメイン(http://www.kurohama.com)等
シェルスクリプトで行う設定
■設定は一発サーバーを実行すると自動的に行われます。
■httpd停止
/etc/rc.d/init.d/httpd stop

■firefox、httpd、mod_ssl、php、php-mbstringインストール
yum -y install firefox httpd mod_ssl php php-mbstring

■Perlコマンドへ/usr/local/bin/perlでもアクセスできるようにする
■/usr/local/bin/perlから/usr/bin/perlへリンクをはる
ln -s /usr/bin/perl /usr/local/bin/perl

■設定ファイルの差替え
■今までの設定ファイルをリネーム
■元に戻す時は、各ファイル名の末尾についている.bakを取る
mv -f /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
mv -f /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak

■差替えファイル移動
cp -f /var/www/html/isrv/setting1/httpd.conf /etc/httpd/conf/httpd.conf
cp -f /var/www/html/isrv/setting1/ssl.conf /etc/httpd/conf.d/ssl.conf
cp -f /var/www/html/isrv/setting1/virtualhost.conf

■差替えファイルパーミッション設定
chmod 644 /etc/httpd/conf/httpd.conf
chmod 644 /etc/httpd/conf.d/ssl.conf
chmod 644 /etc/httpd/conf.d/virtualhost.conf

■テストページ削除
rm -f /etc/httpd/conf.d/welcome.conf
rm -f /var/www/error/noindex.html

■バーチャルホスト用に新規ユーザ作成時にpublic_htmlディレクトリ作成
mkdir /etc/skel/public_html

■Apach設定ファイル書換
/etc/httpd/conf/httpd.conf
■管理者メールアドレスの設定
ServerAdmin root@localhost

ServerAdmin ※管理者メールアドレス
■ドメインを入力
#ServerName www.example.com:80

ServerName ※メインドメイン:80

■httpd起動
/etc/rc.d/init.d/httpd start

■httpd自動起動設定
chkconfig httpd on
差替えファイルであらかじめしてある設定
■Apach設定ファイル編集
/etc/httpd/conf/httpd.conf
■エラーページ等でOS名を表示しないようにする
ServerTokens OS

ServerTokens Prod
■CGI,SSIの許可
Options Indexes FollowSymLinks

Options Includes ExecCGI FollowSymLinks
■.htaccessの許可
# Options FileInfo AuthConfig Limit
#
AllowOverride None

AllowOverride All

■インデックスファイル編集
DirectoryIndex index.html index.html.var

DirectoryIndex index.shtml index.shtml.var
DirectoryIndex index.shtm index.shtm.var
DirectoryIndex index.cgi index.cgi.var
DirectoryIndex index.php index.php.var
DirectoryIndex index.html index.html.var
DirectoryIndex index.htm index.htm.var
■長すぎるURI(414エラー)はログに記録しない
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
■アクセスログの設定
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access_log combined

SetEnvIf Request_URI "default\.ida" no_log
SetEnvIf Request_URI "cmd\.exe" no_log
SetEnvIf Request_URI "root\.exe" no_log
SetEnvIf Request_URI "Admin\.dll" no_log
SetEnvIf Request_URI "NULL\.IDA" no_log
SetEnvIf Remote_Addr 192.168 no_log
SetEnvIf Remote_Addr 127.0.0.1 no_log
CustomLog logs/access_log combined env=!no_log
■エラーページ等でApacheのバージョンを表示しないようにする
ServerSignature On

ServerSignature Off
■UTF-8の設定をコメントアウト
AddDefaultCharset UTF-8

#AddDefaultCharset UTF-8
■CGIスクリプトを有効化
#AddHandler cgi-script .cgi

AddHandler cgi-script .cgi .pl
■ディレクトリのファイル一覧を表示しないようにする
<Directory "/var/www/icons">
Options Indexes MultiViews

Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

■メインホスト用バーチャルホスト設定ファイル作成
/etc/httpd/conf.d/virtualhos.conf
<VirtualHost *:80>
ServerName ※メインドメイン
</VirtualHost>

■SSL設定ファイル編集
/etc/httpd/conf.d/ssl.conf
■DocumentRoot有効化
#/etc/httpd/conf.d/ssl.conf
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"

DocumentRoot "/var/www/html"

"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
■以下を追加
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog "logs/rewrite_log"
RewriteLogLevel 0
RewriteCond %{HTTP_HOST} !※メインドメイン$
RewriteRule ^/(.*)?$ http://%{HTTP_HOST}/$1 [L,R]
</IfModule>
■設定ファイル情報
-rw-r--r-- 1 root root 33726 11月 13 08:47 /etc/httpd/conf/httpd.conf
-rw-r--r-- 1 root root 9677 11月 13 08:47 /etc/httpd/conf.d/ssl.conf
CGIで行う設定
■設定はフォームに入力すると自動的に行われます。
■バーチャルホスト用ユーザーの追加
■追加ホスト用バーチャルホスト設定ファイル追記
/etc/httpd/conf.d/virtualhost.conf
■以下の記述を追加
<VirtualHost *:80>
ServerName ※ドメイン
DocumentRoot /var/www/html/user/※ユーザー名/public_html
ServerName www.※ドメイン
ServerAlias www.※ドメイン
ServerAlias ※ドメイン
ErrorLog logs/※ユーザー名-error_log
CustomLog logs/※ユーザー名-access_log combined env=!no_log
Alias /usage /var/www/html/user/※ユーザー名/usage
</VirtualHost>

■ユーザーを削除した場合は、追加した記述を削除
このページのご意見
■このページへのご意見・ご要望、間違い、誤字・脱字のご連絡はこちらからお願いします。
Copyright(C)2009 KUROHAMA All rights reserved