̃Gg[͂ĂȃubN}[Nɒlj

apache :: apache2 の設定まわり



apache2.conf

% less /etc/apache2/apache2.conf
 :
PidFile /var/run/apache2.pid <= ./envvars APACHE_PID_FILE の値
 :
User hoge <= ./envvars APACHE_RUN_USER の値
 :
Group fuga <= ./envvars APACHE_RUN_GROUP の値
 :


security

% less /etc/apache2/conf.d/security
 :
ServerTokens Prod
 :
ServerSignature Off
 :
TraceEnable Off
 :


httpd.conf

% less /etc/apache2/httpd.conf
 :
ServerName example.com <= 運用するドメイン
 :
# Virtual hosts
Include /etc/apache2/vhosts.conf <= バーチャルホストの設定(任意)
 :


vhosts.conf

% less /etc/apache2/vhosts.conf
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /var/www/main.example.com
    ServerName main.example.com
    ErrorLog  "|exec /usr/sbin/rotatelogs /var/log/apache/main.example.com/error_log.%Y%m%d 86400 540"
    CustomLog "|exec /usr/sbin/rotatelogs /var/log/apache/main.example.com/access_log.%Y%m%d 86400 540" combined

    <Directory /var/www/main.example.com>
        Order allow,deny
        Allow from all
        AllowOverride all
        Options All -Indexes
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/sub.example.com
    ServerName sub.example.com
    ErrorLog  "|exec /usr/sbin/rotatelogs /var/log/apache/sub.example.com/error_log.%Y%m%d 86400 540"
    CustomLog "|exec /usr/sbin/rotatelogs /var/log/apache/sub.example.com/access_log.%Y%m%d 86400 540" combined

    <Directory /var/www/sub.example.com>
        Order allow,deny
        Allow from all
        AllowOverride all
        Options All -Indexes
    </Directory>
</VirtualHost>


preforkモデルかどうかの確認

% apache2 -l
Compiled in modules:
   :
  prefork.c
   :
  • prefork.c が表示されれば preforkモデル。


daemontools runスクリプト

% less /service/apache2/run
#!/bin/sh
logger -t daemontools 'apache (re)started.'
exec /usr/sbin/apache2 -DNO_DETACH -DFOREGROUND -f /etc/apache2/apache2.conf









server/apache/httpd.conf/apache2.conf.txt