さくらVPSのCentOS8環境にApache httpd 2.4.43+HTTP/2+Brotliを入れてみた

#涙のsshd
さくらVPSでCentOS8をカスタムインストールしました。

さぁ，Apache2.4.23+openssl1.1.1gをインストールしようとしたら…
毎回毎回，sshdがお亡くなりになる。

紆余曲折の末，いくつかのサイトを参考にしてなんとかなったのでその方法を備忘的に残しておきます。
特に参考にしたサイトは下にまとめておきました。というよりも，ほぼ，[あぱーブログ](https://blog.apar.jp/linux/13999)の通りにしています。ただ，opensslのインストール等，一部，あぱーブログ様の方法ではうまくいかなかったので修正しています。

#openssl 1.1.1gのインストール

```
# dnf install -y zlib-devel perl-core jansson-devel libev-devel c-ares-devel cmake pcre-devel expat-devel lksctp-tools lksctp-tools-devel 
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
# tar xvzf openssl-1.1.1g.tar.gz
# rm -f openssl-1.1.1g.tar.gz
# cd openssl-1.1.1g
# ./config --prefix=/usr/local shared zlib
# make
# make test
# make install
# ldconfig -v
```

上記インストール後，`/usr/local/bin/openssl version -a`とすると

```
OpenSSL 1.1.1g  21 Apr 2020 (Library: OpenSSL 1.1.1c FIPS  28 May 2019)
built on: Thu Apr  9 19:02:31 2020 UTC
platform: linux-x86_64
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) 
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wa,--noexecstack -Wa,--generate-missing-build-notes=yes -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG -DPURIFY -DDEVRANDOM="\"/dev/urandom\"" -DSYSTEM_CIPHERS_FILE="/etc/crypto-policies/back-ends/openssl.config"
OPENSSLDIR: "/etc/pki/tls"
ENGINESDIR: "/usr/lib64/engines-1.1"
Seeding source: os-specific
```
と出てきました。

また`/etc/ld.so.conf.d/`は作成していません。

#Nghttp2のインストール
```
# cd /usr/local/src/
# wget https://github.com/nghttp2/nghttp2/releases/download/v1.40.0/nghttp2-1.40.0.tar.gz
# tar xvzf nghttp2-1.40.0.tar.gz
# rm -f nghttp2-1.40.0.tar.gz
# cd nghttp2-1.40.0/
# env OPENSSL_CFLAGS="-I/usr/local/include" OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto" ./configure -enable-app
# make
# make install
```
#Brotli のインストール

```
# cd /usr/local/src/
# wget https://github.com/google/brotli/archive/v1.0.7.tar.gz
# tar xvzf v1.0.7.tar.gz
# rm -f v1.0.7.tar.gz
# cd brotli-1.0.7/
# mkdir out && cd out
# ../configure-cmake
# make
# make test
# make install
```

#中間仕上げ

```
echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf
ldconfig
```

#apacheのインストールへ
##お先にFirewallの設定

```
# firewall-cmd --permanent --add-service=http --zone=public
# firewall-cmd --permanent --add-service=https --zone=public
# firewall-cmd --reload

```



##APRのインストール

```
# cd /usr/local/src
# wget https://downloads.apache.org//apr/apr-1.7.0.tar.gz
# tar fxz apr-1.7.0.tar.gz
# rm -f apr-1.7.0.tar.gz
# cd apr-1.7.0
# ./configure --prefix=/usr/local/
# make
# make install
```

うまくいきました。

##APR-Utilのインストール

```
# cd /usr/local/src
# wget https://downloads.apache.org//apr/apr-util-1.6.1.tar.gz
# tar fxz apr-util-1.6.1.tar.gz
# rm -f apr-util-1.6.1.tar.gz
# cd apr-util-1.6.1
# ./configure --prefix=/usr/local/ --with-apr=/usr/local/
# make
# make install
```




##いよいよ本丸

apacheユーザーを作成

```
# groupadd apache
# useradd -g apache apache
```


```
# cd /usr/local/src/
# wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.43.tar.gz
# tar xvzf httpd-2.4.43.tar.gz
# cd httpd-2.4.43/
./configure \
--enable-layout=RedHat \
--enable-http2 \
--enable-brotli \
--with-brotli=/usr/local/lib \
--enable-ssl \
--with-ssl=/usr/local/ \
--with-apr=/usr/local/ \
--with-apr-util=/usr/local/ \
--enable-so \
--enable-mods-shared=all \
--enable-mpms-shared=all
# make
# make install
```
あぱーブログ様と買えたのは，`enable-layout=RedHat`の部分です。これがないと`/usr/local/apache2`にインストールされますが，これを入れておくと，`/usr`直下にインストールされます。また，

```
    prefix:        /usr
    exec_prefix:   ${prefix}
    bindir:        ${prefix}/bin
    sbindir:       ${prefix}/sbin
    libdir:        ${prefix}/lib
    libexecdir:    ${prefix}/lib/apache
    mandir:        ${prefix}/man
    sysconfdir:    /etc/httpd/conf
    datadir:       /var/www
    installbuilddir: ${datadir}/build
    errordir:      ${datadir}/error
    iconsdir:      ${datadir}/icons
    htdocsdir:     ${datadir}/html
    manualdir:     ${datadir}/manual
    cgidir:        ${datadir}/cgi-bin
    includedir:    ${prefix}/include/apache
    localstatedir: /var
    runtimedir:    ${localstatedir}/run
    logfiledir:    ${localstatedir}/log/httpd
    proxycachedir: ${localstatedir}/cache/httpd
```

となるので，他の解説ブログなどとも平仄を合わせられると思います。


#Apache httpd等の設定

httpd.confとhttpd-ssl.confをバックアップします。私の環境では，マルチドメイン環境で動かしており

- /var/www/html
   - /hogehogeA
   - /hogehogeB
 
という構造にしています。従って，httpd-vhosts.confもイジりました。
なお，HTTP/2 および Brotli は HTTPS が必須になるので，先にLet's Encryptで証明書を用意しました。証明書の用意については割愛いたします。

```
# cd /var/www/html
# mkdir hogehogeA
# mkdir hogehogeB
# chmod 755 /var/www/
# chmod 755 /var/www/html
# chmod 755 /var/www/html/hogehogeA
# chmod 755 /var/www/html/hogehogeB
# chown -R apache:apache /var/www/
```


##バックアップ

```
# cd /etc/httpd/conf/
# cp httpd.conf httpd.conf.org
# cp extra/httpd-ssl.conf extra/httpd-ssl.conf.org
# cp extra/httpd-vhosts.conf extra/httpd-ssl.vhost.org
```
##httpd.confの設定

設定ファイルをイジります。まずは`httpd.conf`からですが，デフォルトのユーザー・グループがdaemonであったのをapacheに変更しました。
あとは，`<Directory "var/www/html">`の中をイジっています。

```
# nano /etc/httpd/conf/httpd.conf
--------------------
ServerTokens Prod
ServerSignature Off
TraceEnable Off
AddDefaultCharset UTF-8
Header set X-XSS-Protection "1; mode=block"
Header always append X-Content-Type-Options nosniff

HostnameLookups Off
ServerRoot "/usr"

Listen 80
User apache
Group apache
ServerAdmin root@localhost
ServerName localhost:80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example: LoadModule foo_module modules/mod_foo.so
LoadModule mpm_event_module lib/apache/mod_mpm_event.so
#LoadModule mpm_prefork_module lib/apache/mod_mpm_prefork.so
#LoadModule mpm_worker_module lib/apache/mod_mpm_worker.so
LoadModule authn_file_module lib/apache/mod_authn_file.so
#LoadModule authn_dbm_module lib/apache/mod_authn_dbm.so
#LoadModule authn_anon_module lib/apache/mod_authn_anon.so
#LoadModule authn_dbd_module lib/apache/mod_authn_dbd.so
#LoadModule authn_socache_module lib/apache/mod_authn_socache.so
LoadModule authn_core_module lib/apache/mod_authn_core.so
LoadModule authz_host_module lib/apache/mod_authz_host.so
LoadModule authz_groupfile_module lib/apache/mod_authz_groupfile.so
LoadModule authz_user_module lib/apache/mod_authz_user.so
#LoadModule authz_dbm_module lib/apache/mod_authz_dbm.so
#LoadModule authz_owner_module lib/apache/mod_authz_owner.so
#LoadModule authz_dbd_module lib/apache/mod_authz_dbd.so
LoadModule authz_core_module lib/apache/mod_authz_core.so
LoadModule access_compat_module lib/apache/mod_access_compat.so
LoadModule auth_basic_module lib/apache/mod_auth_basic.so
#LoadModule auth_form_module lib/apache/mod_auth_form.so
#LoadModule auth_digest_module lib/apache/mod_auth_digest.so
#LoadModule allowmethods_module lib/apache/mod_allowmethods.so
#LoadModule file_cache_module lib/apache/mod_file_cache.so
#LoadModule cache_module lib/apache/mod_cache.so
#LoadModule cache_disk_module lib/apache/mod_cache_disk.so
#LoadModule cache_socache_module lib/apache/mod_cache_socache.so
LoadModule socache_shmcb_module lib/apache/mod_socache_shmcb.so
#LoadModule socache_dbm_module lib/apache/mod_socache_dbm.so
#LoadModule socache_memcache_module lib/apache/mod_socache_memcache.so
#LoadModule socache_redis_module lib/apache/mod_socache_redis.so
LoadModule watchdog_module lib/apache/mod_watchdog.so
#LoadModule macro_module lib/apache/mod_macro.so
#LoadModule dbd_module lib/apache/mod_dbd.so
#LoadModule dumpio_module lib/apache/mod_dumpio.so
#LoadModule echo_module lib/apache/mod_echo.so
#LoadModule buffer_module lib/apache/mod_buffer.so
#LoadModule data_module lib/apache/mod_data.so
#LoadModule ratelimit_module lib/apache/mod_ratelimit.so
LoadModule reqtimeout_module lib/apache/mod_reqtimeout.so
#LoadModule ext_filter_module lib/apache/mod_ext_filter.so
#LoadModule request_module lib/apache/mod_request.so
#LoadModule include_module lib/apache/mod_include.so
LoadModule filter_module lib/apache/mod_filter.so
#LoadModule reflector_module lib/apache/mod_reflector.so
#LoadModule substitute_module lib/apache/mod_substitute.so
#LoadModule sed_module lib/apache/mod_sed.so
#LoadModule charset_lite_module lib/apache/mod_charset_lite.so
LoadModule deflate_module lib/apache/mod_deflate.so
LoadModule brotli_module lib/apache/mod_brotli.so
LoadModule mime_module lib/apache/mod_mime.so
LoadModule log_config_module lib/apache/mod_log_config.so
#LoadModule log_debug_module lib/apache/mod_log_debug.so
#LoadModule log_forensic_module lib/apache/mod_log_forensic.so
#LoadModule logio_module lib/apache/mod_logio.so
LoadModule env_module lib/apache/mod_env.so
#LoadModule mime_magic_module lib/apache/mod_mime_magic.so
#LoadModule expires_module lib/apache/mod_expires.so
LoadModule headers_module lib/apache/mod_headers.so
#LoadModule usertrack_module lib/apache/mod_usertrack.so
#LoadModule unique_id_module lib/apache/mod_unique_id.so
LoadModule setenvif_module lib/apache/mod_setenvif.so
LoadModule version_module lib/apache/mod_version.so
#LoadModule remoteip_module lib/apache/mod_remoteip.so
#LoadModule proxy_module lib/apache/mod_proxy.so
#LoadModule proxy_connect_module lib/apache/mod_proxy_connect.so
#LoadModule proxy_ftp_module lib/apache/mod_proxy_ftp.so
#LoadModule proxy_http_module lib/apache/mod_proxy_http.so
#LoadModule proxy_fcgi_module lib/apache/mod_proxy_fcgi.so
#LoadModule proxy_scgi_module lib/apache/mod_proxy_scgi.so
#LoadModule proxy_uwsgi_module lib/apache/mod_proxy_uwsgi.so
#LoadModule proxy_fdpass_module lib/apache/mod_proxy_fdpass.so
#LoadModule proxy_wstunnel_module lib/apache/mod_proxy_wstunnel.so
#LoadModule proxy_ajp_module lib/apache/mod_proxy_ajp.so
#LoadModule proxy_balancer_module lib/apache/mod_proxy_balancer.so
#LoadModule proxy_express_module lib/apache/mod_proxy_express.so
#LoadModule proxy_hcheck_module lib/apache/mod_proxy_hcheck.so
#LoadModule session_module lib/apache/mod_session.so
#LoadModule session_cookie_module lib/apache/mod_session_cookie.so
#LoadModule session_dbd_module lib/apache/mod_session_dbd.so
#LoadModule slotmem_shm_module lib/apache/mod_slotmem_shm.so
#LoadModule slotmem_plain_module lib/apache/mod_slotmem_plain.so
LoadModule ssl_module lib/apache/mod_ssl.so
#LoadModule dialup_module lib/apache/mod_dialup.so
LoadModule http2_module lib/apache/mod_http2.so
#LoadModule lbmethod_byrequests_module lib/apache/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module lib/apache/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module lib/apache/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module lib/apache/mod_lbmethod_heartbeat.so
LoadModule unixd_module lib/apache/mod_unixd.so
#LoadModule heartbeat_module lib/apache/mod_heartbeat.so
#LoadModule heartmonitor_module lib/apache/mod_heartmonitor.so
#LoadModule dav_module lib/apache/mod_dav.so
LoadModule status_module lib/apache/mod_status.so
LoadModule autoindex_module lib/apache/mod_autoindex.so
#LoadModule asis_module lib/apache/mod_asis.so
#LoadModule info_module lib/apache/mod_info.so
#LoadModule cgid_module lib/apache/mod_cgid.so
#LoadModule dav_fs_module lib/apache/mod_dav_fs.so
#LoadModule dav_lock_module lib/apache/mod_dav_lock.so
#LoadModule vhost_alias_module lib/apache/mod_vhost_alias.so
#LoadModule negotiation_module lib/apache/mod_negotiation.so
LoadModule dir_module lib/apache/mod_dir.so
#LoadModule actions_module lib/apache/mod_actions.so
#LoadModule speling_module lib/apache/mod_speling.so
#LoadModule userdir_module lib/apache/mod_userdir.so
LoadModule alias_module lib/apache/mod_alias.so
#LoadModule rewrite_module lib/apache/mod_rewrite.so

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
#ServerAdmin you@example.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# 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 "/var/log/httpd/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "/var/log/httpd/access_log" common

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

<IfModule mpm_event_module>
    StartServers 3
    MinSpareThreads 75
    MaxSpareThreads 250
    ThreadsPerChild 25
    MaxRequestWorkers 400
    MaxConnectionsPerChild 0
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts. 
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock cgisock
</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule headers_module>
    #
    # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied
    # backend servers which have lingering "httpoxy" defects.
    # 'Proxy' request header is undefined by the IETF, not listed by IANA
    #
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/httpd/conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

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


#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile /etc/httpd/conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#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
#

#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited

#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
#EnableSendfile on

# Supplemental configuration
#
# The configuration files in the /etc/httpd/conf/extra/ directory can be 
# included to add extra features or to modify the default configuration of 
# the server, or you may simply copy their contents here and change as 
# necessary.

# Server-pool management (MPM specific)
#Include /etc/httpd/conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include /etc/httpd/conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include /etc/httpd/conf/extra/httpd-autoindex.conf

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

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

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

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


# Local access to the Apache HTTP Server Manual
#Include /etc/httpd/conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include /etc/httpd/conf/extra/httpd-dav.conf

# Various default settings
#Include /etc/httpd/conf/extra/httpd-default.conf

# Configure mod_proxy_html to understand HTML4/XHTML1

#<IfModule proxy_html_module>
#Include /etc/httpd/conf/extra/proxy-html.conf
#</IfModule>

# Secure (SSL/TLS) connections
Include /etc/httpd/conf/extra/httpd-ssl.conf
##
## Note: The following must must be present to support
##       starting without SSL on platforms with no /dev/random equivalent
##       but a statically compiled-in mod_ssl.
##
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>


```

##httpd-vhosts.confの設定

```
# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    DocumentRoot "/var/www/html/hogehogeA"
    ServerName hogehogeA.com
    ServerAlias www.hogehogeA.com
    AddDefaultCharset UTF-8
    <Directory "/var/www/html/hogehogeA">
	AllowOverride All
    </Directory>
    ErrorLog "/var/log/httpd/hogehogeA.com-error_log"
    CustomLog "/var/log/httpd/hogehogeA.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/html/hogehogeB"
    ServerName hogehogeB.com
    ServerAlias www.hogehogeB.com
    AddDefaultCharset UTF-8
    <Directory "/var/www/html/hogehogeB">
	AllowOverride All
    </Directory>
    ErrorLog "/var/log/httpd/hogehogeB.com-error_log"
    CustomLog "/var/log/httpd/hogehogeB.com-access_log" common
</VirtualHost>

```


##httpd-ssl.conf

Let's Encryptを使って証明書を発行していることを前提にしています。

`httpd-ssl.conf`をイジります。

```
--------------------
# nano /etc/httpd/conf/extra/httpd-ssl.conf
--------------------
Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/run/httpd/sslcache(1024000)"
SSLSessionCacheTimeout 3600
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
SSLStrictSNIVHostCheck off

SSLProtocol -all +TLSv1.2 +TLSv1.3

SSLCipherSuite "TLS_AES_128_GCM_SHA256 \
TLS_AES_256_GCM_SHA384 \
TLS_CHACHA20_POLY1305_SHA256 \
ECDHE-ECDSA-AES128-GCM-SHA256 \
ECDHE-ECDSA-AES256-GCM-SHA384 \
ECDHE-ECDSA-AES128-SHA \
ECDHE-ECDSA-AES256-SHA \
ECDHE-ECDSA-AES128-SHA256 \
ECDHE-ECDSA-AES256-SHA384 \
ECDHE-RSA-AES128-GCM-SHA256 \
ECDHE-RSA-AES256-GCM-SHA384 \
ECDHE-RSA-AES128-SHA \
ECDHE-RSA-AES256-SHA \
ECDHE-RSA-AES128-SHA256 \
ECDHE-RSA-AES256-SHA384 \
DHE-RSA-AES128-GCM-SHA256 \
DHE-RSA-AES256-GCM-SHA384 \
DHE-RSA-AES128-SHA \
DHE-RSA-AES256-SHA \
DHE-RSA-AES128-SHA256 \
DHE-RSA-AES256-SHA256 \
EDH-RSA-DES-CBC3-SHA"

SSLHonorCipherOrder on
SSLCompression off
#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
#SSLSessionCache         "dbm:/var/run/ssl_scache"
SSLSessionCache        "shmcb:/var/run/ssl_scache(512000)"
SSLSessionCacheTimeout  300

#SSLUseStapling On
#SSLStaplingCache shmcb:/run/httpd/stapling_cache(128000)

#hogehogeAの設定
<VirtualHost *:443>

    ServerName hogehogeA.com
    ServerAlias www.hogehogeA.com
    DocumentRoot /var/www/html/hogehogeA

    <Directory "/var/www/html/hogehogeA">
        Options FollowSymLinks
        AllowOverride All 
        Require all granted
    </Directory>


    SSLEngine on
    SSLHonorCipherOrder on
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
    SSLCertificateFile /etc/letsencrypt/live/hogehogeA.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/hogehogeA.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/hogehogeA.com/chain.pem

    SetEnvIf Request_URI "\.(gif|jpg|png|css|js)$" nolog
    ErrorLog "/var/log/httpd/hogehogeA.com-s-error_log"
    CustomLog "/var/log/httpd/hogehogeA.com-s-access_log" common
</VirtualHost>

#hogehogeBの設定
<VirtualHost *:443>

    ServerName hogehogeB.com
    ServerAlias www.hogehogeB.com
    DocumentRoot /var/www/html/hogehogeB

    <Directory "/var/www/html/hogehogeB">
        Options FollowSymLinks
        AllowOverride All 
        Require all granted
    </Directory>

    SSLEngine on
    SSLHonorCipherOrder on
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
    SSLCertificateFile /etc/letsencrypt/live/hogehogeB.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/hogehogeB.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/hogehogeB.com/chain.pem

    SetEnvIf Request_URI "\.(gif|jpg|png|css|js)$" nolog
    ErrorLog "/var/log/httpd/hogehogeB.com-s-error_log"
    CustomLog "/var/log/httpd/hogehogeB.com-s-access_log" common
</VirtualHost>
```






#httpd.serviceを設定にする

```
# nano /etc/systemd/system/httpd.service
--------------------------------------
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/sbin/apachectl start
ExecReload=/usr/sbin/apachectl graceful
ExecStop=/usr/sbin/apachectl stop
 [Install]
WantedBy=multi-user.target
--------------------------------------

# systemctl daemon-reload
# systemctl start httpd
# systemctl enable httpd
```


#終わりに
以上で，sshdがお亡くなりになることなく2.4.43+1.1.1gをインストールできました。
様々な記事を見て試行錯誤しながらでしたので自分の備忘録的にも記事にしておきます。



#参考にしたサイトの皆様
[Apache httpd 2.4.43（TLS1.3対応）+ HTTP/2 + Brotli インストールメモ](https://blog.apar.jp/linux/13999/)
[TLS1.3に対応したApache（httpd）のインストール・設定方法](https://hackers-high.com/linux/apache-tls13-installtion/)