LoginSignup
5
10

More than 5 years have passed since last update.

centOS7のapache2.4.6を削除して最新版をインストールしよう

Last updated at Posted at 2018-11-18

CentOS7にデフォで入っているapache2.4.6(httpd)はちょっと古いので、なるべく最新版にしましょう。特にhttp2とかやりたい人は必須らしいです!

ただ、バイナリからインストールするのはちょっと怖いし、バージョンアップもお手軽なパッケージからインストールしたいのが人の子の性...。なので、以下の手順でインストールします。

  1. IUSリポジトリをインストール
  2. 現在のhttpdの削除
  3. IUSリポジトリから、apache2.4.35のインストールをする

IUSリポジトリのインストール

centOS7の方は最初から入っているかもしれません...

sudo yum install https://centos7.iuscommunity.org/ius-release.rpm

現在のhttpdの削除と、IUSからapache2.4の最新版をインストールする

ここで、依存関係のあるパッケージが削除されますので、メモっておきます。私の場合はhttpd-toolspython36u-mod_wsgiが依存関係にあったため削除しました。

sudo yum remove httpd

kiwi@118-27-32-60:~$ sudo yum install httpd --disablerepo=base --disablerepo=updates --enablerepo=ius
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: ftp.riken.jp
 * epel-debuginfo: ftp.riken.jp
 * epel-source: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * ius: mirrors.kernel.org
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ httpd24u.x86_64 0:2.4.35-1.ius.centos7 を インストール
--> 依存性の処理をしています: httpd24u-tools = 2.4.35-1.ius.centos7 のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> 依存性の処理をしています: httpd24u-filesystem = 2.4.35-1.ius.centos7 のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> 依存性の処理をしています: httpd24u-filesystem = 2.4.35-1.ius.centos7 のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> 依存性の処理をしています: libapr15u-1.so.0()(64bit) のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> 依存性の処理をしています: libapr15uutil-1.so.0()(64bit) のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> 依存性の処理をしています: libnghttp2.so.14()(64bit) のパッケージ: httpd24u-2.4.35-1.ius.centos7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ apr15u.x86_64 0:1.5.2-2.ius.centos7 を インストール
---> パッケージ apr15u-util.x86_64 0:1.5.4-3.ius.centos7 を インストール
---> パッケージ httpd24u-filesystem.noarch 0:2.4.35-1.ius.centos7 を インストール
---> パッケージ httpd24u-tools.x86_64 0:2.4.35-1.ius.centos7 を インストール
---> パッケージ libnghttp2.x86_64 0:1.31.1-1.el7 を インストール
--> 衝突を処理しています: httpd24u-tools-2.4.35-1.ius.centos7.x86_64 は httpd-tools < 2.4.35 と衝突しています
--> 依存性解決を終了しました。
エラー: httpd24u-tools conflicts with httpd-tools-2.4.6-80.el7.centos.1.x86_64
 問題を回避するために --skip-broken を用いることができます。
 これらを試行できます: rpm -Va --nofiles --nodigest

# 依存関係のエラーが出た場合、解決する
sudo yum remove httpd-tools python36u-mod_wsgi
sudo yum remove httpd

デフォルトだとbaseupdatesを参照してしまうので、--disablerepoのオプションで無効化します。

また、IUSの利用を強制する場合、--enablerepoオプションで有効化します。

sudo yum install httpd --disablerepo=base --disablerepo=updates --enablerepo=ius

httpd.conf

初期設定では新しいhttpd.confに置き換わっているので、前まで使っていたhttpd.confに戻しましょう。
httpdの削除時だかインストール時に(適当)yum/etc/httpd/conf/httpd.confをバックアップしておいてくれるので、それに戻しておきます。

cd /etc/httpd/conf
sudo mv httpd.conf.rpmsave httpd.conf

httpdの起動

自動起動とデーモンの起動を設定します。失敗した場合、ログを確認するなり、systemctl status httpdで調べましょう

sudo systemctl enable httpd
sudo systemctl start httpd

終わり!

5
10
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
5
10