脆弱性の問題等もあるしApache httpdのインストール方法を再確認します。
httpdとかは1回インストールするとその後はそこまで頻繁にアップデートしないことが多々あるので・・・。
必要なライブラリをダウンロード
httpdのインストールに必要なApache関連のライブラリをダウンロードします。
必要なライブラリは以下です。
インストールするライブラリは2022/01/17日現在の最新バージョンを使用していきます。
Apache httpdをダウンロード
$ cd /usr/local
$ wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz
$ tar xvfz httpd-2.4.52.tar.gz
APR, APR-utilをダウンロード
$ cd httpd-2.4.52/srclib
$ wget https://dlcdn.apache.org//apr/apr-1.7.0.tar.gz
$ wget https://dlcdn.apache.org//apr/apr-util-1.6.1.tar.gz
$ tar xvfz apr-1.7.0.tar.gz
$ tar xvfz apr-util-1.6.1.tar.gz
Apache httpdインストールのコマンド実行時にエラーとなるため事前にフォルダ名を変更する
$ mv apr-1.7.0/ apr
$ mv apr-util-1.6.1/ apr-util
不要なファイルを削除
$ rm -f apr*tar.gz
Apache httpd インストール
$ cd /usr/local/httpd-2.4.52
$ ./configure -prefix=/usr/local/httpd-2.4.52 --enable-so --enable-shared --enable-ssl --enable-rewrite --enable-expires --enable-deflate --enable-headers --with-included-apr --enable-substitute --with-included-apr-util
-- 省略 --
configure: summary of build options:
Server Version: 2.4.52
Install prefix: /usr/local/httpd-2.4.52
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
$ make
-- 省略 --
make[4]: ディレクトリ `/usr/local/httpd-2.4.52/modules/mappers' から出ます
make[3]: ディレクトリ `/usr/local/httpd-2.4.52/modules/mappers' から出ます
make[2]: ディレクトリ `/usr/local/httpd-2.4.52/modules' から出ます
make[2]: ディレクトリ `/usr/local/httpd-2.4.52/support' に入ります
make[2]: ディレクトリ `/usr/local/httpd-2.4.52/support' から出ます
make[1]: ディレクトリ `/usr/local/httpd-2.4.52' から出ます
$ make install
-- 省略 --
Installing configuration files
Installing HTML documents
Installing error documents
Installing icons
Installing CGIs
Installing header files
Installing build system files
Installing man pages and online manual
make[1]: ディレクトリ `/usr/local/httpd-2.4.52' から出ます
インストール時に出るエラー
このエラーが出たらこちらを参照してください。
zlibが見つからなかった場合の対処法です。
checking for zlib location… not found
checking whether to enable mod_deflate… configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
もう1つ。このエラーが出たらこちらを参照してください。
OpenSSLのバージョンが古かった場合の対処法です。
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
インストールしたバージョンを有効にする
上記手順ではまだ以前のhttpdバージョンのままなのでsystemdのUnit設定ファイルを編集していきます。
今まであまり意識していなかったのですが下記URLによると/usr/lib/systemd/systemと/etc/systemd/systemでは使い道が異なるので /etc/systemd/system (管理者によるカスタマイズファイル置き場)にUnitファイルを作成します。
https://weblabo.oscasierra.net/centos7-systemd-files/
$ vi /etc/systemd/system/httpd.service
[Unit]
Description=Apache 2.4.52
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/usr/local/httpd-2.4.52/bin/apachectl -k start
ExecStop=/usr/local/httpd-2.4.52/bin/apachectl -k stop
ExecReload=/usr/local/httpd-2.4.52/bin/apachectl -k graceful
[Install]
WantedBy=multi-user.target
設定ファイルを有効化します。
$ systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /etc/systemd/system/httpd.service.
$ systemctl start httpd
$ systemctl status httpd
● httpd.service - Apache 2.4.52
Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2021-12-16 00:12:53 PDT; 12min ago
Process: 128077 ExecStart=/usr/local/httpd-2.4.52/bin/apachectl -k start (code=exited, status=0/SUCCESS)
Main PID: 128083 (httpd)
Tasks: 82
CGroup: /system.slice/httpd.service
├─128083 /usr/local/httpd-2.4.52/bin/httpd -k start
├─128084 /usr/local/httpd-2.4.52/bin/httpd -k start
├─128085 /usr/local/httpd-2.4.52/bin/httpd -k start
└─128086 /usr/local/httpd-2.4.52/bin/httpd -k start
10月 17 20:46:31 localhost.localdomain systemd[1]: Starting Apache 2.4.52...
10月 17 20:46:31 localhost.localdomain apachectl[128077]: AH00558: httpd: Could not reliably determin...ge
10月 17 20:46:31 localhost.localdomain systemd[1]: Started Apache 2.4.52.
Hint: Some lines were ellipsized, use -l to show in full.
これでインストール完了です。
以上です。
コメント