## PHP 설치전 선행 작업
cd /usr/local/src/
yum install -y wget vim epel-release
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum update -y
## CentOS 7 Default 환경변수설정
echo " " >> /etc/profile
echo "####default PATH#####" >> /etc/profile
echo "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:" >> /etc/profile
echo "#####################" >> /etc/profile
## 소스설치를 위한 패키지 환경 설치
yum install -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 environment-modules uw-imap-utils uw-imap-devel uw-imap uw-imap-static 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 flex zlib* zlib-devel zlib gd* gd gd-devel patch t1lib t1lib-devel readline libedit-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
unlink /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
## cmake 버전 업그레이드 (libzip 설치를 위한 작업)
yum remove -y cmake
cd /usr/local/src/APM_Setup
wget https://github.com/Kitware/CMake/releases/download/v3.26.0/cmake-3.26.0.tar.gz
tar zxvf cmake-3.26.0.tar.gz
cd cmake-3.26.0
./bootstrap --prefix=/usr/local
make -j
make install
source /etc/profile
## pcre2 버전 최신버전 설치
cd /usr/local/src/APM_Setup
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz
tar zxvf pcre2-10.42.tar.gz
cd pcre2-10.42
./configure --prefix=/usr/local/pcre2 --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 --enable-jit --enable-jit-sealloc --enable-pcre2grep-jit --enable-pcre2grep-callout --enable-pcre2grep-callout-fork --enable-unicode --enable-pcre2grep-libz --enable-pcre2grep-libbz2 --enable-pcre2test-libreadline --enable-valgrind --enable-fuzz-support --enable-percent-zt --with-gnu-ld --with-pcre2grep-bufsize=20480 --with-pcre2grep-max-bufsize=1048576 --with-link-size=2 --with-parens-nest-limit=250 --with-heap-limit=20000000 --with-match-limit-depth=MATCH_LIMIT
make -j
make install
## pcre2 연동 환경변수 설정
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig" >> /etc/profile
sed -i "s/export PKG_CONFIG_PATH=\/usr\/local\/lib\/pkgconfig:\/usr\/local\/lib64\/pkgconfig:\/usr\/lib64\/pkgconfig:\/usr\/lib\/pkgconfig/export PKG_CONFIG_PATH=\/usr\/local\/pcre2\/lib\/pkgconfig:\/usr\/local\/lib\/pkgconfig:\/usr\/local\/lib64\/pkgconfig:\/usr\/lib64\/pkgconfig:\/usr\/lib\/pkgconfig/g" /etc/profile
## libzip 최신버전 설치
cd /usr/local/src/APM_Setup
wget https://libzip.org/download/libzip-1.9.2.tar.gz
tar zxvf libzip-1.9.2.tar.gz
mkdir libzip-1.9.2/build
cd libzip-1.9.2/build
cmake ../ \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DENABLE_BZIP2=1 \
-DENABLE_COMMONCRYPTO=1 \
-DENABLE_GNUTLS=1 \
-DENABLE_LZMA=1 \
-DENABLE_MBEDTLS=1 \
-DENABLE_OPENSSL=1 \
-DENABLE_ZSTD=1 \
-DLIBZIP_DO_INSTALL=1 \
-DSHARED_LIB_VERSIONNING=1
make -j
make install
## libgd 최신버전설치
cd /usr/local/src/APM_Setup
wget https://github.com/libgd/libgd/releases/download/gd-2.3.2/libgd-2.3.2.tar.gz
tar zxvf libgd-2.3.2.tar.gz
cd libgd-2.3.2
./configure --prefix=/usr/local --with-pic --with-aix-soname=both --with-x --with-gnu-ld --with-libiconv-prefix --with-zlib --with-png --with-freetype --with-raqm --with-fontconfig --with-jpeg --with-xpm --with-tiff --with-webp
make -j
make install
## PHP 다운로드 및 배포
cd /usr/local/src/APM_Setup
wget https://www.php.net/distributions/php-7.4.33.tar.gz
wget https://mirror.cogentco.com/pub/php/php-7.4.33.tar.gz
wget http://ftp.ntu.edu.tw/pub/php/distributions/php-7.4.33.tar.gz
tar zxvf php-7.4.33.tar.gz
cd php-7.4.33
## PHP 컴파일 설정
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --with-fpm-systemd --with-config-file-path=/usr/local/apache/conf --disable-debug --with-external-pcre=/usr/local/pcre/bin/pcre-config --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-phpdbg-readline --enable-dom --enable-bcmath --enable-cli --enable-cgi --with-iconv --with-iconv-dir --enable-sigchild --with-openssl --with-openssl-dir --with-system-ciphers --with-pcre-jit --with-zlib --with-zlib-dir --enable-opcache --enable-ctype --with-bz2 --enable-calendar --with-curl --enable-dba --enable-pcntl --with-pspell --with-zip --with-dbm --with-gdbm --enable-exif --with-ffi --enable-fileinfo --enable-filter --enable-ftp --enable-gd --with-external-gd --enable-gd-jis-conv --with-webp --with-jpeg --with-xpm --with-freetype --enable-shmop --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --enable-mbregex --enable-huge-code-pages --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-json --with-tidy --enable-tokenizer --with-xsl --enable-soap --with-ldap-sasl --with-ldap --enable-intl --with-mhash --with-gmp --with-gettext --with-enchant --enable-phar --enable-posix --enable-libgcc --with-snmp --with-libedit --with-readline --with-pear --with-libxml --with-xmlrpc --enable-xmlwriter --enable-simplexml --enable-xml --enable-xmlreader --enable-session --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd --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/-lcrypto -lcrypt/-lcrypto -lcrypt -llber/g' /usr/local/src/APM_Setup/php-7.4.33/Makefile
make -j
make install
## 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 = On/allow_url_fopen = Off/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 = "Asia\/Seoul"/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
## 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-7.4.33/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
\cp -f /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
chmod +x /etc/init.d/php-fpm
\cp -f /usr/local/src/APM_Setup/php-7.4.33/sapi/fpm/php-fpm.service /lib/systemd/system/
## /usr/local/php/etc/php-fpm.conf 설정파일 수정
sed -i 's/;pid = run\/php-fpm.pid/pid = \/usr\/local\/php\/var\/run\/php-fpm.pid/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;error_log = log\/php-fpm.log/error_log = \/usr\/local\/php\/var\/log\/php-fpm.log/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;syslog.facility = daemon/syslog.facility = daemon/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;syslog.ident = php-fpm/syslog.ident = php-fpm/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;log_level = notice/log_level = warning/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;log_limit = 4096/log_limit = 4096/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;log_buffering = no/log_buffering = yes/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/;daemonize = yes/daemonize = yes/g' /usr/local/php/etc/php-fpm.conf
sed -i 's/;systemd_interval = 10/systemd_interval = 10/g' /usr/local/php/etc/php-fpm.conf
## /usr/local/php/etc/php-fpm.d/www.conf 설정파일 수정
sed -i 's/;listen.backlog = 511/listen.backlog = 65535/g' /usr/local/php/etc/php-fpm.d/www.conf
echo "net.core.somaxconn=65535" >> /etc/sysctl.conf
sysctl -p
sed -i 's/;listen.owner = nobody/listen.owner = nobody/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;listen.group = nobody/listen.group = nobody/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;listen.mode = 0660/listen.mode = 0660/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/; process.dumpable = yes/process.dumpable = yes/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/pm = dynamic/pm = ondemand/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/pm = static/pm = ondemand/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/pm.max_children = 5/pm.max_children = 50/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;pm.process_idle_timeout/pm.process_idle_timeout/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;access.log = log/access.log = \/usr\/local\/php\/var\/log/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;access.format/access.format/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;slowlog/slowlog/g' /usr/local/php/etc/php-fpm.d/www.conf
sed -i 's/;request_slowlog_timeout = 0/;request_slowlog_timeout = 30/g' /usr/local/php/etc/php-fpm.d/www.conf
## Apache PHP-FPM으로 변경 FastCGI
-> mod_php (apache2handler로 쓸경우 아래에 부분 진행X)
echo "
##########PHP-FPM 연동설정###########
ProxyRequests Off
ProxyPreserveHost On
ProxyErrorOverride on
ProxyTimeout 600
<FilesMatch \.(php|phar)$>
SetHandler "proxy:fcgi://localhost:9000"
</FilesMatch>
#####################################" >> /usr/local/apache/conf/httpd.conf
##php-fpm prefork 로 인해 시작프로그램 등록해제
chkconfig --add php-fpm
chkconfig php-fpm on
/etc/init.d/php-fpm start
## imagick 모듈 설치
cd /usr/local/src/APM_Setup
wget https://pecl.php.net/get/imagick-3.7.0.tgz
tar zxvf imagick-3.7.0.tgz
cd imagick-3.7.0/
/usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make -j && make install
echo "[imagick]" >> /usr/local/apache/conf/php.ini
echo "extension=imagick.so" >> /usr/local/apache/conf/php.ini
echo " " >> /usr/local/apache/conf/php.ini
## mcrypt 모듈 설치
cd /usr/local/src/APM_Setup
wget https://pecl.php.net/get/mcrypt-1.0.4.tgz
tar zxvf mcrypt-1.0.4.tgz
cd mcrypt-1.0.4
/usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make -j && make install
echo "[mcrypt]" >> /usr/local/apache/conf/php.ini
echo "extension=mcrypt.so" >> /usr/local/apache/conf/php.ini
echo " " >> /usr/local/apache/conf/php.ini
## Apache php 모듈 확인 및 재시작
apachectl -M | grep php
/etc/init.d/apachectl restart
## APM 환경변수 설정
아래 설정은 Apache, MySQL, PHP 부분이 모두 포함되어있습니다.
echo " " >> /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
echo " " >> /etc/profile
echo "export PATH="\$"APACHE_HOME/bin:"\$"MySQL_HOME/bin:"\$"PHP_HOME/bin:"\$"PHP_HOME/sbin"\$"{PATH:+:"\$"{PATH}}" >> /etc/profile
source /etc/profile
'WEB & WAS > PHP' 카테고리의 다른 글
CentOS 7 PHP 8.1.33 소스 컴파일 설치 (현재 8.1.17 23/03/17) (0) | 2023.03.17 |
---|---|
CentOS 7 PHP 8.0.33 소스 컴파일 설치 (현재 8.0.28 23/03/17) (0) | 2023.03.17 |
CentOS 7 PHP 7.3.33 소스 컴파일 설치 (0) | 2023.03.16 |
CentOS 7 PHP 7.2.34 소스 컴파일 설치 (0) | 2023.03.16 |
CentOS 7 PHP 7.1.33 소스 컴파일 설치 (0) | 2023.03.16 |
댓글