Apache httpdカスタマイズ1 公開元ディレクトリー変更など

Apache M onitor

 
自分用のメモです。


これまで

Apache (Webサーバー) を含むXampp、全文検索システムのFess、DokuWIki をインストールした。

今日は

Web公開元となるディレクトリー変更など、Apache (Webサーバー) のconfファイルをカスタマイズした。


(a) 公開元ディレクトリーの設定を変更する

httpd.confを編集する
今回の例で、xamppインストール先ディレクトリー (フォルダー) は、C:\xampp だった。
C:\xampp\apache\confhttpd.conf をテキストエディターで開く。

(Before)
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">

(After)
DocumentRoot "D:/home/htdocs/www"
<Directory "D:/home/htdocs/www">

※上のフォルダー名は一例

Windowsで公開元ディレクトリーを作成する
ディレクトリー (C:\xampp\htdocs) の中身を、これから (D:\home\htdocs\www) にコピーする。
公開元変更に伴い、旧ディレクトリーは不要になるため、削除して構わない。

※上のディレクトリー名は一例

ここまで設定したら
Apacheを再起動する
http://localhost/ に従来通りアクセスできるか確認する。


(b) アクセスできるIPを制限する

httpd.confを編集する
(Before)

  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Require all granted

  ↓
(After)

 Options Indexes FollowSymLinks Includes ExecCGI
 AllowOverride All
 
  Require local
  Require ip 192.168.0.0/24
 


※上のディレクトリー名は一例


(c) 管理者のメールアドレス (問い合わせ先) を設定する

httpd.confを編集する
今回の例で、xamppインストール先は、C:\xampp とした。
C:\xampp\apache\confhttpd.conf をテキストエディターで開く。

(Before)
ServerAdmin postmaster@localhost

(After)
ServerAdmin あいさんななのメールアドレス

ここまで設定したら
Apacheを再起動する。
・存在しないURL (http://localhost/xxx/ など)を適宜開く。
・「サーバーの障害と思われる場合は、ウェブ管理者までご連絡ください。」と表示されたら
 [ウェブ管理者]をクリックしてメールアドレスが変更されているか確認する。


(d) ブラウザーのURL欄への入力を省略できるファイル名を追加する

httpd.confを編集する
今回の例で、xamppインストール先は、C:\xampp とした。
C:\xampp\apache\confhttpd.conf をテキストエディターで開く。

(Before)

 DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
  default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
  home.php home.pl home.cgi home.asp home.shtml home.html home.htm


(After)

 DirectoryIndex index.rb index.jsp \
  index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
  default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
  home.php home.pl home.cgi home.asp home.shtml home.html home.htm


今日はここまで。
明日はユーザーディレクトリーを設定してみる。


(*) Apache HTTP サーバ バージョン 2.4 ドキュメント

  http://httpd.apache.org/docs/2.4/