OS/Linux

php 5.5 이상 설치 on centos

아르비스 2016. 1. 5. 15:00

yum 으로 centos에서 php를 설치할 경우 아래와 같은 버전으로 설치된다.


> yum -y install php


 PHP Current Version

 CentOS 7.0-1406

 CentOS 6.6

 5.6.4

 5.4.16

 5.3.3


다른(이후) 버전 설치는 쉽지 않으므로, 

그냥 해당 버전 download 후 build 하는 것이 쉬움.



[수동 설치 방법]


Download PHP file : http://php.net/downloads.php

Ø  tar -zxvf php-5.6.3.tar.gz

cd /root/scr/php-5.6.3/

[root@php-5.6.3]# ./configure \

--prefix=/usr/local/php \

--with-libdir=lib64 \

--with-apxs2=/usr/local/apache/bin/apxs \

--enable-sysvshm=yes \

--enable-debug=no \

--with-iconv \

--with-png-dir \

--with-zlib-dir \

--with-gd \

--enable-gd-native-ttf \

--with-jpeg \

--enable-exif \

--with-freetype \

--enable-ftp \

--enable-mbstring \

--enable-sockets \

--enable-wddx \

--with-freetype-dir \

--enable-bcmath \

--enable-exif \

--enable-calendar \

--with-libxml-dir \

--with-xmlrpc \

--with-mysqli \

--with-pdo-mysql \

--with-mysql-sock=/var/mysql/mysql.sock \

--with-gettext

[root@php-5.6.3]# make && make install




[PHP.ini 설정]

[root@php-5.6.3]# cp php.ini–production /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/register_globals = Off/register_globals = on/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/upload_max_filesize = 2M/upload_max_filesize = 8M/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/allow_url_fopen = On/allow_url_fopen = Off/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/short_open_tag = Off/short_open_tag = On/g" /usr/local/php/lib/php.ini

[root@php-5.6.3]# perl -pi -e "s/;data.timezon = /data.timezone = Asia\/\Seoul/g" /usr/local/php/lib/php.ini

 

[root@php-5.6.3]# perl -pi -e "s/memory_limit = 128M/ memory_limit = 512M/g" /usr/local/php/lib/php.ini

 

[root@linux14 bin]# PATH=$PATH:./usr/local/php/bin

[root@linux14 bin]# echo $PATH

/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:.:/usr/local/php/bin


 

[root@linux14 bin]# vi /usr/local/apache/conf/httpd.conf

LoadModule php5_module  modules/libphp5.so

AddHandler php5-script  .php

 

DirectoryIndex index.html index.php

 

AddType text/html   .php

 

AddType application/x-httpd-php-source phps

[root@linux14 bin]# /usr/local/apache/bin/httpd restart