Ubuntu 16.04 の例 | Apache
Apache
16.04.6 LTS (Xenial Xerus) 。
※ $cat /etc/os-releaseで確認。
設定ファイル
全体
/etc/apache2/apache2.conf
各サイト
/etc/apache2/sites-available/example.com.conf
以下を実行するとsites-enabledフォルダにシンボリックリンクが作成される。
$ cd /etc/apache2/sites-available
$ a2ensite example.com.conf
そして/etc/apache2/apache2.confに以下の記載があるため設定が読み込まれる。
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
モジュール
インストール済みモジュール確認
$ ubuntu@example.com:/etc/apache2$ apachectl -M
headerモジュールを有効化
$ sudo a2enmod headers
実行ユーザー
/etc/apache2/apache2.conf
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
/etc/apache2/envvars
export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=www-data
実行ユーザーを変更したときはsudo systemctl reload apache2では反映されないので以下を実行する。
$ sudo systemctl stop apache2
$ sudo systemctl start apache2
PHPの確認方法
<?php
echo exec('whoami');
ref. https://note.affi-sapo-sv.com/web-user-confirm.php
ログファイル
/var/log/apache2/example.com.access.log/var/log/apache2/example.com.error.log/var/log/apache2/example.com.request_uri.log
SSL証明書
/etc/letsencrypt/live/の直下に配置される。
ログフォーマット
/etc/apache2/apache2.confに以下のように記述されている。
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%{REQUEST_URI}e" request_uri