2022年02月08日 13:27
$ lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
sela@selarabird:~$ lsb_release
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
make :コンパイルを指示するためのユーティリティ. 汎用の依存関係解決器
cmake :クロスプラットフォーム, オープンソースの make システム
gcc :GNU C コンパイラ.
build-essential :Debian パッケージのビルドに不可欠な情報リスト
libpcre3 :Old Perl 5 互換の正規表現 (PCRE) のランタイムファイルライブラリ
libpcre3-dev :PCRE の開発ファイル (ヘッダ, 静的ライブラリ, ドキュメント)
libssl-dev :SSL ツールキットの開発ファイル (ヘッダ, 静的ライブラリ, ドキュメント)
libexpat1-dev :ストリーム指向の XML パーサ Expat 用の C ライブラリ - 開発キット
libxml2-dev :開発用の GNOME XML ライブラリ
libcurl4-openssl-dev :libcurl (OpenSSSL フレーバ) の開発用ファイルとドキュメント
--with-openssl=/usr/lib/ssl
--with-crypto
--with-expat=/usr/lib/x86-64-linux-gnu
--enable-mpms-shared=all --enable-mods-shared=all
--enable-ssl
--with-included-apr
--with-apxs=/usr/local/apache2/bin/apxs
--with-apr=/usr/local/apache2/bin/apr-1-config
--with-apu=/usr/local/apache2/bin/apu-1-config
エラー: APR が見つからない。
configure: error: APR not found. Please read the documentation.
原因: Apache 2.4 から httpd のソースに APR が含まれなくなった。
解決策: APR 公式サイトから APR, APR-Util, APR iconv をダウンロードしてインストール。手元の環境では httpd ソースディレクトリの srclib/ に APR シリーズを配置して httpd の configure オプション「 --with-included-apr 」とともにコンパイル。
エラー: libpcre が見つからない。
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
原因: libpcre が未インストール。
解決策: libpcre3, libpcre3-dev をインストール。
$ sudo apt install libpcre3
$ sudo apt install libpcre3-dev
エラー: 前提条件の障害により mod_ssl がビルドできなかった。
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
原因: libssl-dev が未インストール。
解決策: libssl-dev をインストール。
$ sudo apt install libssl-dev
エラー (make): expat.h がない。
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
35 | #include <expat.h>
| ^~~~~~~~~
compilation terminated.
原因: libexpat1-dev が未インストール。
解決策: libexpat1 をインストール。
$ sudo apt install libexpat1-dev
NOTE: curl ライブラリが見つからない。
checking for libcurl config script... no
configure: *** curl library not found.
configure: NOTE: curl library is only required for building mlogc
configure: NOTE: mlgoc compilation was disabled.
原因: libcurl4-openssl-dev が未インストール。
解決策: libcurl4-openssl-dev をインストール。
$ sudo apt install libcurl4-openssl-dev
エラー: apr ライブラリが必要とされている。
checking for libapr config script... no
configure: *** apr library not found.
configure: error: apr library is required
原因: ARP config スクリプトが見つからない。
解決策: configure 時に APR config スクリプトへのパスを指定する。
--with-apr=/PATH/TO/apr-1-config
エラー: apu ライブラリが必要とされている。
checking for libapu config script... no
configure: *** apu library not found.
configure: error: apu library is required
原因: ARP-Util config スクリプトが見つからない。
解決策: configure 時に APR-Util config スクリプトへのパスを指定する。
--with-apu=/PATH/TO/apu-1-config
警告: APR-Util が crypto サポートされていないので SecRemoteRule は 'crypto' パラメータをサポートしない。
configure: WARNING: APR util was not compiled with crypto support. SecRemoteRule will not support the parameter 'crypto' checking that generated files are newer than configure... done
原因: APR-Util が cyrpto をサポートするように構成されていない。
解決策: httpd の configure 時に APR-Util が crypto をサポートするオプションを指定する。
--with-openssl=/usr/lib/ssl --with-crypto
エラー (make test): libaprutil で XML_* への未定義の参照が行われている。
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:837: msc_test] Error 1
make[2]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make[1]: *** [Makefile:1605: check-am] Error 2
make[1]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make: *** [Makefile:501: check-recursive] Error 1
原因: httpd にバンドルした apr-util で XML 関連ライブラリが不足している。
解決策: httd の configure 時に APR-Util が libexpat の場所を認識できるようにする。
--with-expat=/usr/lib/x86-64-linux-gnu
$ sudo apt install make
$ sudo apt install cmake
$ sudo apt isntall gcc
$ sudo apt isntall build-essential
$ cd /usr/local/src
$ sudo wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz
$ sudo wget https://downloads.apache.org/httpd/httpd-2.4.52.tar.gz.sha256
$ sudo sha256sum -c httpd-2.4.52.tar.gz.sha256
httpd-2.4.52.tar.gz: OK
$ sudo tar xvfz httpd-2.4.52.tar.gz
$ cd /usr/local/httpd-2.4.52
$ sudo ./configure --enable-mpms-shared=all --enable-mods-shared=all --enable-ssl
--enable-mpms-shared=all :すべての (all) MPM を動的共有モジュールとして有効化
--enable-mods-shared=all :すべての (all) 動的共有モジュールを有効化する (真の all は reallyall)
--enable-ssl :SSL/TLS サポート
...
configure: error: APR not found. Please read the documentation.
...
$ cd /usr/local/src
$ sudo wget https://dlcdn.apache.org//apr/apr-1.7.0.tar.gz
$ sudo wget https://www.apache.org/dist/apr/apr-1.7.0.tar.gz.sha256
$ sudo sha256 -c apr-1.7.0.tar.gz.sha256
apr-1.7.0.tar.gz: OK
# 以下 APR-Util, APR iconv も同様
$ sudo tar xvzf apr-1.7.0.tar.gz
$ sudo tar xvzf apr-iconv-1.2.2.tar.gz
$ sudo tar xvzf apr-util-1.6.1.tar.gz
$ cd /usr/local/src
$ sudo mv apr-1.7.0 httpd-2.4.52/srclib/apr
$ sudo mv apr-util-1.6.1 httpd-2.4.52/srclib/apr-util
$ sudo mv apr-iconv-1.2.2 httpd-2.4.52/srclib/apr-iconv
$ sudo ./configure --enable-mpms-shared=all --enable-mods-shared=all --enable-ssl --with-included-apr
...
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
$ sudo apt install libpcre3 libpcre3-dev
$ sudo ./configure --enable-mpms-shared=all --enable -mods-shared=all --enable-ssl --with-included-apr
...
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
$ sudo apt install libssl-dev
$ sudo ./configure --enable-mpms-shared=all --enable -mods-shared=all --enable-ssl --with-included-apr
...
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/apache2
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
$ sudo make
...
xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
35 | #include <expat.h>
| ^~~~~~~~~
compilation terminated.
...
$ sudo apt install libexpat1-dev
$ sudo ./configure --enable-mpms-shared=all --enable-mods-shared=all --enable-ssl --with-included-apr
...
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/apache2
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
$ sudo make
$ sudo make install
Prerequisites
mod_unique_id
libapr
libaprutil
libpcre
libxml2
liblua v5.x.x (optional)
libcur v7.15.1 or higher
$ sudo apt install libxml2-dev
$ cd /usr/local/src
$ sudo wget https://github.com/SpiderLabs/ModSecurity/releases/download/v2.9.5/modsecurity-2.9.5.tar.gz
$ sudo wget https://github.com/SpiderLabs/ModSecurity/releases/download/v2.9.5/modsecurity-2.9.5.tar.gz.sha256
$ sha256sum -c modsecurity-2.9.5.tar.gz.sha256
modsecurity-2.9.5.tar.gz: OK
$ sudo tar xzf modsecurity-2.9.5.tar.gz
$ cd modsecurity-2.9.5/
$ sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs
...
checking for libcurl config script... no
configure: *** curl library not found.
configure: NOTE: curl library is only required for building mlogc
configure: NOTE: mlgoc compilation was disabled.
...
$ sudo apt install libcurl4-openssl-dev
$ sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs
...
checking for libapr config script... no
configure: *** apr library not found.
configure: error: apr library is required
$ sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/bin/apr-1-config
...
checking for libapu config script... no
configure: *** apu library not found.
configure: error: apu library is required
$ sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/bin/apr-1-config --with-apu=/usr/local/apahe2/bin/apu-1-config
...
configure: WARNING: APR util was not compiled with crypto support. SecRemoteRule will not support the parameter 'crypto'
...
$ sudo make
$ sudo make test
$ sudo make test
...
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/bin/ld: /usr/local/apache2/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:837: msc_test] Error 1
make[2]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make[1]: *** [Makefile:1605: check-am] Error 2
make[1]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make: *** [Makefile:501: check-recursive] Error 1
$ sudo /usr/local/apache2/bin/apachectl stop
$ cd /usr/local/src/httpd-2.4.52
$ cat /usr/local/src/httpd-2.4.52/config.nice
#! /bin/sh
#
# Created by configure
"./configure" \
"--enable-mpms-shared=all" \
"--enable-mods-shared=all" \
"--enable-ssl" \
"--with-included-apr" \
"$@"
--with-expat=/usr/lib/x86-64-linux-gnu
$ sudo ./configure --with-expat=/usr/lib/x86-64-linux-gnu --enable-mpms-shared=all --enable-mods-shared=all --enable-ssl --with-included-apr
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/apache2
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS: -L/usr/lib/x86-64-linux-gnu/lib
LIBS:
C preprocessor: gcc -E
$ sudo ./configure --with-openssl=/usr/lib/ssl --with-crypto --with-expat=/usr/lib/x86-64-linux-gnu --enable-mpms-shared=all --enable-mods-shared=all --enable-ssl --with-included-apr
...
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/apache2
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS: -L/usr/lib/ssl/lib -L/usr/lib/x86-64-linux-gnu/lib
LIBS:
C preprocessor: gcc -E
$ sudo make
$ sudo make install
--wtih-apr=/PATH/TO/apr-1-config
--wtih-apu=/PATH/TO/apu-1-config
$ sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/bin/apr-1-config --with-apu=/usr/local/apache2/bin/apu-1-config
$ sudo make
$ sudo make test
...
PASS: run-unit-tests.pl
============================================================================
Testsuite summary for modsecurity 2.9
============================================================================
# TOTAL: 1
# PASS: 1
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make[2]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make[1]: Leaving directory '/usr/local/src/modsecurity-2.9.5/tests'
make[1]: Entering directory '/usr/local/src/modsecurity-2.9.5'
make[1]: Nothing to be done for 'check-am'.
make[1]: Leaving directory '/usr/local/src/modsecurity-2.9.5'