CentOS 7 에 php 설치하기

by 조쉬 posted Jul 16, 2015
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

CentOS 7 에 php 설치하기 (디비와 아파치를 설치한후 마지막에 php를 설치한다.)

 

 

설치 가능한 php 버전을 확인해 본다.

확인해 보니 버전이 php 5.4.16 이다. 

[root@localhost ~]# yum list | grep php

graphviz-php.x86_64                     2.30.1-18.el7                  base     

php.x86_64                              5.4.16-23.el7_0.3              updates  

php-bcmath.x86_64                       5.4.16-23.el7_0.3              updates  

php-cli.x86_64                          5.4.16-23.el7_0.3              updates  

php-common.x86_64                       5.4.16-23.el7_0.3              updates  

php-dba.x86_64                          5.4.16-23.el7_0.3              updates  

php-devel.x86_64                        5.4.16-23.el7_0.3              updates  

php-embedded.x86_64                     5.4.16-23.el7_0.3              updates  

php-enchant.x86_64                      5.4.16-23.el7_0.3              updates  

php-fpm.x86_64                          5.4.16-23.el7_0.3              updates  

php-gd.x86_64                           5.4.16-23.el7_0.3              updates  

php-intl.x86_64                         5.4.16-23.el7_0.3              updates  

php-ldap.x86_64                         5.4.16-23.el7_0.3              updates  

php-mbstring.x86_64                     5.4.16-23.el7_0.3              updates  

php-mysql.x86_64                        5.4.16-23.el7_0.3              updates  

php-mysqlnd.x86_64                      5.4.16-23.el7_0.3              updates  

php-odbc.x86_64                         5.4.16-23.el7_0.3              updates  

php-pdo.x86_64                          5.4.16-23.el7_0.3              updates  

php-pear.noarch                         1:1.9.4-21.el7                 base     

php-pecl-memcache.x86_64                3.0.8-4.el7                    base     

php-pgsql.x86_64                        5.4.16-23.el7_0.3              updates  

php-process.x86_64                      5.4.16-23.el7_0.3              updates  

php-pspell.x86_64                       5.4.16-23.el7_0.3              updates  

php-recode.x86_64                       5.4.16-23.el7_0.3              updates  

php-snmp.x86_64                         5.4.16-23.el7_0.3              updates  

php-soap.x86_64                         5.4.16-23.el7_0.3              updates  

php-xml.x86_64                          5.4.16-23.el7_0.3              updates  

php-xmlrpc.x86_64                       5.4.16-23.el7_0.3              updates  

rrdtool-php.x86_64                      1.4.8-8.el7                    base     

uuid-php.x86_64                         1.6.2-26.el7                   base     

 

 

php를 설치한다.

중간에 y를 선택해 준다. 연관 패키지이다.

 

[root@localhost ~]# yum install php php-mysql php-gd php-pear

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

 * base: centos.tt.co.kr

 * extras: centos.tt.co.kr

 * updates: centos.tt.co.kr

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.4.16-23.el7_0.3 will be installed

--> Processing Dependency: php-common(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64

--> Processing Dependency: php-cli(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64

---> Package php-gd.x86_64 0:5.4.16-23.el7_0.3 will be installed

--> Processing Dependency: libt1.so.5()(64bit) for package: php-gd-5.4.16-23.el7_0.3.x86_64

---> Package php-mysql.x86_64 0:5.4.16-23.el7_0.3 will be installed

--> Processing Dependency: php-pdo(x86-64) = 5.4.16-23.el7_0.3 for package: php-mysql-5.4.16-23.el7_0.3.x86_64

---> Package php-pear.noarch 1:1.9.4-21.el7 will be installed

--> Processing Dependency: php-xml for package: 1:php-pear-1.9.4-21.el7.noarch

--> Processing Dependency: php-posix for package: 1:php-pear-1.9.4-21.el7.noarch

--> Running transaction check

---> Package php-cli.x86_64 0:5.4.16-23.el7_0.3 will be installed

---> Package php-common.x86_64 0:5.4.16-23.el7_0.3 will be installed

--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-23.el7_0.3.x86_64

---> Package php-pdo.x86_64 0:5.4.16-23.el7_0.3 will be installed

---> Package php-process.x86_64 0:5.4.16-23.el7_0.3 will be installed

---> Package php-xml.x86_64 0:5.4.16-23.el7_0.3 will be installed

---> Package t1lib.x86_64 0:5.1.2-14.el7 will be installed

--> Running transaction check

---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

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

 Package            Arch          Version                  Repository      Size

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

Installing:

 php                x86_64        5.4.16-23.el7_0.3        updates        1.3 M

 php-gd             x86_64        5.4.16-23.el7_0.3        updates        124 k

 php-mysql          x86_64        5.4.16-23.el7_0.3        updates         97 k

 php-pear           noarch        1:1.9.4-21.el7           base           357 k

Installing for dependencies:

 libzip             x86_64        0.10.1-8.el7             base            48 k

 php-cli            x86_64        5.4.16-23.el7_0.3        updates        2.7 M

 php-common         x86_64        5.4.16-23.el7_0.3        updates        561 k

 php-pdo            x86_64        5.4.16-23.el7_0.3        updates         95 k

 php-process        x86_64        5.4.16-23.el7_0.3        updates         52 k

 php-xml            x86_64        5.4.16-23.el7_0.3        updates        122 k

 t1lib              x86_64        5.1.2-14.el7             base           166 k

 

Transaction Summary

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

Install  4 Packages (+7 Dependent packages)

 

Total download size: 5.7 M

Installed size: 21 M

Is this ok [y/d/N]: y

Downloading packages:

(1/11): libzip-0.10.1-8.el7.x86_64.rpm                     |  48 kB   00:00     

(2/11): php-5.4.16-23.el7_0.3.x86_64.rpm                   | 1.3 MB   00:01     

(3/11): php-gd-5.4.16-23.el7_0.3.x86_64.rpm                | 124 kB   00:01     

(4/11): php-pdo-5.4.16-23.el7_0.3.x86_64.rpm               |  95 kB   00:00     

(5/11): php-common-5.4.16-23.el7_0.3.x86_64.rpm            | 561 kB   00:01     

(6/11): php-process-5.4.16-23.el7_0.3.x86_64.rpm           |  52 kB   00:00     

(7/11): php-xml-5.4.16-23.el7_0.3.x86_64.rpm               | 122 kB   00:00     

(8/11): php-mysql-5.4.16-23.el7_0.3.x86_64.rpm             |  97 kB   00:00     

(9/11): php-pear-1.9.4-21.el7.noarch.rpm                   | 357 kB   00:00     

(10/11): php-cli-5.4.16-23.el7_0.3.x86_64.rpm              | 2.7 MB   00:01     

(11/11): t1lib-5.1.2-14.el7.x86_64.rpm                     | 166 kB   00:00     

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

Total                                              2.7 MB/s | 5.7 MB  00:02     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : libzip-0.10.1-8.el7.x86_64                                  1/11 

  Installing : php-common-5.4.16-23.el7_0.3.x86_64                         2/11 

  Installing : php-cli-5.4.16-23.el7_0.3.x86_64                            3/11 

  Installing : php-pdo-5.4.16-23.el7_0.3.x86_64                            4/11 

  Installing : php-process-5.4.16-23.el7_0.3.x86_64                        5/11 

  Installing : php-xml-5.4.16-23.el7_0.3.x86_64                            6/11 

  Installing : t1lib-5.1.2-14.el7.x86_64                                   7/11 

  Installing : php-gd-5.4.16-23.el7_0.3.x86_64                             8/11 

  Installing : 1:php-pear-1.9.4-21.el7.noarch                              9/11 

  Installing : php-mysql-5.4.16-23.el7_0.3.x86_64                         10/11 

  Installing : php-5.4.16-23.el7_0.3.x86_64                               11/11 

  Verifying  : php-common-5.4.16-23.el7_0.3.x86_64                         1/11 

  Verifying  : php-pdo-5.4.16-23.el7_0.3.x86_64                            2/11 

  Verifying  : t1lib-5.1.2-14.el7.x86_64                                   3/11 

  Verifying  : php-process-5.4.16-23.el7_0.3.x86_64                        4/11 

  Verifying  : php-5.4.16-23.el7_0.3.x86_64                                5/11 

  Verifying  : php-gd-5.4.16-23.el7_0.3.x86_64                             6/11 

  Verifying  : php-xml-5.4.16-23.el7_0.3.x86_64                            7/11 

  Verifying  : php-mysql-5.4.16-23.el7_0.3.x86_64                          8/11 

  Verifying  : php-cli-5.4.16-23.el7_0.3.x86_64                            9/11 

  Verifying  : libzip-0.10.1-8.el7.x86_64                                 10/11 

  Verifying  : 1:php-pear-1.9.4-21.el7.noarch                             11/11 

 

Installed:

  php.x86_64 0:5.4.16-23.el7_0.3           php-gd.x86_64 0:5.4.16-23.el7_0.3    

  php-mysql.x86_64 0:5.4.16-23.el7_0.3     php-pear.noarch 1:1.9.4-21.el7       

 

Dependency Installed:

  libzip.x86_64 0:0.10.1-8.el7             php-cli.x86_64 0:5.4.16-23.el7_0.3  

  php-common.x86_64 0:5.4.16-23.el7_0.3    php-pdo.x86_64 0:5.4.16-23.el7_0.3  

  php-process.x86_64 0:5.4.16-23.el7_0.3   php-xml.x86_64 0:5.4.16-23.el7_0.3  

  t1lib.x86_64 0:5.1.2-14.el7             

 

Complete!

설치가 완료 되었다.

 

 

아파치를 재시작해 준다.

[root@localhost ~]# systemctl restart httpd.service

 

 

홈페이지에서 php 정보를 확인하기 위해 info.php 파일을 만든다.

[root@localhost ~]# vi /var/www/html/info.php

내용은 아래와 같이 입력한다.

<?php

   phpinfo();

?>

참고로 저장하고 빠져 나올때는 ESC 키를 누른 후에 손을 땐후

:wq

입력하면 저장후 빠져 나온다.

 

아파치를 재시작해 준다.

[root@localhost ~]# systemctl restart httpd.service

 

 

CentOS에 깔려 있는 브라우저 파이어 폭스를 실행해서 php 정보를 확인해 본다.

주소창에 입력

localhost/info.php

 

참고사항

PHP 설치 경로 : /usr/lib64/php

PHP 설정파일 경로 :  /etc/php.ini