LoginSignup
1
0

More than 1 year has passed since last update.

[CentOS7]Apacheの古いバージョンの導入とデーモン化

Last updated at Posted at 2021-12-01

この記事のあとに、PHPと連携する際に躓いた点を新しく記事にしました。 参考にしてみてください。

リンク

はじめに

ども。僕です。

最近、脆弱性のある環境を作成するさい、Apache+PHPで脆弱性のあるWEBページを構築する機会がありました。
そこで、Apacheの脆弱性であるCVE-2021-41773, CVE-2021-42013を使ってみたく、古いApacheのインストールを行いました。

古いバージョンをピンポイントで導入するのと、そのデーモン化について調べたので、記していきます。

今回の環境↓

  • CentOS 7
  • Apache 2.4.49

Apacheの古いバージョンのインストール

古いバージョンのインストールなんてできないので、リポジトリからcurlしてきます。

# curl -OL http://archive.apache.org/dist/httpd/httpd-2.4.49.tar.gz
# tar -xvzf httpd-2.4.49.tar.gz
# yum install -y libtool apr-devel apr-util apr-util-devel pcre pcre-devel
# cd httpd-2.4.49
# ./configure
# make
# make install
// /usr/localにインストールされます

// インストール確認
# cd /usr/local/apache2/bin
# ./httpd -v
Server version: Apache/2.4.49 (Unix)

make installをすると/usr/local/apache2ディレクトリができて、そこで設定していきます。

Apacheのデーモン化

このままだといちいちファイル指定して起動しないといけないので、デーモン化してsystemctlで制御しましょう。

// 新規作成
# vim /etc/systemd/system/httpd.service
[Unit]
Description=The Apache 2.4.49 HTTP Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
EnvironmentFile=/usr/local/apache2/conf/httpd.conf
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
ExecStop=/usr/local/apache2/bin/apachectl -k stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

# systemctl start httpd.service
# systemctl status httpd.service
// 起動していることを確認する

以上で古いバージョンのApacheのインストールが完了します。

参考文献

CentOS7にapache2.4.46をソースからインストール

【CentOS7】httpd 2.2 (Apache)をコンパイルからインストールする手順

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0