Linux/APM

[CentOS7] PHP 7.4 설치

aegypius 2021. 1. 30. 02:50
728x90
반응형

  CentOS 8은 php 7.4 버전이 기본 패키지이지만, CentOS 7에서는 php 5.4.16 버전이다. 서버에 php 5.4이상부터 최신버전을 설치하려 한다면 컴파일 보다는 yum을 이용하는 것이 편리하다. CentOS 8 부터 새로운 패키지 관리자로 dnf가 추가되었지만 yum은 여전히 사용할 수 있다.

  yum은 repository(저장소)를 통해서 패키지를 관리하며, repository에 등록된 패키지 정보를 토대로 손쉽게 설치할 수 있다. remi 저장소를 이용해서 php의 최신버전을 설치해보자.

  Remi's RPM repository에 방문하면 아래와 같이 리눅스 버전별로 설치할 수 있는 repository의 목록을 볼 수 있다.

  서버의 OS가 CentOS 7이라면 remi-release-7.rpm을, CentOS 8이라면 remi-release-8.rpm을 설치하자. 레미 저장소는 rpm형태로 제공되며 아래와 같이 yum으로 설치할 수 있다. (아래의 예는 CentOS 7인 경우이다.)

# yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

 

  remi 저장소는 종속성 문제로 EPEL(Extra Packages for Enterprise Linux) 저장소가 미리 설치되어 있어야 설치할 수 있다. 페도라 프로젝트의 EPEL 저장소 설치방법에 대한 안내는 아래와 같다.

  서버의 리눅스 버전에 맞는 패키지를 선택하여 설치하자. 만약 CentOS 7이라면 아래와 같이 설치할 수 있다.

# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

  epel 저장소와 remi 저장소의 설치를 마쳤다면 yum명령으로 설치된 repository의 목록을 확인할 수 있다.

[root@localhost pius]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: ftp.iij.ad.jp
 * extras: mirror.kakao.com
 * remi-php74: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirror.kakao.com
repo id                     repo name                                                                status
!base/7/x86_64              CentOS-7 - Base                                                          10,072
!epel/x86_64                Extra Packages for Enterprise Linux 7 - x86_64                           13,516
!extras/7/x86_64            CentOS-7 - Extras                                                           448
!mariadb                    MariaDB                                                                      97
!remi-php74                 Remi's PHP 7.4 RPM repository for Enterprise Linux 7 - x86_64               381
!remi-safe                  Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                4,080
!updates/7/x86_64           CentOS-7 - Updates                                                        1,207
repolist: 29,801
[root@localhost pius]#

 

  이제 yum repolist all 명령으로 모든 저장소의 상태를 확인해보자.

[root@localhost pius]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: mirror.kakao.com
 * remi-php54: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirror.kakao.com
repo id                          repo name                                            status
C7.0.1406-base/x86_64            CentOS-7.0.1406 - Base                               disabled
C7.0.1406-centosplus/x86_64      CentOS-7.0.1406 - CentOSPlus                         disabled
C7.0.1406-extras/x86_64          CentOS-7.0.1406 - Extras                             disabled
C7.0.1406-fasttrack/x86_64       CentOS-7.0.1406 - Fasttrack                          disabled
C7.0.1406-updates/x86_64         CentOS-7.0.1406 - Updates                            disabled
C7.1.1503-base/x86_64            CentOS-7.1.1503 - Base                               disabled
C7.1.1503-centosplus/x86_64      CentOS-7.1.1503 - CentOSPlus                         disabled
C7.1.1503-extras/x86_64          CentOS-7.1.1503 - Extras                             disabled
C7.1.1503-fasttrack/x86_64       CentOS-7.1.1503 - Fasttrack                          disabled
C7.1.1503-updates/x86_64         CentOS-7.1.1503 - Updates                            disabled
C7.2.1511-base/x86_64            CentOS-7.2.1511 - Base                               disabled
C7.2.1511-centosplus/x86_64      CentOS-7.2.1511 - CentOSPlus                         disabled
C7.2.1511-extras/x86_64          CentOS-7.2.1511 - Extras                             disabled
C7.2.1511-fasttrack/x86_64       CentOS-7.2.1511 - Fasttrack                          disabled
C7.2.1511-updates/x86_64         CentOS-7.2.1511 - Updates                            disabled
C7.3.1611-base/x86_64            CentOS-7.3.1611 - Base                               disabled
C7.3.1611-centosplus/x86_64      CentOS-7.3.1611 - CentOSPlus                         disabled
C7.3.1611-extras/x86_64          CentOS-7.3.1611 - Extras                             disabled
C7.3.1611-fasttrack/x86_64       CentOS-7.3.1611 - Fasttrack                          disabled
C7.3.1611-updates/x86_64         CentOS-7.3.1611 - Updates                            disabled
C7.4.1708-base/x86_64            CentOS-7.4.1708 - Base                               disabled
C7.4.1708-centosplus/x86_64      CentOS-7.4.1708 - CentOSPlus                         disabled
C7.4.1708-extras/x86_64          CentOS-7.4.1708 - Extras                             disabled
C7.4.1708-fasttrack/x86_64       CentOS-7.4.1708 - Fasttrack                          disabled
C7.4.1708-updates/x86_64         CentOS-7.4.1708 - Updates                            disabled
C7.5.1804-base/x86_64            CentOS-7.5.1804 - Base                               disabled
C7.5.1804-centosplus/x86_64      CentOS-7.5.1804 - CentOSPlus                         disabled
C7.5.1804-extras/x86_64          CentOS-7.5.1804 - Extras                             disabled
C7.5.1804-fasttrack/x86_64       CentOS-7.5.1804 - Fasttrack                          disabled
C7.5.1804-updates/x86_64         CentOS-7.5.1804 - Updates                            disabled
!base/7/x86_64                   CentOS-7 - Base                                      enabled: 10,072
base-debuginfo/x86_64            CentOS-7 - Debuginfo                                 disabled
base-source/7                    CentOS-7 - Base Sources                              disabled
c7-media                         CentOS-7 - Media                                     disabled
centosplus/7/x86_64              CentOS-7 - Plus                                      disabled
centosplus-source/7              CentOS-7 - Plus Sources                              disabled
cr/7/x86_64                      CentOS-7 - cr                                        disabled
!epel/x86_64                     Extra Packages for Enterprise Linux 7 - x86_64       enabled: 13,514
epel-debuginfo/x86_64            Extra Packages for Enterprise Linux 7 - x86_64 - Deb disabled
epel-source/x86_64               Extra Packages for Enterprise Linux 7 - x86_64 - Sou disabled
epel-testing/x86_64              Extra Packages for Enterprise Linux 7 - Testing - x8 disabled
epel-testing-debuginfo/x86_64    Extra Packages for Enterprise Linux 7 - Testing - x8 disabled
epel-testing-source/x86_64       Extra Packages for Enterprise Linux 7 - Testing - x8 disabled
!extras/7/x86_64                 CentOS-7 - Extras                                    enabled:    448
extras-source/7                  CentOS-7 - Extras Sources                            disabled
fasttrack/7/x86_64               CentOS-7 - fasttrack                                 disabled
!mariadb                         MariaDB                                              enabled:     97
!remi                            Remi's RPM repository for Enterprise Linux 7 - x86_6 disabled
remi-debuginfo/x86_64            Remi's RPM repository for Enterprise Linux 7 - x86_6 disabled
remi-glpi91                      Remi's GLPI 9.1 RPM repository for Enterprise Linux  disabled
remi-glpi92                      Remi's GLPI 9.2 RPM repository for Enterprise Linux  disabled
remi-glpi93                      Remi's GLPI 9.3 RPM repository for Enterprise Linux  disabled
remi-glpi94                      Remi's GLPI 9.4 RPM repository for Enterprise Linux  disabled
remi-modular                     Remi's Modular repository for Enterprise Linux 7 - x disabled
remi-modular-test                Remi's Modular testing repository for Enterprise Lin disabled
!remi-php54                      Remi's PHP 5.4 RPM repository for Enterprise Linux 7 enabled:    408
remi-php55                       Remi's PHP 5.5 RPM repository for Enterprise Linux 7 disabled
remi-php55-debuginfo/x86_64      Remi's PHP 5.5 RPM repository for Enterprise Linux 7 disabled
remi-php56                       Remi's PHP 5.6 RPM repository for Enterprise Linux 7 disabled
remi-php56-debuginfo/x86_64      Remi's PHP 5.6 RPM repository for Enterprise Linux 7 disabled
remi-php70                       Remi's PHP 7.0 RPM repository for Enterprise Linux 7 disabled
remi-php70-debuginfo/x86_64      Remi's PHP 7.0 RPM repository for Enterprise Linux 7 disabled
remi-php70-test                  Remi's PHP 7.0 test RPM repository for Enterprise Li disabled
remi-php70-test-debuginfo/x86_64 Remi's PHP 7.0 test RPM repository for Enterprise Li disabled
remi-php71                       Remi's PHP 7.1 RPM repository for Enterprise Linux 7 disabled
remi-php71-debuginfo/x86_64      Remi's PHP 7.1 RPM repository for Enterprise Linux 7 disabled
remi-php71-test                  Remi's PHP 7.1 test RPM repository for Enterprise Li disabled
remi-php71-test-debuginfo/x86_64 Remi's PHP 7.1 test RPM repository for Enterprise Li disabled
!remi-php72                      Remi's PHP 7.2 RPM repository for Enterprise Linux 7 disabled
remi-php72-debuginfo/x86_64      Remi's PHP 7.2 RPM repository for Enterprise Linux 7 disabled
remi-php72-test                  Remi's PHP 7.2 test RPM repository for Enterprise Li disabled
remi-php72-test-debuginfo/x86_64 Remi's PHP 7.2 test RPM repository for Enterprise Li disabled
remi-php73                       Remi's PHP 7.3 RPM repository for Enterprise Linux 7 disabled
remi-php73-debuginfo/x86_64      Remi's PHP 7.3 RPM repository for Enterprise Linux 7 disabled
remi-php73-test                  Remi's PHP 7.3 test RPM repository for Enterprise Li disabled
remi-php73-test-debuginfo/x86_64 Remi's PHP 7.3 test RPM repository for Enterprise Li disabled
!remi-php74                      Remi's PHP 7.4 RPM repository for Enterprise Linux 7 disabled
remi-php74-debuginfo/x86_64      Remi's PHP 7.4 RPM repository for Enterprise Linux 7 disabled
remi-php74-test                  Remi's PHP 7.4 test RPM repository for Enterprise Li disabled
remi-php74-test-debuginfo/x86_64 Remi's PHP 7.4 test RPM repository for Enterprise Li disabled
!remi-safe                       Safe Remi's RPM repository for Enterprise Linux 7 -  enabled:  4,089
remi-safe-debuginfo/x86_64       Remi's RPM repository for Enterprise Linux 7 - x86_6 disabled
remi-test                        Remi's test RPM repository for Enterprise Linux 7 -  disabled
remi-test-debuginfo/x86_64       Remi's test RPM repository for Enterprise Linux 7 -  disabled
!updates/7/x86_64                CentOS-7 - Updates                                   enabled:  1,216
updates-source/7                 CentOS-7 - Updates Sources                           disabled
repolist: 29,844
[root@localhost pius]#

 

  위와 같이 remi-php54가 enable 상태인 경우에는 yum을 통해서 php를 설치하면 php5.4버전이 설치된다. 7.4버전을 설치하기 위해서 5.4를 disable로 7.4를 enable로 바꾸어보자. 아래와 같다.

 # yum-config-manager --enable remi-php74

 

  이제 yum repolist all 명령을 통해서 remi-php74가 enable로 설정되었음을 확인할 수 있다. 이 상태에서 yum으로 php의 설치를 시도한다면(# yum install php) php 7.4 버전이 설치될 것이다.

 

  yum-config-manager 명령을 사용할 때 enable 옵션 대신에 disable을 사용하여 특정 패키지를 비활성화할 수 있다. php 버전 7.4를 설치하려 하다면 그 이외의 버전은 미리 disble로 설정하는 것이 좋다. 만약 yum-config-manager명령이 실행되지 않는다면 아래와 같이 yum-utils를 설치해야 할 것이다 

# yum install yum-utils
728x90
반응형