LINUX

CentOS7 php 설치하기

지니 2017. 3. 22. 16:02
반응형



이글은 CentOS Linux release 7.3.1611 (Core)  서버에서 작업되었습니다.



설치가 되어있을때 , 버전이 나온다.

[root@cobuy-0884 ~]# php -v

PHP 5.2.16 (cli) (built: Jul  2 2016 23:09:09) 

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies

    with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies

You have new mail in /var/spool/mail/root



설치가 되어있지 않을때 , php 명령어를 알수 없다고 나온다.

[root@cobuy-0938 bin]# php -v

-bash: php: command not found




방법 1. yum 을 이용한 설치

(저는 다루지 않습니다.)


방법 2. 패키지를 이용한 설치


http://pikabu.tistory.com/54

(위 주소가 매우잘 설명되어있다.)


1. yum -y install epel-release

명령 실행

Complete! 명령이 나온다면 다음으로~


2. cd /etc/yum.repos.d 경로로 이동


[root@cobuy-0938 bin]# cd /etc/yum.repos.d/

[root@cobuy-0938 yum.repos.d]# pwd

/etc/yum.repos.d


3. wget http://rpms.famillecollet.com/enterprise/remi.repo

(wget = 네트워크 상에서 데이터를 다운로드 받는다)

https://www.joinc.co.kr/w/man/1/wget

(위 주소에서 'wget' 에 대해 설명되어있다.)


[root@cobuy-0938 yum.repos.d]# wget http://rpms.famillecollet.com/enterprise/remi.repo

--2017-03-23 00:48:05--  http://rpms.famillecollet.com/enterprise/remi.repo

Resolving rpms.famillecollet.com (rpms.famillecollet.com)... 195.154.241.117, 



----이하 생략



4. php 버전 설치


저는 php 5.6 버전을 설치하겠습니다.


(다른 버전을 설치할 것이라면 저와 명령문을 조금만 다르게 주시면 됩니다.)


http://rpms.famillecollet.com/enterprise/remi.repo 주소로 들어가보면 


아래 이미지와 같이



[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/$releasever/php55/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/$releasever/php55/mirror
enabled=0
gpgcheck=1
gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/$releasever/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/$releasever/php56/mirror
enabled=0
gpgcheck=1
gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi

[remi-php70]
name=Remi's PHP 7.0 RPM repository for Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/$releasever/php70/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/$releasever/php70/mirror
# WARNING: Only available for RHEL/CentOS >= 6
enabled=0
gpgcheck=1
gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi

이렇게 들어있습니다.


저는 5.6 버전을 설치할것이기 때문에



5. yum -y --enablerepo=remi,remi-php56 install httpd php php-common


만약 다른 버전이라면 

ex)) 7.0

yum -y --enablerepo=remi,remi-php70 install httpd php php-common


이런식으로 실행


명령 실행



//-- 로그 --//

[root@cobuy-0938 yum.repos.d]# yum -y --enablerepo=remi,remi-php56 install httpd php php-common


langpacks

epel/x86_64/metalink                                                                                         | 4.8 kB  00:00:00     

epel                                                                                                         | 4.3 kB  00:00:00     

remi                                                                                                         | 2.9 kB  00:00:00     

remi-php56                                                                                                   | 2.9 kB  00:00:00     

remi-safe                                                                                                    | 2.9 kB  00:00:00     

(1/6): epel/x86_64/updateinfo                                                                                | 759 kB  00:00:00     

(2/6): remi/7/primary_db                                                                                     | 1.6 MB  00:00:02     

(3/6): remi-php56/7/primary_db                                                                               | 212 kB  00:00:02     

(4/6): epel/x86_64/primary_db                                                                                | 4.6 MB  00:00:03     

(5/6): epel/x86_64/group_gz                                                                                  | 170 kB  00:00:03     

(6/6): remi-safe/7/primary_db                                                                                | 917 kB  00:00:04     

Loading mirror speeds from cached hostfile

 * base: ftp.daumkakao.com

 * epel: mirror01.idc.hinet.net

 * extras: ftp.daumkakao.com

 * remi: mirrors.thzhost.com

 * remi-php56: mirrors.thzhost.com

 * remi-safe: mirrors.thzhost.com

 * updates: ftp.daumkakao.com

Package httpd-2.4.6-45.el7.centos.x86_64 already installed and latest version

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.6.30-1.el7.remi will be installed

--> Processing Dependency: php-cli(x86-64) = 5.6.30-1.el7.remi for package: php-5.6.30-1.el7.remi.x86_64

---> Package php-common.x86_64 0:5.6.30-1.el7.remi will be installed

--> Processing Dependency: php-pecl-zip(x86-64) for package: php-common-5.6.30-1.el7.remi.x86_64

--> Processing Dependency: php-pecl-jsonc(x86-64) for package: php-common-5.6.30-1.el7.remi.x86_64

--> Running transaction check

---> Package php-cli.x86_64 0:5.6.30-1.el7.remi will be installed

---> Package php-pecl-jsonc.x86_64 0:1.3.10-2.el7.remi.5.6 will be installed

---> Package php-pecl-zip.x86_64 0:1.13.5-1.el7.remi.5.6 will be installed

--> Processing Dependency: libzip.so.4()(64bit) for package: php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64

--> Running transaction check

---> Package libzip-last.x86_64 0:1.1.3-1.el7.remi will be installed

--> Finished Dependency Resolution


Dependencies Resolved


====================================================================================================================================

 Package                         Arch                    Version                                  Repository                   Size

====================================================================================================================================

Installing:

 php                             x86_64                  5.6.30-1.el7.remi                        remi-php56                  2.6 M

 php-common                      x86_64                  5.6.30-1.el7.remi                        remi-php56                  1.1 M

Installing for dependencies:

 libzip-last                     x86_64                  1.1.3-1.el7.remi                         remi                         45 k

 php-cli                         x86_64                  5.6.30-1.el7.remi                        remi-php56                  4.0 M

 php-pecl-jsonc                  x86_64                  1.3.10-2.el7.remi.5.6                    remi-php56                   57 k

 php-pecl-zip                    x86_64                  1.13.5-1.el7.remi.5.6                    remi-php56                   58 k


Transaction Summary

====================================================================================================================================

Install  2 Packages (+4 Dependent packages)


Total download size: 7.9 M

Installed size: 30 M

Downloading packages:

warning: /var/cache/yum/x86_64/7/remi/packages/libzip-last-1.1.3-1.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY

Public key for libzip-last-1.1.3-1.el7.remi.x86_64.rpm is not installed

(1/6): libzip-last-1.1.3-1.el7.remi.x86_64.rpm                                                               |  45 kB  00:00:01     

Public key for php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64.rpm is not installed                   ] 724 kB/s | 2.3 MB  00:00:07 ETA 

(2/6): php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64.rpm                                                       |  57 kB  00:00:01     

(3/6): php-5.6.30-1.el7.remi.x86_64.rpm                                                                      | 2.6 MB  00:00:01     

(4/6): php-common-5.6.30-1.el7.remi.x86_64.rpm                                                               | 1.1 MB  00:00:02     

(5/6): php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64.rpm                                                         |  58 kB  00:00:01     

(6/6): php-cli-5.6.30-1.el7.remi.x86_64.rpm                                                                  | 4.0 MB  00:00:05     

------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                               1.4 MB/s | 7.9 MB  00:00:05     

Retrieving key from http://rpms.remirepo.net/RPM-GPG-KEY-remi

Importing GPG key 0x00F97F56:

 Userid     : "Remi Collet <RPMS@FamilleCollet.com>"

 Fingerprint: 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56

 From       : http://rpms.remirepo.net/RPM-GPG-KEY-remi

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : libzip-last-1.1.3-1.el7.remi.x86_64                                                                              1/6 

  Installing : php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64                                                                      2/6 


WARNING : These php-* RPMs are not official Fedora / Red Hat build and

overrides the official ones. Don't file bugs on Fedora Project nor Red Hat.


Use dedicated forum at http://forum.remirepo.net/


  Installing : php-common-5.6.30-1.el7.remi.x86_64                                                                              3/6 

  Installing : php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64                                                                        4/6 

  Installing : php-cli-5.6.30-1.el7.remi.x86_64                                                                                 5/6 

  Installing : php-5.6.30-1.el7.remi.x86_64                                                                                     6/6 

  Verifying  : php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64                                                                        1/6 

  Verifying  : libzip-last-1.1.3-1.el7.remi.x86_64                                                                              2/6 

  Verifying  : php-cli-5.6.30-1.el7.remi.x86_64                                                                                 3/6 

  Verifying  : php-5.6.30-1.el7.remi.x86_64                                                                                     4/6 

  Verifying  : php-common-5.6.30-1.el7.remi.x86_64                                                                              5/6 

  Verifying  : php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64                                                                      6/6 


Installed:

  php.x86_64 0:5.6.30-1.el7.remi                                php-common.x86_64 0:5.6.30-1.el7.remi                               


Dependency Installed:

  libzip-last.x86_64 0:1.1.3-1.el7.remi         php-cli.x86_64 0:5.6.30-1.el7.remi   php-pecl-jsonc.x86_64 0:1.3.10-2.el7.remi.5.6  

  php-pecl-zip.x86_64 0:1.13.5-1.el7.remi.5.6  


Complete!


//-- 로그 --//




6. php 설치여부 확인


php -v


명령 실행




[root@cobuy-0938 yum.repos.d]# php -v

PHP 5.6.30 (cli) (built: Jan 19 2017 07:57:06) 

Copyright (c) 1997-2016 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies




설치완료





반응형