[ITPASS2021]2021年度(2月)Apacheアップグレードログ(ika)

ika-itpass の Apache アップグレード作業ログ

経緯

  • 対外公開サーバ情報セキュリティ監査の結果, ika には対処が 求められる重要度 4 以上の脆弱性が確認された. その中には Apache に関するものもあった.
    • 影響を受けるバージョン: Apache HTTP Server 2.4.7 ~ 2.4.51
    • 2022 年 2 月 9 日現在, ika-itpass にインストールされているバージョン: 2.4.51

作業概要

  • Apache をアップグレードする
  • 作業日
    • 2022/02/09
  • 作業者
    • 伊藤, 入場

作業ログ

現状の確認

Apache が動作していることを確認する.

$ ps aux | grep httpd
root         782  0.0  0.0  10616  7672 ?        Ss    2021   3:45 
/usr/local/apache2/bin/httpd -k start
www-data 1420701  0.0  0.0  10852  4612 ?        S     2月06   0:08 
/usr/local/apache2/bin/httpd -k start
www-data 1420702  0.0  0.0 1936184 23920 ?       Sl    2月06   0:46 
/usr/local/apache2/bin/httpd -k start
www-data 1420703  0.0  0.0 1936184 28048 ?       Sl    2月06   1:01 
/usr/local/apache2/bin/httpd -k start
www-data 1420705  0.0  0.0 2001720 23588 ?       Sl    2月06   0:29 
/usr/local/apache2/bin/httpd -k start
www-data 1420792  0.0  0.0 2001720 25048 ?       Sl    2月06   0:42 
/usr/local/apache2/bin/httpd -k start
tierraki 1538554  0.0  0.0   5344   664 pts/2    S+   17:33   0:00 grep httpd

インストールされている Apache のバージョンを確認する.

$ /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.51 (Unix)
Server built:   Oct 20 2021 09:35:41

新バージョンのビルド

  • ソースを取得・展開

    ※ 2022 年 02 月 09 日時点の最新バージョンは 2.4.52 である.

    • ビルドは /usr/local/src で行う.

      # cd /usr/local/src
      # wget http://ftp.tsukuba.wide.ad.jp/software/apache//httpd/httpd-2.4.52.tar.gz
  • httpd のインストール

    # cd /usr/local/src
    # tar xvzf httpd-2.4.52.tar.gz
    # cd httpd-2.4.52
    • configure オプション (: 目的)
      • --enable-ssl (: apache-ssl を動作させるため)
      • --enable-rewrite (: mod_rewrite を使用するため)
        • gate の登録窓口を http から https へ移動させたい
      • --enable-so (: DSO (Dynamic shared object: 動的共有オブジェクト) を使用するため)
      • --with-included-apr (: ビルド時に "Cannot use an external APR-util with the bundled APR" とエラーが生じる場合があるため)
    # ./configure --enable-ssl --enable-rewrite --enable-so --with-apr=/usr/local/apr
    • なお, インストール先は /usr/local/apache2 (apache2 のデフォルト)
      • configure の際に --prefix の設定は不要
    • configure の結果は config.log を参照し, 問題ないか確認する.
  • make でビルドする.

    # make

新バージョンのインストール

  • apache を停止する.

    # /usr/local/apache2/bin/apachectl -k graceful-stop
    • 停止したかどうかを確認する.

      $ ps aux | grep http
      • www-data の表示が消えたことを確認する.
    • apache のエラーログ /var/log/httpd-error.log を確認し, エラーなどが出ていないことを確認する.
  • apache をインストールする.

    # make install
  • /usr/local/apache2 の下に以下のディレクトリが作成されていることを確認する.
$ ls /usr/local/apache2/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules

新バージョンの動作確認

  • バージョン確認

    # /usr/local/apache2/bin/httpd -v
    Server version: Apache/2.4.52 (Unix)
    Server built:   Feb  9 2022 17:45:45
  • Apache 起動

    # /usr/local/apache2/bin/apachectl -k start
    $ ps aux | grep httpd
    • 画面左端に www-data と表示され, 起動できていることを確認できる.
  • 起動スクリプトの編集 (バージョン名変更のみ)
    • /etc/systemd/system/apache2.service を編集する.

      # emacs apache2.service
    • ファイルの中身は以下のようになっていればよい.

      [Unit]
      Description=httpd-2.4.52 daemon
      
      [Service]
      Type=forking
      ExecStart=/usr/local/apache2/bin/apachectl start
      
      [Install]
      WantedBy=multi-user.target

参考資料

Last modified:2022/02/10 08:47:26
Keyword(s):
References:[[ITPASS]過去の構築・運用ドキュメント]