IT pass HikiWiki - [Memo2018][ITPASS]Apache のインストールと設定 Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

{{toc}}

= Apache のインストールと設定

最新バージョンの状況に合わせて作業内容を見直しながら行った.

== ビルドのための設定

* PCRE をインストールした.
    # apt-get install libpcre3 libpcre3-dev

* ソースを取得・展開した.
  * apache の最新バージョンを ((<URL:http://httpd.apache.org/>)) から確認し, 取得・展開した.  
  ※ 2018 年 11 月 05 日時点の最新バージョンは 2.4.37 である.
  * apache2.4.x では apr と apr-util を別途用意する必要が有るため, ((<URL: http://apr.apache.org/download.cgi/>)) から最新版を取得し, 展開した. (参照: ((<URL: http://weblabo.oscasierra.net/install-apache24-1/>)))

     # cd /usr/local/src
     # wget http://ftp.tsukuba.wide.ad.jp/software/apache//httpd/httpd-2.4.37.tar.gz
     # wget http://ftp.jaist.ac.jp/pub/apache/apr/apr-1.6.5.tar.gz
     # wget http://ftp.jaist.ac.jp/pub/apache/apr/apr-util-1.6.1.tar.gz
    

* apr, apr-util のインストール
  * インストール先と configure の際につけたオプションは以下の通りで ある.

         # tar xzf apr-1.6.3.tar.gz
         # cd apr-1.6.3
         #  ./configure
         # make
         # make install

         # cd /usr/local/src
         # tar xzf apr-util-1.6.1.tar.gz
         # cd apr-util-1.6.1
         # sudo ./configure --with-apr=/usr/local/apr
         # make
         # make install

* expat のインストール
  * このままでは expat.h がないため make でエラーが出るので, 手動で expat.h を含むパッケージを取得した. Expat をソースからインストール : https://ja.osdn.net/projects/sfnet_expat/releases/

     # cd /usr/local/src
     # wget https://ja.osdn.net/projects/sfnet_expat/downloads/expat/2.2.6/expat-2.2.6.tar.bz2
     # tar xvf expat-2.2.6.tar.bz2
     # cd expat-2.2.6
     # ./configure --prefix=/usr/local/expat
     # make
     # make install

     # cd /usr/local/src
     # tar xvzf httpd-2.4.37.tar.gz
     # cd httpd-2.4.37


* httpd のインストール
  * configure オプション (: 目的)
    * --enable-ssl  (: apache-ssl を動作させるため)
    * --enable-rewrite (: mod_rewrite を使用するため)
      * gate の登録窓口を http から https へ移動させたい  
    * --enable-so (: DSO (Dynamic shared object: 動的共有オブジェクト) を使用するため)
    * --with-included-apr (: ビルド時に "Cannot use an external APR-util with  the bundled APR" とエラーが生じる場合があるため)
    
   # ./configure --enable-ssl --enable-rewrite --enable-so --with-apr=/usr/local/apr
  
  * なお, インストール先は /usr/local/apache2 (apache2 のデフォルト)
    *  configure の際に --prefix の設定は不要
  * configure の結果は config.log を参照し, 問題ないか確認した.
  
== ビルドとインストール

# make
# make install

* /usr/local/apache2 の下に以下のディレクトリが作成されていることを確認した.

XXXX@xxx-itpass:/usr/local/apache2# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules

== 実行ファイルへのパスの設定

* インストールされた Apache のバイナリファイル群へパスを通す.
  * ((<[ITPASS2017]パスの設定>)) の((* <一般ユーザ用コマンドのパス> *)) と ((* <システム管理用コマンドのパス> *)) の両方に ((*/usr/local/apache2/bin*)) を追加する. (システム管理用コマンドも一般ユーザ用コマンドと同じ場所にインストールされているため, システム管理用コマンドの設定を別途行う必要は無い).
  * 具体的には, 以下のようにする.
    * /etc/bash.bashrc の末尾に

       # add PATH for local installed softwares
       PATH="${PATH}:/usr/local/apache2/bin"
       # add PATH for local installed softwares (for root)
       if [ "`id -u`" -eq 0 ]; then
       PATH="${PATH}:/usr/local/apache2/bin"
       fi
       export PATH

      を追加した.

    * /etc/csh.cshrc の末尾に

       # add PATH for local installed softwares
       set path = ($path /usr/local/bin /usr/bin /bin /usr/local/apache2/bin)
       # add PATH for local installed softwares (for root)
       if ( "`id -u`" == 0 ) then
       set path = ($path /usr/local/sbin /usr/sbin /sbin /usr/local/apache2/bin)
       endif
    
      を追加した.

    * /etc/zsh/zshenv の末尾に

       # add PATH for local installed softwares
       export PATH="$PATH:/usr/local/apache2/bin”
       # add PATH for local installed softwares (for root)
       if [ "`id -u`" -eq 0 ]; then
         export PATH="$PATH:/usr/local/apache2/bin”
       fi
       # delete duplicated path setting
       typeset -U path

      の記述を追加した.


== マニュアルへのパスの設定

* インストールされた Apache のマニュアル群へパスを通した.
  * /etc/manpath.config に以下の行を追加する. 詳しくは ((<[ITPASS2017]パスの設定#man 関連のパスの設定>)) を参照.

     MANDATORY_MANPATH                          /usr/local/apache2/man
     MANPATH_MAP        /usr/local/apache2/bin  /usr/local/apache2/man
     MANDB_MAP          /usr/local/apache2/man  /usr/local/apache2/man

== モジュールの確認, 追加

* インストールした apache2 で有効になっているモジュールを確認した.

   # /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES

  * 結果, 以下の3つが最低限有効になっていないことを確認した.
    * ssl_module
    * rewrite_module
    * userdir_module

* 有効になっていなかったので, 以下のように対処する.
  * DSO(Dynamic Shared Object) を有効にしているので (configure 時に --enable-so をつけた), モジュールを追加する.

#* apxs コマンドのパスを設定していないため, 実行できなかった. 以後 apxs コマンドを使用する際は場所を指定した.
    * mod_rewrite

       # /usr/local/apache2/bin/apxs -i -a -n rewrite mod_rewrite.la

    * mod_ssl

       # cd /usr/local/src/httpd-2.4.37/modules/ssl
       # /usr/local/apache2/bin/apxs -c mod_ssl.c
       # /usr/local/apache2/bin/apxs -i -a -c -I /usr/include/openssl -I ../md -D HAVE_OPENSSL=1 -lcrypto -lssl *.c

      * 参考: ((<URL: http://kamiyasu2.blog.fc2.com/blog-entry-22.html>))

    * mod_userdir

       # cd /usr/local/src/httpd-2.4.37/modules/mappers
       # /usr/local/apache2/bin/apxs -c mod_userdir.c
       # /usr/local/apache2/bin/apxs -i -a -n userdir mod_userdir.la

* モジュールが正しく追加されたかを確認した.

   # /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES


== 設定ファイルの編集

以下の設定ファイルを編集した. 編集はバックアップを取ってからコピーアンドペーストで行った.

* httpd 用
  * /usr/local/apache2/conf/httpd.conf
* httpd-ssl
  * /usr/local/apache2/conf/extra/httpd-ssl.conf
* 各ユーザの public_html 以下の設定用
  * /usr/local/apache2/conf/extra/httpd-userdir.conf

変更の要点は以下の通りである(以下は変更点の概要であり, 実際に行った作業はこのあとに記述).

* httpd.conf
  * HTTP デーモンを起動するユーザを www-data にする
  * サーバ管理者 (ServerAdmin) のメールアドレスを設定
  * サーバ名 (ServerName) を設定
  * サーバのデフォルトルート (DefaultRoot) を /~itpass に設定
  * ディレクトリのインデックスファイルに index.html 以外に
    index.htm index.htm.en index.html.en index.htm.ja index.html.ja
    も追加.
  * エラーログファイルを /var/log/httpd-error.log に設定
  * アクセスログファイルを /var/log/httpd-access.log に設定
  * CGI に関する設定を変更
  * extra/httpd-vhosts.confをロード
  * extra/httpd-userdir.conf をロード
  * extra/httpd-ssl.conf をロード
  * /~gate, および /cgi-bin に対するアクセスを HTTPS へ移動させる.
  * hiki.cgi の置かれた場所で設定したすべての設定値の変更を, 下位のディレクトリで変更できるようにする.
  * hiki-IPtable 以外では, mod_negotiation によるコンテントネゴシエーションされた "MultiViews" を許可する.

* httpd-vhosts.conf
  * {epa,aoe}.scitec.kobe-u.ac.jp 宛の接続を受ける (virtual host)
    * ドキュメントルートは /home/{epalab,aoelab}/public_html にする
    * 管理者メールアドレスは itpadmin _at_ ... にする
    * http://{epa,aoe}.scitec.kobe-u.ac.jp/~gate/ 以下に対するアクセスを https://itpass.scitec.kobe-u.ac.jp/~gate に移動させる
  * http://itpass.scitec.kobe-u.ac.jp/{/hiki,/~epalab/hiki,/~itpass/hiki} に対するアクセスのみ HTTPS へ移動させる. その際, URI のエンコードは行わない.  

* httpd-userdir.conf
  * 所有者がマッチしなくてもシンボリックリンクの公開を許可する.

* httpd-ssl.conf
  * ドキュメントルート (DocumentRoot),
    サーバ名 (ServerName),
    サーバ管理者アドレス (ServerAdmin),
    エラーログ (ErrorLog),
    アクセスログ (TransferLog) を設定する
  * epa.scitec, aoe.scitec の場合の https 接続を設定する

# * 設定ファイルのところどころにメールアドレスを指定する項目がある.
#   * 以下の diff では "_at_" となっているが, 実際にファイルを書き換える際にはすべて "@" に読み替えて書き換える.

== オリジナルとの diff
確認のため, ika にある同じファイルと diff を取って作業する.
本日はhttpd-ssl.conf については httpd.conf を確認するところまで完了した. 残りSSL 証明書の作成の際に再編集するため, 該当する箇所については 3 つのファイルについての確認は明日以降に行うika にあるファイルと異なったままにしておいた.



=== httpd.conf

root@tako-itpass:/usr/local/apache2/conf# sudo diff -u original/httpd.conf   httpd.conf
--- original/httpd.conf 2017-11-06 16:10:31.924741417 +0900
+++ httpd.conf  2017-11-06 19:11:06.873306079 +0900
@@ -82,7 +82,7 @@
  #LoadModule auth_digest_module modules/mod_auth_digest.so
  #LoadModule allowmethods_module modules/mod_allowmethods.so
  #LoadModule file_cache_module modules/mod_file_cache.so
-#LoadModule cache_module modules/mod_cache.so
+LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
@@ -129,7 +129,7 @@
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
-#LoadModule ssl_module modules/mod_ssl.so
+LoadModule ssl_module modules/mod_ssl.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
@@ -139,16 +139,16 @@
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule info_module modules/mod_info.so
-#LoadModule cgid_module modules/mod_cgid.so
+LoadModule cgid_module modules/mod_cgid.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
-#LoadModule negotiation_module modules/mod_negotiation.so
+LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
-#LoadModule userdir_module modules/mod_userdir.so
+LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
-#LoadModule rewrite_module modules/mod_rewrite.so
+LoadModule rewrite_module modules/mod_rewrite.so

<IfModule unixd_module>
#
@@ -157,10 +157,10 @@
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
-# running httpd, as with most system services.
+# runningehttpdi a/mod_rewrite.so with most system services.
#
-User daemon
-Group daemon
+User www-data
+Group www-data

</IfModule>

@@ -181,7 +181,7 @@
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
-ServerAdmin you@example.com
+ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp

#
# ServerName gives the name and port that the server uses to identify itself.
@@ -190,7 +190,7 @@
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
-#ServerName www.example.com:80
+ServerName itpass.scitec.kobe-u.ac.jp:80

#
# Deny access to the entirety of your server's filesystem. You must
@@ -214,8 +214,8 @@
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
-DocumentRoot "/usr/local/apache2/htdocs"
-<Directory "/usr/local/apache2/htdocs">
+DocumentRoot "/home/itpass/public_html"
+<Directory "/home/itpass/public_html">
     #
     # Possible values for the Options directive are "None", "All",
     # or any combination of:
@@ -237,6 +237,7 @@
     #
     AllowOverride None

+    Order deny,allow
     #
     # Controls who can get stuff from this server.
     #
@@ -248,7 +249,7 @@
# is requested.
#
<IfModule dir_module>
-    DirectoryIndex index.html
+    DirectoryIndex index.html index.htm index.htm.en index.html.en index.htm.ja index.html.ja
</IfModule>

#
@@ -266,7 +267,7 @@
# 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 "logs/error_log"
+ErrorLog "/var/log/httpd-error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
@@ -295,13 +296,13 @@
     # define per-<VirtualHost> access logfiles, transactions will be
     # logged therein and *not* in this file.
     #
-    CustomLog "logs/access_log" common
+    # CustomLog "logs/access_log" common

     #
     # If you prefer a logfile with access, agent, and referer information
     # (Combined Logfile Format) you can use the following directive.
     #
-    #CustomLog "logs/access_log" combined
+    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
@@ -340,16 +341,16 @@
     # ScriptSock: On threaded servers, designate the path to the UNIX
     # socket used to communicate with the CGI daemon of mod_cgid.
     #
-    #Scriptsock cgisock
+    Scriptsock cgisock
</IfModule>

#
# "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
-<Directory "/usr/local/apache2/cgi-bin">
-    AllowOverride None
-    Options None
+<Directory "/usr/local/apache2/cgi-bin/">
+    AllowOverride AuthConfig Limit
+    Options +ExecCGI +FollowSymLinks +IncludesNoExec
     Require all granted
</Directory>

@@ -395,7 +396,7 @@
     # To use CGI scripts outside of ScriptAliased directories:
     # (You will also need to add "ExecCGI" to the "Options" directive.)
     #
-    #AddHandler cgi-script .cgi
+    AddHandler cgi-script .cgi

     # For type maps (negotiated resources):
     #AddHandler type-map var
@@ -464,16 +465,16 @@
#Include conf/extra/httpd-autoindex.conf

# Language settings
-#Include conf/extra/httpd-languages.conf
+Include conf/extra/httpd-languages.conf

# User home directories
-#Include conf/extra/httpd-userdir.conf
+Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
-#Include conf/extra/httpd-vhosts.conf
+Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf
@@ -482,7 +483,7 @@
#Include conf/extra/httpd-dav.conf

# Various default settings
-#Include conf/extra/httpd-default.conf
+#Include conf/extra/httpd-none.conf

# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
@@ -490,7 +491,7 @@
</IfModule>

# Secure (SSL/TLS) connections
-#Include conf/extra/httpd-ssl.conf
+Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
@@ -500,4 +501,73 @@
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
+ #
+# Setting for Hiki Area
+#
+<Directory "/home/epalab/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/itpass/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>

+<Directory "/home/aoelab/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/chikuwa2/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/chikuwa3/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+
+<Directory "/home/itpass/public_html/hiki-secret">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/uwabami/public_html/hiki">
+ AllowOverride FileInfo AuthConfig Limit Indexes  Options=ExecCGI,FollowSymlinks
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/bldg3/public_html/hiki">
+ AllowOverride ALL
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/fourtran/public_html/hiki">
+ AllowOverride FileInfo AuthConfig Limit Indexes   Options=ExecCGI,FollowSymlinks
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/itpass/public_html/hiki-IPtable">
+ AllowOverride ALL
+</Directory>
+</Directory>
+
+<Directory "/home/yot/public_html/hiki">
+ AllowOverride FileInfo AuthConfig Limit Indexes Options=ExecCGI, FollowSymlinks    ## apache 起動時のエラー発生原因 'Indexes Options=ExecCGI' を 'IndexesOptions=ExecCGI' へ変更
+</Directory>
+
+<Directory "/home/okazakis/public_html/hiki">
+ AllowOverride FileInfo AuthConfig Limit Indexes Options=ExecCGI,FollowSymlinks
+ Options -MultiViews
+</Directory>
+
+<Directory "/home/shiojich/public_html/hiki">
+ AllowOverride FileInfo AuthConfig Limit Indexes Options=ExecCGI,FollowSymlinks
+ Options -MultiViews
+</Directory>
+# uncomment out the below to deal with user agents that deliberately
+ # violate open standerds by misusing DNT (DNT *must* be a specific
+ # end-user choice)

ectory>


=== extra/httpd-ssl.conf

root@tako-itpass:/usr/local/apache2/conf/extra# sudo diff -u ../original/extra/h
ttpd-ssl.conf httpd-ssl.conf
--- ../original/extra/httpd-ssl.conf    2017-11-06 16:10:31.988743325 +0900
+++ httpd-ssl.conf      2017-11-06 19:35:19.024717195 +0900
@@ -49,8 +49,9 @@
#   ensure these follow appropriate best practices for this deployment.
#   httpd 2.2.30, 2.4.13 and later force-disable aNULL, eNULL and EXP ciphers,
#   while OpenSSL disabled these by default in 0.9.8zf/1.0.0r/1.0.1m/1.0.2a.
-SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
-SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
+#SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
+SSLCipherSuite  ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3 DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSSECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
+SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4

#  By the end of 2016, only TLSv1.2 ciphers should remain in use.
#  Older ciphers should be disallowed as soon as possible, while the
@@ -70,6 +71,7 @@
#   must be the prerogative of the web server administrator who manages
#   cpu load versus confidentiality, so enforce the server's cipher order.
SSLHonorCipherOrder on
+SSLCompressopn +SSLCompression off   # apache 起動時のエラー発生原因 'SSLCompressopn off' を 'SSLCompression off' へ変更

#   SSL Protocol support:
#   List the protocol versions which clients are allowed to connect with.
@@ -89,7 +91,7 @@
#   Configure the SSL Session Cache: First the mechanism
#   to use and second the expiring timeout (in seconds).
#SSLSessionCache         "dbm:/usr/local/apache2/logs/ssl_scache"
-SSLSessionCache        "shmcb:/usr/local/apache2/logs/ssl_scache(512000)"
+#SSLSessionCache        "shmcb:/usr/local/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

#   OCSP Stapling (requires OpenSSL 0.9.8h or later)
@@ -118,19 +120,20 @@
## SSL Virtual Host Context
##

-<VirtualHost _default_:443>
+# NameVirtualHost *:443
+<VirtualHost *:443>

#   General setup for the virtual host
-DocumentRoot "/usr/local/apache2/htdocs"
-ServerName www.example.com:443
-ServerAdmin you@example.com
-ErrorLog "/usr/local/apache2/logs/error_log"
-TransferLog "/usr/local/apache2/logs/access_log"
+DocumentRoot "/home/itpass/public_html"
+ServerName itpass.scitec.kobe-u.ac.jp:443
+ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp
+ErrorLog "/var/log/httpd-ssl-error.log"
+TransferLog "/var/log/httpd-ssl-access.log"

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
-
+SSLProtocol all -SSLv2 -SSLv3
#   Server Certificate:
#   Point SSLCertificateFile at a PEM encoded certificate.  If
#   the certificate is encrypted, then you will be prompted for a
@@ -141,7 +144,7 @@
#   Some ECC cipher suites (http://www.ietf.org/rfc/rfc4492.txt)
#   require an ECC certificate which can also be configured in
#   parallel.
-SSLCertificateFile "/usr/local/apache2/conf/server.crt"
+SSLCertificateFile "/usr/local/apache2/conf/ca/itpass/itpass.crt"
#SSLCertificateFile "/usr/local/apache2/conf/server-dsa.crt"
#SSLCertificateFile "/usr/local/apache2/conf/server-ecc.crt"

@@ -151,7 +154,7 @@
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
#   ECC keys, when in use, can also be configured in parallel
-SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
+SSLCertificateKeyFile "/usr/local/apache2/conf/ca/itpass/itpass.key"
#SSLCertificateKeyFile "/usr/local/apache2/conf/server-dsa.key"
#SSLCertificateKeyFile "/usr/local/apache2/conf/server-ecc.key"

@@ -162,7 +165,7 @@
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convenience.
-#SSLCertificateChainFile "/usr/local/apache2/conf/server-ca.crt"
+#SSLCertificateChainFile "/usr/local/apache2/conf/server.crt"

#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
@@ -287,4 +290,36 @@
CustomLog "/usr/local/apache2/logs/ssl_request_log" \
           "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

-</VirtualHost>
+</VirtualHost>
+
+<VirtualHost *:443>
+DocumentRoot "/home/aoelab/public_html"
+ServerName aoe.scitec.kobe-u.ac.jp:442
+ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp
+ErrorLog /var/log/httpd-ssl-error.log
+TransferLog /var/log/httpd-ssl-access.log
+SSLEngine on
+#SSLCipherSuite   ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:!SSLv2:!SSLv3:+EXP:+eNULL
+SSLCipherSuite  ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3 DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSSECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
+SSLCertificateFile "/usr/local/apache2/conf/ca/aoe/aoe.crt""/usr/local/apache2/conf/ca/aoe/aoe.crt
+SSLCertificateKeyFile "/usr/local/apache2/conf/ca/aoe/aoe.key"
+SSLProtocol all -SSLv2 -SSLv3
+SSLHonorCipherOrder On
+SSLCompression Off
+</VirtualHost>
+
+<VirtualHost *:443>
+DocumentRoot "/home/epalab/public_html"
+ServerName epa.scitec.kobe-u.ac.jp:443
+ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp
+ErrorLog /var/log/httpd-ssl-error.log
+TransferLog /var/log/httpd-ssl-access.log
+SSLEngine on
+#SSLCipherSuite  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:!SSLv2:!SSLv3:+EXP:+eNULL
+SSLCipherSuite  ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3 DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSSECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
+SSLCertificateFile "/usr/local/apache2/conf/ca/epa/epa.crt"
+SSLCertificateKeyFile "/usr/local/apache2/conf/ca/epa/epa.key"
+SSLProtocol all -SSLv2 -SSLv3
+SSLHonorCipherOrder On
+SSLCompression Off
+</VirtualHost>



=== extra/httpd-vhosts.conf

root@tako-itpass:/usr/local/apache2/conf/extra# sudo diff -u ../original/extra/httpd-vhosts.conf httpd-vhosts.conf
--- ../original/extra/httpd-vhosts.conf 2017-11-06 16:10:32.004743801 +0900
+++ httpd-vhosts.conf   2017-11-06 19:59:00.303859738 +0900
@@ -21,21 +21,74 @@
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
-    ServerAdmin webmaster@dummy-host.example.com
-    DocumentRoot "/usr/local/apache2/docs/dummy-host.example.com"
-    ServerName dummy-host.example.com
-    ServerAlias www.dummy-host.example.com
-    ErrorLog "logs/dummy-host.example.com-error_log"
-    CustomLog "logs/dummy-host.example.com-access_log" common
+ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp
+    DocumentRoot "/home/itpass/public_html"
+    ServerName itpass.scitec.kobe-u.ac.jp
+    ErrorLog "/var/log/httpd-error.log"
+    CustomLog "/var/log/httpd-access.log" combined
+    <IfModule mod_rewrite.c>
+      RewriteEngine On
+#      RewriteLog "/var/log/httpd-rewrite.log"
+#      RewriteLogLevel 0
+      LogLevel alert rewrite:trace1
+      RewriteCond %{SERVER_PORT} !^443$
+      RewriteRule ^/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/hiki/$1 [L,R,NE]
+      RewriteRule ^/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/hiki-secret/$1 [L,R,NE]
+      # ---- hiki
+      RewriteRule ^/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/hiki/$1 [L,R,NE]
+      RewriteRule ^/~bldg3/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~bldg3/hiki/$1 [L,R,NE]
+      RewriteRule ^/~epalab/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~epalab/hiki/$1 [L,R,NE]
+      RewriteRule ^/~itpass/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~itpass/hiki/$1 [L,R,NE]
+      RewriteRule ^/~itpass/hiki-secret/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~itpass/hiki-secret/$1 [L,R,NE]
+      # ---- gate
+      RewriteRule ^/~gate/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~gate/$1 [L,R,NE]
+      RewriteRule ^/cgi-bin/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/cgi-bin/$1 [L,R,NE]
+    </IfModule>
</VirtualHost>

+# ---- aoelab ----
+
<VirtualHost *:80>
-    ServerAdmin webmaster@dummy-host2.example.com
-    DocumentRoot "/usr/local/apache2/docs/dummy-host2.example.com"
-    ServerName dummy-host2.example.com
-    ErrorLog "logs/dummy-host2.example.com-error_log"
-    CustomLog "logs/dummy-host2.example.com-access_log" common
+
</VirtualHost>


+erverAdmin +ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp  # apache 起動時のエラー発生原因 'erverAdmin' を 'ServerAdmin' へ変更
+        DocumentRoot "/home/aoelab/public_html"
+        ServerName aoe.scitec.kobe-u.ac.jp
+        ErrorLog "/var/log/httpd-error.log"
+        CustomLog "/var/log/httpd-access.log" combined
+        <IfModule mod_rewrite.c>
+          RewriteEngine On
+#          RewriteLog "/var/log/httpd-rewrite.log"
+#          RewriteLogLevel 0
+          LogLevel alert rewrite:trace1
+          RewriteCond %{SERVER_PORT} !^443$
+          # ---- hiki
+          RewriteRule ^/hiki/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/hiki/$1 [L,R]
+          # ---- gate
+          RewriteRule ^/~gate/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/~gate/$1 [L,R,NE]
+          RewriteRule ^/cgi-bin/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/cgi-bin/$1 [L,R,NE]
+        </IfModule>
+</VirtualHost>

+# ---- epalab ----
+<VirtualHost *:80>
+    ServerAdmin itpadmin@itpass.scitec.kobe-u.ac.jp
+    DocumentRoot "/home/epalab/public_html"
+    ServerName epa.scitec.kobe-u.ac.jp
+    ErrorLog /var/log/httpd-error.log
+    CustomLog /var/log/httpd-access.log combined
+    <IfModule mod_rewrite.c>
+      RewriteEngine On
+#      RewriteLog "/var/log/httpd-rewrite.log"
+#      RewriteLogLevel 0
+      LogLevel alert rewrite:trace1
+      RewriteCond %{SERVER_PORT} !^443$
+      # ---- hiki
+      RewriteRule ^/hiki/(.*)?$ https://epa.scitec.kobe-u.ac.jp/hiki/$1 [L,R,NE]
+      # ---- gate
+      RewriteRule ^/~gate/(.*)?$ https://itpass.scitec.kobe-u.ac.jp
+      RewriteRule ^/cgi-bin/(.*)?$ https://itpass.scitec.kobe-u.ac.jp/cgi-bin/$1 [L,R,NE]
+    </IfModule>
+ </VirtualHost>



=== extra/httpd-userdir.conf

root@tako-itpass:/usr/local/apache2/conf/extra# sudo diff -u ../original/extra/httpd-userdir.conf httpd-userdir.conf
--- ../original/extra/httpd-userdir.conf        2017-11-06  16:10:31.996743563   +0900
+++ httpd-userdir.conf  2017-11-06 20:03:22.837291051 +0900
@@ -15,7 +15,14 @@
#
<Directory "/home/*/public_html">
     AllowOverride FileInfo AuthConfig Limit Indexes
-    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
+    Options MultiViews Indexes FollowSymLinks IncludesNoExec
     Require method GET POST OPTIONS
+   <IfModule negotiation_module>
+        AddLanguage ja .ja
+        AddLanguage ja-JP .ja
+        AddLanguage en .en
+        LanguagePriority en ja
+        ForceLanguagePriority Prefer Fallback
+    </IfModule>
</Directory>

= ログローテートの設定

* /etc/logrotate.conf を編集して圧縮オプションを追加する.
  * compressのコメントアウトを外す.
  
* /etc/logrotate.d/ 以下に apache2 ファイルをつくり, 以下の内容を書き込む.
  
    /var/log/httpd-access.log {
        missingok
        weekly
        rotate 12
        postrotate
            /usr/bin/killall -HUP httpd 2> /dev/null || true
        endscript
    }
  
    /var/log/httpd-error.log {
        delaycompress
        missingok
        weekly
        rotate 12
        postrotate
            /usr/bin/killall -HUP httpd 2> /dev/null || true
        endscript
    }
  
    /var/log/httpd-ssl-access.log {
        missingok
        weekly
        rotate 12
        postrotate
            /usr/bin/killall -HUP httpd 2> /dev/null || true
        endscript
    }
  
    /var/log/httpd-ssl-error.log {
        missingok
        weekly
        rotate 12
        postrotate
            /usr/bin/killall -HUP httpd 2> /dev/null || true
        endscript
    }