インストールが終わったら、設定ファイルを編集していきましょう。
設定ファイルの編集
portsからインストールすると、サンプルが入っています。
/usr/local/etc/apache/httpd.confです。
ここでは、修正するべき場所を中心に記載します。(Apache 1.3.33での例)
ExtendedStatus controls whether Apache will generate "full" status
information (ExtendedStatus On) or just basic information (ExtendedStatus
Off) when the "server-status" handler is called. The default is Off.
# ExtendedStatus On
- コメントを外して、サーバステータスを詳細にする。
#
ServerAdmin: Your address, where problems with the server should be
e-mailed. This address appears on some server-generated pages, such
as error documents.
# ServerAdmin webmaster@yamanakake.com
- 管理者のメールアドレスを設定
#
ServerName allows you to set a host name which is sent back to clients for
your server if it's different than the one the program would get (i.e., use
"www" instead of the host's real name).
# (中略) ServerName www.yamanakake.com
- コメントを外して、サーバ名を設定。
ただし、名前解決が出来ないと起動できない場合があります。山中家もそうでした。((DNSも自前なので、apache.shをzapache.shにリネームしたら、起動順が変わってOKになりました))
#
HostnameLookups: Log the names of clients or just their IP addresses
e.g., www.apache.org (on) or 204.62.129.132 (off).
The default is off because it'd be overall better for the net if people
had to knowingly turn this feature on, since enabling it means that
each client request will result in AT LEAST one lookup request to the
nameserver.
# HostnameLookups On
- OffをOnにすると、ログに記載されるアクセス者のIPアドレスがホスト名に変換されます。
#
ErrorLog: The location of the error log file.
If you do not specify an ErrorLog directive within a
container, error messages relating to that virtual host will be
logged here. If you do define an error logfile for a
container, that host's errors will be logged there and not here.
# ErrorLog /var/log/apache/httpd-error.log
- エラーがあったときのログ。デフォルトは/var/log/httpd-error.logだが、さっき作ったディレクトリに変更。
#
If you prefer a single logfile with access, agent, and referer information
(Combined Logfile Format) you can use the following directive.
# CustomLog /var/log/apache/httpd-access.log combined
- 通常アクセスのログ。デフォルトは/var/log/httpd-access.log combinedだが、さっき作ったディレクトリに変更。
#
Optionally add a line containing the server version and virtual host
name to server-generated pages (error documents, FTP directory listings,
modstatus and modinfo output etc., but not CGI generated documents).
Set to "EMail" to also include a mailto: link to the ServerAdmin.
Set to one of: On | Off | EMail
# ServerSignature Off ServerTokens ProductOnly
- エラーページなどに表示される情報を制限しておく。そうしないとバージョンなんかがばれて、セキュリティ対策が遅れると狙われるなどのリスクがあるため。
まぁ、お客さんにバージョンを示す必要はないので。
#
Allow server status reports, with the URL of http://servername/server-status
Change the ".example.com" to match your domain to enable.
#
SetHandler server-status Order deny,allow Deny from all Allow from 192.168.1.0/24 127.0.0.1 * サーバーステータスは、デフォルトではコメントになっていますが、ローカルからのみアクセスできるようにしておいて、有効にしておきます。
アドレスは、環境に合わせてくださいね。#
Allow remote server configuration reports, with the URL of
http://servername/server-info (requires that mod_info.c be loaded).
Change the ".example.com" to match your domain to enable.
#
SetHandler server-info Order deny,allow Deny from all Allow from 192.168.1.0/24 127.0.0.1
- サーバーインフォメーションも、デフォルトではコメントになっていますが、ローカルからのみアクセスできるようにしておいて、有効にしておきます。
#
Use name-based virtual hosting.
# NameVirtualHost *:80
- バーチャルホストを使うことで、ワームからのアクセスなどを切り分けることが出来ます。
また、山中家の様に複数のドメインや、各ドメインにさらに複数のサイトを構築できます。
バーチャルホストの設定の書き方は、TAKE-LABOさんが大変参考になります。


コメントする