Valid XHTML 1.0!
Valid CSS!

Apache 1.3でのhttpd.conf 詳細設定

設定の変更

変更後は
# /usr/local/apache/bin/apachectl configtest
で"Syntax OK"が出るのを確認、その後
# /usr/local/apache/bin/apachectl restart
で再起動する。

ポートの設定

makeをrootで行うとポートは80に設定され、ユーザで行うと8080になる。必要に応じて変更する。

#
# Port: The port to which the standalone server listens. For
# ports < 1023, you will need httpd to be run as root initially.
#
Port 80

ユーザとグループの設定

初期設定では両方とも"nobody"となっている、必要に応じて変更する。

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# . On SCO (ODT 3) use "User nouser" and "Group nogroup".
# . On HPUX you may not be able to use shared memory as nobody, and the
# suggested workaround is to create a user www and use that use.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET
# when the value of (unsigned)Group is above 60000;
# don't use Group nobody on these systems!
#
User nobody
Group nobody

メールアドレスの設定

エラーページにはここで設定したメールアドレスが表示される。またエラーがあった場合このアドレスに通知がいく。webmasterなどのメールアドレスを登録しておくとよい。

#
# 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@yebisu.co.jp

サーバネームの設定

使用するドメイン名を記入する、これを行わないと起動しない。

#
# 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).
#
# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address (e.g., http://123.45.67.89/)
# anyway, and this will make redirections work in a sensible way.
#
# 127.0.0.1 is the TCP/IP local loop-back address, often named localhost. Your
# machine always knows itself by this address. If you use Apache strictly for
# local testing and development, you may use 127.0.0.1 as the server name.
#
ServerName www.yebisu.co.jp

ドキュメントルートの設定

htmlファイルを置く場所を決める。初期設定では/usr/local/apache/htdocsとなっているので/home/htdocsなどにすると便利になる。

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/htdocs"

インデックスを表示しない

初期設定ではディレクトリ内にindex.htmlが存在しない場合はディレクトリ内の一覧を表示されるようになっているが、ここのIndexesを削除することにより一覧表示されなくなる。

#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks MultiViews

ホスト名の照会設定

ここをOnにするとログにアクセスしてきたホストをIPアドレスではなくホスト名で保存ができるようになる。

#
# 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

エラーログの保存先

ここを変更すると初期設定では/usr/local/apache/logs/に保存されるログの置き場所を変更できる。ログは/var/に置かれることが多いので/var/apache/などのディレクトリを作り、そこに保存するようにすると便利。

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog /var/apache/error_log

アクセスログの保存先

エラーログと同じようにアクセスログの保存場所を指定できる。

#
# The location and format of the access logfile (Common Logfile Format)
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog /var/apache/access_log common

シグネチャーの設定

エラーの時などにapacheのバージョンと一緒に管理者のメールアドレスが表示されるが、ここの設定を"EMail"にすると自動的にmailto:のリンクになる。

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (error documents, FTP directory listings,
# mod_status and mod_info 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 EMail

CGIディレクトリの設定

初期設定では/usr/local/apache/cgi-bin/になっているディレクトリを変更できる。

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications an
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

エラーページの指定

指定することによりエラーページを自分で作ったものに変更できる。エラー番号ごとに指定をする。DocumentRootが/home/htdocs/の場合に/home/htdocs/error/というディレクトリを作り指定するには下記のようにする。

#
# Customizable error response (Apache style)
# these come in three flavors
#
# 1) plain text
#ErrorDocument 500 "The server made a boo boo.
# n.b. the single leading (") marks it as text, it does not get output
#
# 2) local redirects
#ErrorDocument 404 /missing.html
# to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
# N.B.: You can redirect to a script or a document using server-side-includes.
#
# 3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
# N.B.: Many of the environment variables associated with the original
# request will *not* be available to such a script.
ErrorDocument 403 /error/error_403.html
ErrorDocument 404 /error/error_404.html

バーチャルホストの設定

設定により一つのサーバで複数のドメインでのアクセスを受けることができるようになる。

#
# Use name-based virtual hosting.
#
#NameVirtualHost *

NameVirtualHost 210.168.239.169
↑ここでIPアドレスを指定する

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
# </VirtualHost>

<VirtualHost 210.168.239.169>
ServerName www.yebisu.co.jp
ServerAdmin webmaster@yebisu.co.jp
DocumentRoot /home/htdocs/yebisu
</VirtualHost>

<VirtualHost 210.168.239.169>
ServerName www.kurolabel.co.jp
ServerAdmin webmaster@kurolabel.co.jp
DocumentRoot /home/htdocs/kurolabel
</VirtualHost>

↑それぞれのドメイン名の詳細を設定する

これ以外の設定

こちらをご覧ください。
JAPANIZED APACHE SERVER PROJECT