LoginSignup
6
12

More than 5 years have passed since last update.

RedHat7にPHP7のインストール

Posted at

あるサーバーにPHP7を入れてほしいという依頼が来た。

インスタンスの情報収集

$ uname -a
Linux xxx.compute.internal 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
$ cat /proc/version
Linux version 3.10.0-514.el7.x86_64 (mockbuild@x86-039.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Wed Oct 19 11:24:13 EDT 2016
項目 内容
OS Red Hat Enterprise Linux Server 7.3
アーキテクチャ x86_64
gcc 4.8.5

wgetのインストール

wgetが入っていなかったのでインストール。rpmファイルの取得に使います。

# yum install wget

yumリポジトリの追加

リポジトリはAWSのデフォルトのまま。

# yum repolist
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                repo name                                                                             status
rhui-REGION-client-config-server-7/x86_64                              Red Hat Update Infrastructure 2.0 Client Configuration Server 7                            6
rhui-REGION-rhel-server-releases/7Server/x86_64                        Red Hat Enterprise Linux Server 7 (RPMs)                                              13,838
rhui-REGION-rhel-server-rh-common/7Server/x86_64                       Red Hat Enterprise Linux Server 7 RH Common (RPMs)                                       209
repolist: 14,053

epelのリポジトリの追加

epelとは、Extra Packages for Enterprise Linuxの略称で、RedHatやCentOSは保守的で使えるrpmパッケージ自体やそのバージョンが限られているので、新しいものを使いたい場合は、epelをリポジトリに追加することにより、Fadoraと同様のパッケージの利用が可能になる。
詳しくは、https://fedoraproject.org/wiki/About_EPEL/ja

# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
# rpm -ivh epel-release-7-9.noarch.rpm

リポジトリを確認。epelが追加された。

# yum repolist
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                repo name                                                                             status
epel/x86_64                                                            Extra Packages for Enterprise Linux 7 - x86_64                                        11,184
rhui-REGION-client-config-server-7/x86_64                              Red Hat Update Infrastructure 2.0 Client Configuration Server 7                            6
rhui-REGION-rhel-server-releases/7Server/x86_64                        Red Hat Enterprise Linux Server 7 (RPMs)                                              13,838
rhui-REGION-rhel-server-rh-common/7Server/x86_64                       Red Hat Enterprise Linux Server 7 RH Common (RPMs)                                       209
repolist: 25,237

remiのリポジトリの追加

remiリポジトリを追加するためには、epelリポジトリの追加を先にしておく必要がある。

# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

リポジトリの確認。remiが追加されている。

# yum repolist
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
remi-safe                                                                                                                                   | 2.9 kB  00:00:00
remi-safe/primary_db                                                                                                                        | 906 kB  00:00:03
repo id                                                                repo name                                                                             status
epel/x86_64                                                            Extra Packages for Enterprise Linux 7 - x86_64                                        11,184
remi-safe                                                              Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                             2,000
rhui-REGION-client-config-server-7/x86_64                              Red Hat Update Infrastructure 2.0 Client Configuration Server 7                            6
rhui-REGION-rhel-server-releases/7Server/x86_64                        Red Hat Enterprise Linux Server 7 (RPMs)                                              13,838
rhui-REGION-rhel-server-rh-common/7Server/x86_64                       Red Hat Enterprise Linux Server 7 RH Common (RPMs)                                       209
repolist: 27,237

念のためリポジトリのデータベースの参照も確認。
なんかたくさん入ってるぞ!

# ls /etc/yum.repos.d/
epel.repo          redhat.repo                     redhat-rhui.repo  remi-php70.repo  remi.repo       rhui-load-balancers.conf
epel-testing.repo  redhat-rhui-client-config.repo  remi-php54.repo   remi-php71.repo  remi-safe.repo

PHPのインストール

さて下準備が長くなりましたが、本題のPHP7のインストールです。
開発に必要と思われるものを一気に入れちゃいます。

# yum install --enablerepo=epel,remi-php70 php php-mbstring php-pear php-fpm php-mcrypt php-mysql

確認。

# php -v
PHP 7.0.16 (cli) (built: Feb 14 2017 17:22:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

でけた!

6
12
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
6
12