2007/01/28

5250GB 3Ware 9590SE-8ML での Server 構築(9)
Fedora Core 6 Aptche httpd Webserver の設定


宝塚に設置した Main Webserver のメンテナンス時の Backup 体制を整えるため、岡山に設置している Server に Aptche httpd Webserver を構築します。

ところで、Apache の語源は つぎはぎだらけの A PAtCHy server という説が一般的ですが、正しくはアメリカの先住民族の部族名である Apache から由来しています。このことは本家 http://www.apache.orgWhy was the name 'Apache' chosen? として明記されています。

The name 'Apache' was chosen from respect for the Native American Indian tribe of Apache, well-known for their superior skills in warfare strategy and their inexhaustible endurance. It also makes a cute pun on "a patchy web server" -- a server made from a series of patches -- but this was not its origin. The group of developers who released this new software soon started to call themselves the "Apache Group".



さて、いつもは、左図のようにGUI で設定を行うのですが、今回は Virtialhost 設定等の変更がかなり多くなりますので /etc/httpd/conf/httpd.conf を直接編集します。

(GUI で設定を行うと /etc/httpd/conf.d/system-config-httpd.conf を編集することになります。)



root 権限でログイン後、 コンピュータを開き /etc/httpd/conf/httpd.conf を ダブルクリックします。

変更箇所は以下の通りです。

元ファイルの内容

Listen 80

ServerTokens OS

Include conf.d/*.conf

ServerAdmin root@localhost

#ServerName www.example.com:80

DocumentRoot "/var/www/html"

<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

AddDefaultCharset UTF-8

#NameVirtualHost *:80











変更後ファイルの内容

Listen 192.168.xxx.xxx:80 XXX は使用環境に合わせる

ServerTokens ProdOSを表示しない

#Include conf.d/*.confGUI設定情報等を無効にする

ServerAdmin webmastertakajun.neterror 発生画面の e-mail 表示変更

ServerName www.takajun.net:80Main Host名の変更

DocumentRoot "/hogehoge/www/takajun"Webserver で公開するディレクトリ変更

<Directory "/hogehoge/www">各種制限を行うディレクトリの設定
Options Indexesindex.html がない場合にファイル一覧を表示する場合のみ変更
AllowOverride All.htaccess ファイルでアクセス制限を行う
Order allow,deny
Allow from all
</Directory>

<Directory "/hogehoge/www/takajun/cgi-bin">CGIを実行するディレクトリ変更
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

AddDefaultCharset off日本語表記の文字化け対策(必須)

NameVirtualHost 192.168.xxx.xxx:80VirtualHost設定(NICのアドレス)

<VirtualHost 192.168.xxx.xxx:80>Main Host 内容の繰り返し
ServerAdmin webmastertakajun.net
DocumentRoot /hogehoge/www/takajun
ServerName www.takajun.net
ScriptAlias /cgi-bin/ "/hogehoge/www/takajun/cgi-bin/"
ErrorLog /hogehoge/log/takajun-error_log
CustomLog /hogehoge/log/takajun-referer_log referer
CustomLog /hogehoge/log/takajun-access_log common
</VirtualHost>

<VirtualHost 192.168.xxx.xxx:80>ここから Virtualhost の内容設定開始
ServerAdmin webmastersystemtrade.net
DocumentRoot /hogehoge/www/systemtrade
ServerName www.systemtrade.net
ScriptAlias /cgi-bin/ "/hogehoge/www/systemtrade/cgi-bin/"
ErrorLog /hogehoge/log/systemtrade-error_log
CustomLog /hogehoge/log/systemtrade-referer_log referer
CustomLog /hogehoge/log/systemtrade-access_log common
</VirtualHost>

<VirtualHost 192.168.xxx.xxx:80>
ServerAdmin webmastersystemtrade.net
DocumentRoot /hogehoge/www/systemtrade
ServerName www.systemtrade.net
ScriptAlias /cgi-bin/ "/data/www/systemtrade/cgi-bin/"
ErrorLog /hogehoge/log/systemtrade-error_log
CustomLog /hogehoge/log/systemtrade-referer_log referer
CustomLog /hogehoge/log/systemtrade-access_log common
</VirtualHost>

以下必要な Virtualhost を追記する。





httpd.conf の設定が終わると システム - 管理 - サーバー設定 - Services を選択します。

httpd にチェックを入れ 起動 を確認します。既に起動していた場合は、再起動 をクリックします。

再起動できない場合は GNOME端末を立ち上げて

# http -S (Sは大文字)

と打ち込みます。

VirtualHost configuration:
192.168.xxx.xxx:80 is a NameVirtualHost
default server www.takajun.net (/etc/httpd/conf/httpd.conf:1013)
port 80 namevhost www.takajun.net (/etc/httpd/conf/httpd.conf:1013)
port 80 namevhost www.systemtrade.net (/etc/httpd/conf/httpd.conf:1071)
Syntax OK

と Virtualhost がキチンと表示され Syntax OK が出るか確認をしてください。

# http -S も動作しない場合は # http と打ち込んで、Syntax Erroer を潰してください。



セキュリティレベル と ファイヤーウォールの設定 を行います。

システム - 管理 - セキュリティレベル と ファイヤーウォールの設定
を選択します。

ん? こちらはファイーウォールですが・・・


こちらはファイーウォールですね。

最初に ファイアーウォール を設定します。

ファイアーウォールのオプション タブで、
ファイアーウォール有効
信頼できるサービスSecure wwwwww にチェック
を入れます。


SELinux の設定SELinuxポリシー修正 で左図のようにチェックを入れ、一度 reboot してから使用します。




次に コンピュータ から アクセス制限をしたいディレクトリ を開きます。

右クリックをして ドキュメントの生成 => 空のファイル を選択します。

空のファイルが生成できたら、名前を .htaccess に変更します。

AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID & Password"
AuthType Basic
require user taro hanako

生成した .htaccess をダブルクリックして開きます。

パスワードを保存するディレクトリとファイル名を宣言します。アクセス許可者が少ない場合は require user taro hanako の様にユーザー名を順番に追記してください。アクセス許可者が多い場合は、グループ名で管理をします。

.htaccess 自体のアクセス権は604に設定して下さい。

# htpasswd /etc/httpd/conf/.htpasswd taro

New password: (非表示)
Re-type new password: (非表示)
Addingg password for user taro

ユーザー名 taro のパスワードを設定します。
GNOME端末 から htpasswd /etc/httpd/conf/.htpasswd taro を実行します。
始めてパスワードを設定する場合は、 htpasswd -c と入力します。

パスワードを聞いてきますので 2回入力をします。Addingg password for user taro が表示されれば成功です。

.htpasswd ファイルのアクセス権も604に設定します。

今回も トラブルが発生しました。httpd.conf ファイルにエラーがないのに、Virtualhost がうまく表示されません。

かなり悩んだのですが、2枚挿ししている NIC の内、WAN ( Router / CTU )側に接続しているケーブルを残し、LAN 側のケーブルを外して reboot したところ、問題なく動作しました。

取り敢えず LAN 側の NIC を無効にして使用することにします。

尚、Windows で作成した CGI の改行コード は LF + CR ですが、Linix では LF が使用されているため、Windows で作成した CGI はそのままでは動作しません。

[hogehoge@server Desktop]# perl -pe 's/\r\n/\n/' xxxx_lf_cr.cgi > xxxx_lf.cgi

で、変換すると Linux でも使用することができるようになります。


5250GB 3Ware 9590SE-8ML での Server 構築 関連 Page
2006/12/05 3Ware 9590SE BIOS 設定編
2006/12/06 PC 組立/Bench 編
2006/12/14 Fedora Core 6 に 3Ware 3DM2 をインストール
2006/12/15 Fedora Core 6 NFS Server の設定
2006/12/17 Fedora Core 6 Samba Server の設定
2006/12/20 Fedora Core 6 CUPS Print Server の設定
2007/01/13 Fedora Core 6 AntiVirus Soft Install
2007/01/24 Fedora Core 6 yum-updatesd の自動化設定
2007/01/28 Fedora Core 6 Aptche httpd Webserver の設定
2007/12/12 Fedora Core 6 xmms 24時間 BGM








当 Page への Link は自由ですが、Auction 等の商品説明や補足のために Link を張る事は堅く禁じます。(詳細はこちら

Copyright (c) 1999 - 2007 takajun. All rights reserved.