# Apacheを番外の最新バージョンにしてみた

- リンク: https://reveil.ddns.net/apache2-2-4-54/
- 公開日: 2022-07-27T13:14:05+09:00
- 作成者: reveil

ubuntu server 22.04 LTSのデフォルトのapache2のバージョンは2.4.52で固定されている
らしい。
リリース日を見ると2021年12月と少しだけ古いバージョンとなっている。安定し
て動くものを採用しているのでしょう。

| **OS** | **Apache** | **リリース日** | 
| Ubuntu 18.04 LTS | 2.4.29 | 2017/10/23 | 
| Ubuntu 20.04 LTS | 2.4.41 | 2019/08/14 | 
| Ubuntu 22.04 LTS | 2.4.52 | 2021/12/20 |

新しいものが大好きな者としてはどうにかして最新バージョンを導入できないか調べてみ
た。

この記事を書いている2022年7月27日時点の最新バージョンはどうやら2022年6月8日にリリース
された2.4.54らしいことはわかった。

[[

しかし上述のとおりUbuntu 22.04 LTSのApacheは2.4.52で固定されているため、公式リポジ
トリに2.4.52より新しいバージョンが登録されない限り通常のアップデート作業は無効だ。

 [](https://blog.with2.net/link/?id=2094640&cid=1016) [](https://blog.with2.net/link/?id=2094640&tag=10849)

そこでPPAの登場。
個人が管理しているリポジトリで非公式アップデートになりますがうまく
動作してくれれば文句はありません。これが原因で致命的なトラブルになることはまず無い
でしょう。トラブったらその時はその時です。（笑）

それでは早速PPAの導入をば（非公式リポジトリの登録）

    ```wp-block-prismatic-blocks
    sudo add-apt-repository ppa:ondrej/apache2
    ```

PPAが導入できたらインストールできる最新バージョンを確認してみます。

    ```wp-block-prismatic-blocks
    $ sudo apt show apache2
    Package: apache2
    Version: 2.4.54-1+ubuntu22.04.1+deb.sury.org+1
    Priority: optional
    Section: httpd
    Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
    Installed-Size: 523 kB
    Provides: httpd, httpd-cgi
    Depends: apache2-bin (= 2.4.54-1+ubuntu22.04.1+deb.sury.org+1), apache2-data (= 2.4.54-1+ubuntu22.04.1+deb.sury.org+1), apache2-utils (= 2.4.54-1+ubuntu22.04.1+deb.sury.org+1), lsb-base, mime-support, perl:any, procps
    Recommends: ssl-cert
    Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser
    Download-Size: 165 kB
    APT-Manual-Installed: yes
    APT-Sources: https://ppa.launchpadcontent.net/ondrej/apache2/ubuntu jammy/main amd64 Packages
    Description: Apache HTTP サーバ
    ```

最新バージョンとして2.4.54表示されたので後はいつものアップデートとインストールコマンド
を叩きます

    ```wp-block-prismatic-blocks
    sudo apt update
    sudo apt install apache2 -y
    ```

ほどなくしてインストールが完了、あとは新しいバージョンがうまく稼働しているか確認

    ```wp-block-prismatic-blocks
    $ sudo service apache2 status
    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
         Active: active (running) since Wed 2022-07-27 12:07:10 JST; 49min ago
           Docs: https://httpd.apache.org/docs/2.4/
        Process: 34669 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
       Main PID: 34675 (apache2)
          Tasks: 11 (limit: 37630)
         Memory: 231.9M
            CPU: 18.237s
         CGroup: /system.slice/apache2.service
                 ├─34675 /usr/sbin/apache2 -k start
                 ├─34823 /usr/sbin/apache2 -k start
                 ├─34824 /usr/sbin/apache2 -k start
                 ├─34825 /usr/sbin/apache2 -k start
                 ├─34827 /usr/sbin/apache2 -k start
                 ├─35104 /usr/sbin/apache2 -k start
                 ├─35111 /usr/sbin/apache2 -k start
                 ├─35112 /usr/sbin/apache2 -k start
                 ├─35201 /usr/sbin/apache2 -k start
                 ├─35217 /usr/sbin/apache2 -k start
                 └─35218 /usr/sbin/apache2 -k start
     7月 27 12:07:10 ubuntu systemd[1]: Starting The Apache HTTP Server...
     7月 27 12:07:10 ubuntu systemd[1]: Started The Apache HTTP Server.
    ```

バージョンの確認は以下で

    ```wp-block-prismatic-blocks
    $ apache2ctl -v
    Server version: Apache/2.4.54 (Ubuntu)
    Server built:   2022-06-08T15:59:33
    ```

**PPAベースの最新バージョンにアップデートした直後SSL接続が出来なくないという不具合
が発生。**
これは結構簡単に解決できた。/etc/apache2/sites-available下にあるdefault-
ssl.confが新しいバージョンインストール時に新しいファイルに置き換えられているのが
原因。バージョンアップ前のファイルが同じディレクトリに拡張子を変えた形で保存され
ているのでdefault-ssl.confにリネームしapache2を再起動してやるだけでOK。リネームし
なくてもdefault-ssl.confにSSL証明書の正しいパスを記述してやってもOK。

sudo apt show -a apache2でズラズラっと表示される情報の中に設定ファイル、スクリプト
など含めたフルインストールになるってちゃんと書いてありましたわ。面倒がらずにちゃんと
読まないといけませんね。

    ```wp-block-prismatic-blocks
    $　sudo apt show -a apache2
    〜中略〜
    Installing this package results in a full installation, including the
    configuration files, init scripts and support scripts.
    〜以下略〜
    ```

最後にちょっとしたハプニングがありましたが今のところ問題なく動いてくれています。

この記事がお気に召しましたらシェア・いいねを！！
