1. 빌드 환경 설정
yum install -y libjpeg libjpeg-devel libjpeg-turbo-devel gd gd-devel gdbm-devel php-mbstring libexif-devel libmcrypt libmcrypt-devel libvpx libvpx-devel libXpm libXpm-devel icu libicu libicu-devel t1lib t1lib-devel gmp-devel mhash* gettext gettext-devel libtidy libtidy-devel libxslt libxslt-devel libedit-devel libc-client libc-client-devel pam-devel readline-devel libpng libpng-devel krb5-devel db4-devel expat*
1-1. libmcrypt & libmcrypt-devel 패키지 설치
CentOS에서는 위 패키지가 yum에 포함되어있지 않아 직접 설치해야 한다. Ubuntu는 확인하지 못했는데 apt-get으로 된다면 그렇게 설치하면 된다.
cd /usr/local/src
wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-2.5.8-9.puias6.x86_64.rpm
wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
rpm -ivh libmcrypt-2.5.8-9.puias6.x86_64.rpm
rpm -ivh libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
2. MySQL 라이브러리 참조
cd /usr/local/mysql
ln -s lib lib64
3. PHP 다운로드 및 컴파일
cd /usr/local/src
wget http://am1.php.net/get/php-5.6.25.tar.gz/from/this/mirror
tar xvfz mirror
cd php-5.6.25
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/apache/conf \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-regex=php \
--with-libxml-dir=/usr \
--with-openssl --with-pcre-regex --with-zlib \
--with-bz2 --with-curl --with-gdbm \
--with-db4=/usr --with-dbm --with-pcre-dir=/usr --with-openssl-dir=/usr \
--with-libxml-dir=/usr --with-gd --with-vpx-dir=/usr --with-jpeg-dir=/usr \
--with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr \
--with-t1lib=/usr --with-gettext --with-gmp --with-mhash --with-imap \
--with-imap-ssl --with-kerberos --with-icu-dir=/usr --with-ldap \
--with-ldap-sasl --with-libmbfl --with-onig --with-mcrypt \
--with-libedit --with-readline --with-tidy --with-libexpat-dir=/usr \
--with-xmlrpc --with-xsl --with-pear --with-pic --with-libdir=lib64 \
--enable-bcmath --enable-calendar --enable-exif \
--enable-ftp --enable-pcntl --enable-gd-native-ttf \
--enable-gd-jis-conv --enable-intl --enable-mbstring \
--enable-shmop --enable-sockets --enable-sysvmsg \
--enable-sysvsem --enable-sysvshm --enable-wddx \
--enable-zip --enable-mysqlnd --enable-dba=shared \
--enable-mod-charset --enable-dom --enable-mbregex \
--enable-inline-optimization --enable-sigchild --enable-soap \
--enable-maintainer-zts --enable-opcache=nom
make
(** make시 오류해결)
https://zetawiki.com/wiki/CentOS_php-pear_%EC%84%A4%EC%B9%98
"php설치시 “PEAR package PHP_Archive not installed” 오류 관련 참고"
make후 pear 패키지 install failed 뜨면 위와 같이 따로 설치해주면 된다
make install
4. PHP 환경설정
cp php.ini-production /etc/httpd/php.ini
vi /etc/httpd/php.ini
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Module Settings;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[Date]
date.timezone = "Asia/Seoul"
5. Apache 환경설정
vi /usr/local/apache/conf/httpd.conf
# httpd.conf 내에서 PHP모듈이 정상적으로 추가되어있는지 확인 (자동으로 연동되어 등록됨)
LoadModule php5_module modules/libphp5.so
#<IfModule dir_module>을 찾아 아래 내용 추가
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php index.cgi
</IfModule>
#<IfModule mime_module> 을 찾아 아래 내용 추가
<IfModule mime_module>
AddType application/x-compress . z
AddType application/x-gzip . gz . tgz
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml .html .htm .inc
AddType application/x-httpd-source .phps
</IfModule>
#httpd.conf 저장한 뒤
/etc/init.d/httpd restart
6. 환경변수 등록
cd ~
vi .bash_profile
#PATH부분에 아래 내용을 추가한다
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin
#.bash_profile 저장한 뒤
source .bash_profile
7. 연동 확인
vi /usr/local/apache/htdocs/phpinfo.php
<? php
phpinfo();
?>
# 입력 후 저장
8. /etc/httpd/php.ini 수정
https://jguru-study.tistory.com/31
short_open_tag = on
수정 저장후
service httpd restart
[참고사이트]
https://jguru-study.tistory.com/29
https://jguru-study.tistory.com/30
https://jguru-study.tistory.com/31