a2enmod module を実行するだけで簡単に行うことが可能です。これに対して、モジュールを無効化するコマンドは a2dismod module です。実際のところ、これらのプログラムは /etc/apache2/mods-enabled/ 内に実際のファイル (/etc/apache2/mods-available/ 内に保存されています) を指すシンボリックリンクを作成 (または削除) しているだけです。
/etc/apache2/ports.conf の中で設定されています)、/var/www/html/ ディレクトリに含まれるページを公開します (/etc/apache2/sites-enabled/000-default.conf の中で設定されています)。
mod_ssl) required for secure HTTP (HTTPS) out of the box. It just needs to be enabled with a2enmod ssl, then the required directives have to be added to the configuration files. A configuration example is provided in /etc/apache2/sites-available/default-ssl.conf.
SSLCertificateFile /etc/letsencrypt/live/DOMAIN/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN/chain.pem SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt
mod_gnutls, which is shipped with the libapache2-mod-gnutls package and enabled with the a2enmod gnutls command. Unfortunately the version packaged for Debian had serious issues and even security implications and is therefor not part of the Debian Bullseye release.
/etc/apache2/sites-enabled/000-default.conf ファイルの中でデフォルトの仮想ホストが定義されています。この仮想ホストはクライアントによって送信された要求に一致するホストが見つからない場合に使われます。
/etc/apache2/sites-available/ にファイルを追加します。falcot.org ドメインで運用されるウェブサイトをセットアップするには、以下のファイルを作成し、a2ensite www.falcot.org を使って仮想ホストを有効化するだけで簡単に可能です。
例 11.13 /etc/apache2/sites-available/www.falcot.org.conf ファイル
<VirtualHost *:80> ServerName www.falcot.org ServerAlias falcot.org DocumentRoot /srv/www/www.falcot.org </VirtualHost>
CustomLog 指示文を追加すればこの挙動を変えることが可能です)。そのため、ログファイルのフォーマットをカスタマイズして、仮想ホストの名前を含むようにすることが道理に適っています。これを行うには、/etc/apache2/conf-available/customlog.conf ファイルを作成してすべてのログファイルに対する新しいフォーマットを定義し (LogFormat 指示文を使います)、さらに a2enconf customlog を有効化します。また、/etc/apache2/sites-available/000-default.conf ファイルから CustomLog 指示文を削除 (またはコメントアウト) しなければいけません。
Directory ブロックが含まれます。Directory ブロックを使うことで、提供されるファイルの位置に従って、サーバの挙動を変えることが可能です。Directory ブロックには通常 Options と AllowOverride 指示文が含まれます。
例 11.15 Directory ブロック
<Directory /srv/www> Options Includes FollowSymlinks AllowOverride All DirectoryIndex index.php index.html index.htm </Directory>
DirectoryIndex 指示文には、クライアントからディレクトリを要求された場合に応答として送信するファイルのリストを指定します。リスト内の最初に見つかったファイルが応答として使われます。
Options 指示文には、有効化するオプションを指定します。None を指定するとすべてのオプションが無効化されます。それに対して All を指定すると MultiViews を除いたすべてのオプションが有効化されます。以下に利用できるオプションを挙げます。
ExecCGI indicates that CGI scripts can be executed.
FollowSymlinks tells the server that symbolic links can be followed, and that the response should contain the contents of the target of such links.
SymlinksIfOwnerMatch also tells the server to follow symbolic links, but only when the link and its target have the same owner.
Includes enables Server Side Includes (SSI for short). These are directives embedded in HTML pages and executed on the fly for each request.
IncludesNOEXEC allows Server Side Includes (SSI) but disables the exec command and limits the include directive to text/markup files.
Indexes tells the server to list the contents of a directory if the HTTP request sent by the client points at a directory without an index file (i.e., when no files mentioned by the DirectoryIndex directive exists in this directory).
MultiViews enables content negotiation; this can be used by the server to return a web page matching the preferred language as configured in the browser.
AllowOverride 指示文には、.htaccess ファイルを使って有効化または無効化することを許可するすべてのオプションをリストします。AllowOverride 指示文は一般に ExecCGI を制限するために使われることが多いです。こうすることで、管理者はウェブサーバ (www-data ユーザ) の権限でプログラムを実行することを許可するユーザを選択します。
mod_auth* modules.
/etc/apache2/authfiles/htpasswd-private file contains a list of users and passwords; it is commonly manipulated with the htpasswd command. For example, the following command is used to add a user or change their password:
#htpasswd /etc/apache2/authfiles/htpasswd-private userNew password: Re-type new password: Adding password for user user
/etc/awstats/awstats.conf ファイルをカスタマイズして設定を行います。Falcot の管理者は以下のパラメータだけを修正し、他はそのままの状態にしています。
LogFile="/var/log/apache2/access.log" LogFormat = "%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" SiteDomain="www.falcot.com" HostAliases="falcot.com REGEX[^.*\.falcot\.com$]" DNSLookup=1 LoadPlugin="tooltips"
LogFile と LogFormat パラメータを使って、ログファイルの場所とログファイルに含まれる情報の書式を指定します。さらに SiteDomain と HostAliases は主要ウェブサイトに割り当てている複数の名前をリストします。
DNSLookup を 1 に設定するべきではありません。トラフィックの少ないサイトでは Falcot の設定と同様に DNSLookup を設定することで、解析結果に生 IP アドレスではなく完全なマシン名が含まれるようになり、解析結果を読みやすくなります。
/etc/awstats/awstats.www.falcot.org.conf などの設定ファイルを作ってください。
例 11.18 仮想ホスト用の AWStats 設定ファイル
Include "/etc/awstats/awstats.conf" SiteDomain="www.falcot.org" HostAliases="falcot.org"
/usr/share/awstats/icon/ directory. In order for these icons to be available on the web site, the Apache configuration needs to be adapted to include the following directive (check out /usr/share/doc/awstats/examples/apache.conf for a more detailed example):
Alias /awstats-icon/ /usr/share/awstats/icon/