LoginSignup
2
5

More than 5 years have passed since last update.

Apache2.4 httpd.confの目的別セット

Posted at

yum とかでインストールすると全部入りになっちゃうので、使わないの機能とはは外すようにしている。
メモがてらQiiting。

httpd.conf

conf/httpd.conf
ServerRoot "/etc/httpd"
Listen 0.0.0.0:80
User apache
Group apache

Include conf.modules.d/*.conf

ServerName myserver.example.com
ServerAdmin admin@localhost

# ここは環境やサービスにあわせて
MaxClients 5
MinSpareServers 1
MaxSpareServers 5

<Directory />
    AllowOverride none
    Require all denied
</Directory>

# パスはあわせる
DocumentRoot "/var/www/myapp/current/public"
<Directory "/var/www/myapp/current/public">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

<IfModule mime_module>
    TypesConfig /etc/mime.types
    #AddType application/x-gzip .tgz
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

        # CGI使う時は外す
    #AddHandler cgi-script .cgi
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

EnableMMAP off
EnableSendfile off

IncludeOptional conf.d/*.conf

conf.d 以下

welcome.conf とか、使わないであろうファイルは消しちゃうか、welcome.conf.nouse のようにリネームして退避しておく。
また、一時的に使わない場合も、〜.nouseとリネームしておくと良い。

conf.d/auth_basic.conf
# Basic 認証を使う場合
<Location />
    AuthType Basic
    AuthUserFile "/path/to/passwdfile"
    AuthGroupFile /dev/null
    AuthName "Restricted Area"
    Require valid-user
</Location>
conf.d/auth_digest.conf
# Digest 認証を使う場合
<Location />
    AuthType Digest
    AuthUserFile "/path/to/passwdfile"
    AuthName "Restricted Area"
    Require valid-user
</Location>

ログは、ELBのヘルスチェックを別ログに記録するようにしている。ここを参考

conf.g/logging.conf
ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module>
    SetEnvIf User-Agent "ELB-HealthChecker.*" nolog
    SetEnvIf User-Agent "ELB-HealthChecker.*" elb

    #LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t %D \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %{X-Forwarded-For}i %{X-Forwarded-Proto}i" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
            # Debug 向け
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{X-Forwarded-For}i %{X-Forwarded-Proto}i %I %O" combinedio
    </IfModule>

    #CustomLog "logs/access_log" common
    CustomLog "logs/access_log" combined env=!nolog
    CustomLog "logs/elb_healthcheck_log" combined env=elb

</IfModule>
2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5