Apache HTTP のインストールはいつでも楽しいものです。数日前、CentOS VM に Apache 2.4 をインストールしていたところ、 複数のエラー が発生しました。
参考になればと思いまとめてみました。

APRが見つかりません
[root@chandan httpd-2.4.25]# ./configure --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@chandan httpd-2.4.25]#
APR は「Apache Portable Runtime」の略で、ソースからコンパイルする必要があります。私と同じ状況に陥った場合は、フォローしていただくと 救われ ます。
まず 、APR をインストールする必要があります。
- wget を使用して APR の最新バージョンをダウンロードする
wget https://www-eu.apache.org/dist/apr/apr-1.6.3.tar.gz .
- ダウンロードしたファイルを解凍します
gunzip -c apr-1.6.3.tar.gz | tar xvf -
- 新しいフォルダー「 apr-1.6.3 」が作成されます。
- 中に入ってconfigureコマンドでコンパイルします
./configure
数秒かかりますが、完了するとプロンプトが表示されます (エラーがないことを確認してください)。
- 最後のステップは、make コマンドを使用してインストールすることです。
make
make install
完了後、Apacheをインストールしようとしましたが、別のエラーが発生しました。

APR-util が見つかりません
[root@chandan httpd-2.4.25]# ./configure --enable-ssl --enable-so
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
[root@chandan httpd-2.4.25]#
「APR-util not found」エラーが発生する場合は、 次のファイルをインストールする 必要があります。
- 最新の APR-util ソースをダウンロードする
wget https://www-eu.apache.org/dist/apr/apr-util-1.6.1.tar.gz .
- ダウンロードしたgzファイルを解凍します。
gunzip -c apr-util-1.6.1.tar.gz | tar xvf -
- 新しく作成したフォルダー「apr-util-1.6.1」内に移動し、次のコマンドを使用してインストールします。
./configure --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
Apacheを再度インストールしようとしましたが、別のエラーが発生しました。

libpcre の pcre-config が見つかりません
これが私が得たものです。
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found . PCRE is required and available from http://pcre.org/
PCRE は Perl 互換正規表現の略で、このエラーは 簡単に解決 されました。 pcre-devel パッケージをインストールするだけです。
yum install pcre-devel
まだ終わっていないので、OpenSSL に関連する次の試行で別のものを取得します。

OpenSSLのバージョンが古すぎます
checking whether to enable mod_slotmem_plain... no
checking whether to enable mod_ssl... checking dependencies
checking for OpenSSL... checking for user-provided OpenSSL base directory... ./configure: line 25426: cd: /usr/bin/openssl: Not a directory
/root/httpd-2.4.25
adding "-I/root/httpd-2.4.25/include" to CPPFLAGS
setting MOD_CFLAGS to "-I/root/httpd-2.4.25/include"
setting ab_CFLAGS to "-I/root/httpd-2.4.25/include"
adding "-L/root/httpd-2.4.25/lib" to LDFLAGS
setting MOD_LDFLAGS to "-L/root/httpd-2.4.25/lib"
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
[root@chandan httpd-2.4.25]#
まず、最新バージョンの OpenSSL を使用していることを確認する必要があります。私の場合は、 devel パッケージを インストールする必要がありましたが、問題ありませんでした。
yum install openssl-devel

xml/apr_xml.c:35:19: 致命的なエラー: expat.h: そのようなファイルまたはディレクトリはありません
APR をコンパイル中に、このエラーが発生しました。
[root@instance-1 apr-util-1.6.1]# make
make[1]: Entering directory `/opt/temp/apr-util-1.6.1'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/opt/temp/apr-util-1.6.1/include -I/opt/temp/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#include
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
このエラーが発生した場合は、
expat-devel
パッケージをインストールすることで解決できます。
yum install expat-devel
構成: エラー: $PATH に受け入れ可能な C コンパイラーが見つかりません
C コンパイラーが見つからないという問題は、どのソフトウェア ビルドでもよく見られる問題であり、コンパイラーをインストールすることでこれを修正できます。
yum install gcc
nghttp2のバージョンが古すぎます
これは、HTTP/2 を使用して Apache をインストールしようとする場合に特有です。次のエラーが表示されます。
checking whether to enable mod_http2... checking dependencies
checking for OpenSSL... (cached) yes
setting MOD_LDFLAGS to " -lssl -lcrypto -lrt -lcrypt -lpthread"
setting MOD_CFLAGS to " "
setting MOD_CPPFLAGS to "-DH2_OPENSSL"
checking for nghttp2... checking for user-provided nghttp2 base directory... none
checking for pkg-config along ... checking for nghttp2 version >= 1.2.1... FAILED
configure: WARNING: nghttp2 version is too old
no
checking whether to enable mod_http2... configure: error: mod_http2 has been requested but can not be built due to prerequisite failures
その場合は、以下のように nghttp2 をインストールすることで修正できます。
- ここ から nghttp2 の最新バージョンをダウンロードします
wget https://github.com/nghttp2/nghttp2/releases/download/v1.37.0/nghttp2-1.37.0.tar.gz
- ダウンロードしたファイルを解凍します
tar -xvf nghttp2-1.37.0.tar.gz
- 新しいフォルダーが作成され、その中に移動して次のコマンドを実行します。
./configure
make
make install
エラーが発生せずに完了したら、HTTP2 を使用して Apache ソース ビルドを再度実行します。大丈夫ですよ。
ようやくApacheをインストールすることができました。 Apache HTTP サーバー管理について学習することに興味がある場合は、この オンライン コース を確認してください。