Linux,Unix,BSD/Apache, PHP

외부 네트워크가 연결되지 않는 CentOS7에 PHP7.0 설치하기

채윤아빠 2019. 2. 16. 21:51
728x90
반응형




보통 DMZ 내부에서 외부 네트워크와 완벽하게 단절된 경우, yum을 사용할 수 없기 때문에 패키지 관리 및 신규 패키지 설치에 어려움이 있습니다.
본 문서에서는 외부 네트워크를 사용할 수 없는 곳에 위치해 있는 CentOS7에 PHP7.0을 설치하는 방법에 대하여 설명합니다.


PHP7.0에 필요한 rpm 파일 구하기

동일 버전의 CentOS7 준비

PHP 7.0 설치 대상 서버와 동일한 버전의 CentOS minimal 버전을 구하여 VirutalBox 등을 이용하여 외부 네트워크를 이용할 수 있는 동일한 환경을 구성합니다.


PHP7.0 rpm 파일 다운로드

동일한 환경으로 구성한 CentOS7에서 다음과 같은 과정으로 PHP7.0 설치에 필요한 rpm 파일들은 다운로드 받을 수 있도록 준비합니다.

이를 위하여 yum에서 설치한 필요한 패키지의 rpm 파일만 다운로드 받을 수 있는 옵션이 있습니다.

yum install php php-mcrypt php-cli php-gd php-curl php-mysqli php-ldap php-zip php-fileinfo php-mbstring

====================================================================================================================================================================
Installing:
 php                                            x86_64                        7.0.33-2.el7.remi                             remi-php70                        2.6 M
 php-cli                                        x86_64                        7.0.33-2.el7.remi                             remi-php70                        4.0 M
 php-common                                     x86_64                        7.0.33-2.el7.remi                             remi-php70                        1.0 M
 php-gd                                         x86_64                        7.0.33-2.el7.remi                             remi-php70                         73 k
 php-ldap                                       x86_64                        7.0.33-2.el7.remi                             remi-php70                         65 k
 php-mbstring                                   x86_64                        7.0.33-2.el7.remi                             remi-php70                        574 k
 php-mcrypt                                     x86_64                        7.0.33-2.el7.remi                             remi-php70                         57 k
 php-mysqlnd                                    x86_64                        7.0.33-2.el7.remi                             remi-php70                        237 k
 php-pecl-zip                                   x86_64                        1.15.4-1.el7.remi.7.0                         remi-php70                         51 k
Installing for dependencies:
 apr                                            x86_64                        1.4.8-3.el7_4.1                               base                              103 k
 apr-util                                       x86_64                        1.5.2-6.el7                                   base                               92 k
 dejavu-fonts-common                            noarch                        2.33-6.el7                                    base                               64 k
 dejavu-sans-fonts                              noarch                        2.33-6.el7                                    base                              1.4 M
 fontconfig                                     x86_64                        2.13.0-4.3.el7                                base                              254 k
 fontpackages-filesystem                        noarch                        1.44-8.el7                                    base                              9.9 k
 gd-last                                        x86_64                        2.2.5-5.el7.remi                              remi-safe                         134 k
 httpd                                          x86_64                        2.4.6-88.el7.centos                           base                              2.7 M
 httpd-tools                                    x86_64                        2.4.6-88.el7.centos                           base                               90 k
 jbigkit-libs                                   x86_64                        2.0-11.el7                                    base                               46 k
 libX11                                         x86_64                        1.6.5-2.el7                                   base                              606 k
 libX11-common                                  noarch                        1.6.5-2.el7                                   base                              164 k
 libXau                                         x86_64                        1.0.8-2.1.el7                                 base                               29 k
 libXpm                                         x86_64                        3.5.12-1.el7                                  base                               55 k
 libjpeg-turbo                                  x86_64                        1.2.90-6.el7                                  base                              134 k
 libmcrypt                                      x86_64                        2.5.8-13.el7                                  epel                               99 k
 libpng                                         x86_64                        2:1.5.13-7.el7_2                              base                              213 k
 libtiff                                        x86_64                        4.0.3-27.el7_3                                base                              170 k
 libtool-ltdl                                   x86_64                        2.4.2-22.el7_3                                base                               49 k
 libwebp                                        x86_64                        0.3.0-7.el7                                   base                              170 k
 libxcb                                         x86_64                        1.13-1.el7                                    base                              214 k
 libzip5                                        x86_64                        1.5.1-1.el7.remi                              remi-safe                          55 k
 mailcap                                        noarch                        2.1.41-2.el7                                  base                               31 k
 php-json                                       x86_64                        7.0.33-2.el7.remi                             remi-php70                         60 k
 php-pdo                                        x86_64                        7.0.33-2.el7.remi                             remi-php70                        123 k
Updating for dependencies:
 freetype                                       x86_64                        2.8-12.el7_6.1                                updates                           380 k

Transaction Summary
====================================================================================================================================================================
Install  9 Packages (+25 Dependent packages)
Upgrade             (  1 Dependent package)

외부 네트워크를 이용할 수 있는 곳에서 아래와 같이 명령을 입력하면, PHP7.0 설치에 필요한 모든 rpm 파일들은 다운로드 받게 됩니다.

yum install --downloadonly -downloaddir=./php70 php php-mcrypt php-cli php-gd php-curl php-mysqli php-ldap php-zip php-fileinfo php-mbstring

대상 서버에 PHP7.0 설치

다운로드 받은 rpm 파일들을 tar로 묶어서 인터넷이 되지 않는 대상 서버에 복사합니다.

다운로드 받은 rpm 파일을 다음과 같이 순차적으로 설치합니다.

rpm -Uvh freetype-2.8-12.el7_6.1.x86_64.rpm
rpm -Uvh libjpeg-turbo-1.2.90-6.el7.x86_64.rpm
rpm -Uvh libxcb-1.13-1.el7.x86_64.rpm
rpm -Uvh fontconfig-2.13.0-4.3.el7.x86_64.rpm
rpm -Uvh libX11-1.6.5-2.el7.x86_64.rpm
rpm -ivh libmcrypt-2.5.8-13.el7.x86_64.rpm
rpm -ivh libpng-1.5.13-7.el7_2.x86_64.rpm
rpm -ivh libtiff-4.0.3-27.el7_3.x86_64.rpm
rpm -ivh libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
rpm -ivh libwebp-0.3.0-7.el7.x86_64.rpm
rpm -ivh libzip5-1.5.1-1.el7.remi.x86_64.rpm
rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm
rpm -ivh apr-1.4.8-3.el7_4.1.x86_64.rpm
rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm
rpm -ivh dejavu-fonts-common-2.33-6.el7.noarch.rpm
rpm -ivh dejavu-sans-fonts-2.33-6.el7.noarch.rpm
rpm -ivh fontpackages-filesystem-1.44-8.el7.noarch.rpm
rpm -ivh gd-last-2.2.5-5.el7.remi.x86_64.rpm
rpm -ivh jbigkit-libs-2.0-11.el7.x86_64.rpm
rpm -ivh libX11-common-1.6.5-2.el7.noarch.rpm
rpm -ivh libXau-1.0.8-2.1.el7.x86_64.rpm
rpm -ivh libXpm-3.5.12-1.el7.x86_64.rpm
rpm -ivh httpd-tools-2.4.6-88.el7.centos.x86_64.rpm
rpm -ivh httpd-2.4.6-88.el7.centos.x86_64.rpm
rpm -Uvh php*

다음은 위 rpm 들의 설치 과정입니다.

[root@webbuilderWEB php70]# rpm -Uvh freetype-2.8-12.el7_6.1.x86_64.rpm
경고: freetype-2.8-12.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:freetype-2.8-12.el7_6.1          ################################# [ 50%]
Cleaning up / removing...
   2:freetype-2.4.11-15.el7           ################################# [100%]
[root@webbuilderWEB php70]# rpm -Uvh libjpeg-turbo-1.2.90-6.el7.x86_64.rpm
경고: libjpeg-turbo-1.2.90-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:libjpeg-turbo-1.2.90-6.el7       ################################# [ 50%]
Cleaning up / removing...
   2:libjpeg-turbo-1.2.90-5.el7       ################################# [100%]
[root@webbuilderWEB php70]# rpm -Uvh libxcb-1.13-1.el7.x86_64.rpm
경고: libxcb-1.13-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:libxcb-1.13-1.el7                ################################# [ 50%]
Cleaning up / removing...
   2:libxcb-1.12-1.el7                ################################# [100%]
[root@webbuilderWEB php70]# rpm -Uvh fontconfig-2.13.0-4.3.el7.x86_64.rpm
경고: fontconfig-2.13.0-4.3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:fontconfig-2.13.0-4.3.el7        ################################# [ 50%]
Cleaning up / removing...
   2:fontconfig-2.10.95-11.el7        ################################# [100%]
[root@webbuilderWEB php70]# rpm -Uvh libX11-1.6.5-2.el7.x86_64.rpm
경고: libX11-1.6.5-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
오류: Failed dependencies:
        libX11-common >= 1.6.5-2.el7 is needed by libX11-1.6.5-2.el7.x86_64
[root@webbuilderWEB php70]# rpm -ivh libmcrypt-2.5.8-13.el7.x86_64.rpm
경고: libmcrypt-2.5.8-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:libmcrypt-2.5.8-13.el7           ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh libpng-1.5.13-7.el7_2.x86_64.rpm
경고: libpng-1.5.13-7.el7_2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libpng-2:1.5.13-7.el7_2.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libtiff-4.0.3-27.el7_3.x86_64.rpm
경고: libtiff-4.0.3-27.el7_3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libtiff-4.0.3-27.el7_3.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
경고: libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libtool-ltdl-2.4.2-22.el7_3.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libwebp-0.3.0-7.el7.x86_64.rpm
경고: libwebp-0.3.0-7.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libwebp-0.3.0-7.el7.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libzip5-1.5.1-1.el7.remi.x86_64.rpm
경고: libzip5-1.5.1-1.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:libzip5-1.5.1-1.el7.remi         ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm
경고: mailcap-2.1.41-2.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:mailcap-2.1.41-2.el7             ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh apr-1.4.8-3.el7_4.1.x86_64.rpm
경고: apr-1.4.8-3.el7_4.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:apr-1.4.8-3.el7_4.1              ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm
경고: apr-util-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:apr-util-1.5.2-6.el7             ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh dejavu-fonts-common-2.33-6.el7.noarch.rpm
경고: dejavu-fonts-common-2.33-6.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        dejavu-fonts-common-2.33-6.el7.noarch* a
[root@webbuilderWEB php70]# rpm -ivh dejavu-sans-fonts-2.33-6.el7.noarch.rpm
경고: dejavu-sans-fonts-2.33-6.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        dejavu-sans-fonts-2.33-6.el7.noarch* a
[root@webbuilderWEB php70]# rpm -ivh fontpackages-filesystem-1.44-8.el7.noarch.rpm
경고: fontpackages-filesystem-1.44-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        fontpackages-filesystem-1.44-8.el7.noarch* a
[root@webbuilderWEB php70]# rpm -ivh gd-last-2.2.5-5.el7.remi.x86_64.rpm
경고: gd-last-2.2.5-5.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:gd-last-2.2.5-5.el7.remi         ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh jbigkit-libs-2.0-11.el7.x86_64.rpm
경고: jbigkit-libs-2.0-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        jbigkit-libs-2.0-11.el7.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libX11-common-1.6.5-2.el7.noarch.rpm
경고: libX11-common-1.6.5-2.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:libX11-common-1.6.5-2.el7        ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh libXau-1.0.8-2.1.el7.x86_64.rpm
경고: libXau-1.0.8-2.1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libXau-1.0.8-2.1.el7.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh libXpm-3.5.12-1.el7.x86_64.rpm
경고: libXpm-3.5.12-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
        libXpm-3.5.12-1.el7.x86_64* a
[root@webbuilderWEB php70]# rpm -ivh httpd-tools-2.4.6-88.el7.centos.x86_64.rpm
경고: httpd-tools-2.4.6-88.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:httpd-tools-2.4.6-88.el7.centos  ################################# [100%]
[root@webbuilderWEB php70]# rpm -ivh httpd-2.4.6-88.el7.centos.x86_64.rpm
경고: httpd-2.4.6-88.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:httpd-2.4.6-88.el7.centos        ################################# [100%]
[root@webbuilderWEB php70]# rpm -Uvh php*
경고: php-7.0.33-2.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
준비 중...                         ################################# [100%]
Updating / installing...
   1:php-json-7.0.33-2.el7.remi       ################################# [  9%]
   2:php-common-7.0.33-2.el7.remi     ################################# [ 18%]
   3:php-cli-7.0.33-2.el7.remi        ################################# [ 27%]
   4:php-pdo-7.0.33-2.el7.remi        ################################# [ 36%]
   5:php-mysqlnd-7.0.33-2.el7.remi    ################################# [ 45%]
   6:php-7.0.33-2.el7.remi            ################################# [ 55%]
   7:php-gd-7.0.33-2.el7.remi         ################################# [ 64%]
   8:php-ldap-7.0.33-2.el7.remi       ################################# [ 73%]
   9:php-mbstring-7.0.33-2.el7.remi   ################################# [ 82%]
  10:php-mcrypt-7.0.33-2.el7.remi     ################################# [ 91%]
  11:php-pecl-zip-1.15.4-1.el7.remi.7.################################# [100%]

설치된 apache, php 버전을 확인해 보면 다음과 같습니다.

[root@webbuilderWEB php70]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09
[root@webbuilderWEB php70]# php -v
PHP 7.0.33 (cli) (built: Jan  9 2019 14:57:19) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

httpd 아파치 서비스는 다음과 같이 활성화합니다.

systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

httpd 아파치 서비스는 다음과 같이 시작합니다.

systemctl start httpd