CentOS 7 PHP 5.3.29 소스 컴파일 설치

## PHP 설치 전 필수 조건
cd /usr/local/src/
yum install -y wget vim epel-release
얌 설치 -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
얌 업데이트 -y

## CentOS 7의 기본 환경 변수 설정
에코 ” ” >> /etc/profile
echo “####default PATH#####” >> /etc/profile
echo “내보내기 경로=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:” >> /etc/profile
에코 “#####################” >> /etc/profile

## 소스 설치를 위한 패키지 환경 설치
yum 설치 -y libdb-devel enchant-devel libxslt libxslt-devel net-snmp-devel readline-devel readline aspell-devel unixODBC unixODBC-devel libicu-devel icu libicu libc-client libc-client-devel libc-client-2007f freetype- devel freetype* freetype libXpm libXpm-devel libpng-devel libpng* libvpx-devel libvpx libcurl libcurl-devel curl* curl-devel curl tcp_wrappers-devel libzip 환경 모듈 uw-imap-utils uw-imap-devel uw-imap uw-imap -정적 pam-devel libldb-devel openldap-devel cyrus-sasl-devel bzip2-devel bzip2 bzip2-libs ncurses-devel ncurses mysql-devel libjpeg-devel libjpeg* libjpeg-devel openssl-devel openssl* openssl-libs libxml* libxml2 libxml2 -devel libmcrypt libmcrypt-devel libmcrypt* mcrypt mhash* mhash mhash-devel libmhash libmhash-devel expat-devel expat expat* gmp* gmp gmp-devel krb5* krb5-devel db4 db4-devel wget make cmake libtool* pcre* gdbm* gdbm gdbm-devel libtiff* libtiff libtiff-devel 플렉스 zlib* zlib-devel zlib gd* gd gd-devel 패치 t1lib t1lib-devel readline l ibe dit-devel libtidy libtidy-devel gcc* gcc gcc-c++ libtermcap-devel dialog sqlite-devel oniguruma oniguruma-devel libzip5 mod_ssl postgresql-devel lcov systemtap-sdt-devel mod_ldap elfutils-devel libwebp-devel libwebp git gzip libnghttp2-devel valgrind * mod_proxy* editline editline-devel patchelf systemd-devel ImageMagick-devel libzstd-devel libffi libffi-devel libraqm-devel libraqm libsodium libsodium-devel

## CentOS 6 이하용 라이브러리 설정
mkdir /usr/kerberos
ln -s /usr/lib64 /usr/kerberos/lib

## PHP imap 관련 모듈 64비트 32비트 라이브러리 호환성 설정
ln -s /usr/lib64/libc-client.a /usr/lib/libc-client.a
/usr/include/db.h를 분리합니다.


ln -s /usr/include/libdb4/db.h /usr/include/db.h
ln -s /usr/include/sqlext.h /usr/local/include/sqlext.h
ln -s /usr/lib64/libgdbm_compat.so /usr/local/lib64/libdbm.so

## OpenLDAP 호환
\cp -arpf /usr/lib64/libldap* /usr/lib/
ln -sf /usr/lib64/libm.so /usr/lib/libm.so
ln -sf /usr/lib64/libssl.so /usr/lib/libssl.so

## libXpm 모듈 32비트 호환
ln -s /usr/lib64/libXpm.so /usr/lib/
ln -s /usr/lib64/libXpm.so.4 /usr/lib/
ln -s /usr/lib64/libXpm.so.4.11.0 /usr/lib/

## PHP 이미지 모듈 64비트 32비트 라이브러리 호환성 설정
ln -s /usr/lib64/libjpeg.so /usr/lib
ln -s /usr/lib64/libpng.so /usr/lib

## PHP 다운로드 및 배포

cd /usr/local/src/APM_Setup
wget https://www.php.net/distributions/php-5.3.29.tar.gz
wget http://museum.php.net/php5/php-5.3.29.tar.gz
wget https://mirror.cogentco.com/pub/php/php-5.3.29.tar.gz
타르 zxvf php-5.3.29.tar.gz
cd /usr/local/src/APM_Setup/php-5.3.29

## PHP 컴파일 설정

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/apache/conf –disable-debug –with-pcre-dir=/usr/local/pcre /bin/pcre-config –enable-bcmath –enable-mod-charset –with-iconv-dir –enable-sigchild –enable-magic-quotes –with-libxml-dir –with-xmlrpc – -enable-xmlwriter –with-openssl –with-openssl-dir –with-pcre-regex –with-zlib –with-zlib-dir –with-bz2 –enable-calendar –with-curl –enable-dba –with-pspell –with-dbm –with-gdbm –enable-exif –enable-fileinfo –enable-filter –enable-ftp –with-gd –enable-gd -native-ttf –enable-gd-jis-conv –with-jpeg-dir –with-png-dir –with-freetype-dir –with-xpm-dir –enable-shmop –with- imap –with-imap-ssl –with-kerberos –enable-mbstring –enable-mbregex –enable-mbregex-backtrack –with-onig –with-mcrypt –enable-sockets –with-regex =php –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-json –with-tidy –enable-tokenizer –with-xsl –enable-wddx –enable-zend-multibyte – -활성화-zip –활성화-zi p –enable-soap –with-libmbfl –with-ldap-sasl –with-ldap –enable-intl –with-mhash –enable-hash –with-gmp –with-gettext – -with-t1lib –with-enchant –enable-phar –enable-posix –enable-libgcc –enable-safe-mode –with-snmp –enable-ucd-snmp-hack –with-libedit –with- readline –enable-simplexml –enable-xml –enable-session –enable-xmlreader –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd — enable-mysqlnd – -enable-embedded-mysqli –with-mysql-sock=/tmp/mysql.sock –enable-maintainer-zts –enable-zts –enable-roxen-zts –enable-fpm — with-fpm-user=nobody –with-fpm-group=nobody

## lber 라이브러리를 참조할 수 없으므로 강제 포함

sed -i ‘s/-lm -lcrypt/-lm -lcrypt -L/usr/lib64 -lstdc++ -llber/g’ /usr/local/src/APM_Setup/php-5.3.29/Makefile
할 -j
설치를 하다

## php.ini 구성 파일 변경

\cp -arpf php.ini-development /usr/local/apache/conf/php.ini
sed -i ‘s/;upload_tmp_dir =/upload_tmp_dir = \/tmp/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/upload_max_filesize=2M/upload_max_filesize=100M/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/post_max_size=8M/post_max_size=100M/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/memory_limit=128M/memory_limit=256M/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/allow_url_fopen = 켜기/allow_url_fopen = 끄기 /g’ /usr/local/apache/conf/php.ini
sed -i ‘s/expose_php=On/expose_php=Off/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/display_errors=Off/display_errors=On/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/log_errors=Off/log_errors=On/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/;error_log = syslog/error_log = syslog/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/short_open_tag=Off/short_open_tag=On/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/;date.timezone =/date.timezone = “아시아\/서울”/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/session.gc_maxlifetime = 1440 /session.gc_maxlifetime = “3600”/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/register_globals=Off/register_globals=On/g’ /usr/local/apache/conf/php.ini
sed -i ‘s/error_reporting = E_ALL | E_STRICT/error_reporting = E_ALL \& ~E_NOTICE \& ~E_DEPRECATED \& ~E_USER_DEPRECATED /g’ /usr/local/apache/conf/php.ini

## imagick 모듈 설치
cd /usr/local/src/APM_Setup
wget https://pecl.php.net/get/imagick-3.1.2.tgz
tar zxvf imagick-3.1.2.tgz
cd imagick-3.1.2
/usr/local/php/bin/phpize && ./configure –with-php-config=/usr/local/php/bin/php-config && make -j && make install
sed -i ‘s/extension_dir = /;extension_dir = /g’ /usr/local/apache/conf/php.ini
echo “extension_dir = \”/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/\”” >> /usr/local/apache/conf/php.ini
echo “extension=imagick.so” >> /usr/local/apache/conf/php.ini
에코 ” ” >> /usr/local/apache/conf/php.ini

## ZendGuardLoader 설치
에코 “”
echo “MPM 프리포크이므로 ZendGuardLoader가 설치됩니다.


에코 “”
cd /usr/local/src/APM_Setup
wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
\cp -arpf ./ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib
echo “zend_loader.enable=1” >> /usr/local/apache/conf/php.ini
echo “zend_extension=/usr/local/php/lib/ZendGuardLoader.so” >> /usr/local/apache/conf/php.ini

## Apache PHP 모듈 확인 및 재시작
Apachectl -M | grep PHP
/etc/init.d/apachectl 재시작

## php-fpm 구성 파일 및 데몬 구성

\cp -f /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
\cp -f /usr/local/src/APM_Setup/php-5.3.29/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm
\cp -f /usr/local/src/APM_Setup/php-5.3.29/sapi/fpm/php-fpm.service /lib/systemd/system/

sed -i ‘s/;log_level = 통지/log_level = 경고/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;emergency_restart_threshold = 0/emergency_restart_threshold = 5/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;emergency_restart_interval = 0/emergency_restart_interval = 30s/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;process_control_timeout=0/process_control_timeout=20/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/; process.max = 128/process.max = 1024/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/; process.priority = -19/process.priority = -19/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;listen.backlog=-1/listen.backlog=65535/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;listen.owner=nobody/listen.owner=nobody/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;listen.group=nobody/listen.group=nobody/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;listen.mode=0660/listen.mode=0660/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/pm=dynamic/pm=ondemand/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/pm.max_children = 5/pm.max_children = 50/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;pm.process_idle_timeout/pm.process_idle_timeout/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;access.log=log/access.log=/usr/local/php/var/log/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;access.format/access.format/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;slowlog/slowlog/g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s/;request_slowlog_timeout = 0/;request_slowlog_timeout = 30/g’ /usr/local/php/etc/php-fpm.conf

## APM 환경 변수 설정
다음 구성에는 Apache, MySQL 및 PHP 부분이 포함되어 있습니다.


에코 ” ” >> /etc/profile
echo “APACHE_HOME=/usr/local/apache” >> /etc/profile
echo “MySQL_HOME=/usr/local/mysql” >> /etc/profile
echo “PHP_HOME=/usr/local/php” >> /etc/profile
에코 ” ” >> /etc/profile
에코 “내보내기 경로=”\$”APACHE_HOME/bin:”\$”MySQL_HOME/bin:”\$”PHP_HOME/bin:”\$”PHP_HOME/sbin”\$”{경로:+:”\$”{ 경로}}” >> /etc/프로필
소스 /etc/profile