##기본 설정
mkdir -p /usr/local/src/APM_Setup
export SOURCE_DIR=/usr/local/src/APM_Setup
yum install -y vim wget epel-release
cd $SOURCE_DIR
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum update -y
##디폴트환경변수
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
##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 라이브러리 32비트 호환
\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/
##httpd-2.4.57 prefork 설치
export APR=apr-1.7.4
export APR_ICONV=apr-iconv-1.2.2
export APR_UTIL=apr-util-1.6.3
export PCRE=pcre-8.45
cd /usr/local/src/APM_Setup
wget https://archive.apache.org/dist/httpd/httpd-2.4.57.tar.gz
tar zxvf httpd-2.4.57.tar.gz
wget https://archive.apache.org/dist/apr/apr-1.7.4.tar.gz
tar zxvf apr-1.7.4.tar.gz
wget https://archive.apache.org/dist/apr/apr-iconv-1.2.2.tar.gz
tar zxvf apr-iconv-1.2.2.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.3.tar.gz
tar zxvf apr-util-1.6.3.tar.gz
wget https://ftp.exim.org/pub/pcre/pcre-8.45.tar.gz
tar zxvf pcre-8.45.tar.gz
##apr 소스 설치
cd /usr/local/src/APM_Setup/apr-1.7.4
./configure --prefix=/usr/local/apr
make -j && make install
##apr-iconv 소스 설치
cd /usr/local/src/APM_Setup/apr-iconv-1.2.2
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/bin/apr-1-config
make -j && make install
##apr-util 소스 설치
cd /usr/local/src/APM_Setup/apr-util-1.6.3
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-iconv=/usr/local/apr/bin/apriconv --with-crypto --with-openssl --with-nss --with-lber --with-ldap --with-ldap-include=/usr/include --with-ldap-lib=/usr/lib64/
make -j && make install
##pcre 1 버전 소스 설치
cd /usr/local/src/APM_Setup/pcre-8.45
./configure --prefix=/usr/local/pcre --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-jit --enable-utf8 --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-pcretest-libreadline --enable-valgrind
make -j && make install
##httpd 2.4 동시 접속자 수 늘리기
cd /usr/local/src/APM_Setup/httpd-2.4.57
sed -i "s/#define DEFAULT_SERVER_LIMIT 256/#define DEFAULT_SERVER_LIMIT 2048/g" /usr/local/src/APM_Setup/httpd-2.4.57/server/mpm/prefork/prefork.c
sed -i "s/#define DEFAULT_SERVER_LIMIT 16/#define DEFAULT_SERVER_LIMIT 256/g" /usr/local/src/APM_Setup/httpd-2.4.57/server/mpm/worker/worker.c
sed -i "s/#define DEFAULT_SERVER_LIMIT 16/#define DEFAULT_SERVER_LIMIT 256/g" /usr/local/src/APM_Setup/httpd-2.4.57/server/mpm/event/event.c
여기서 httpd를 prefork로 설치하는지, worker로 설치하는지 정해야합니다.
##httpd 2.4 prefork 컴파일 옵션
./configure --prefix=/usr/local/apache --enable-load-all-modules --enable-maintainer-mode --enable-debugger-mode --enable-pie --enable-modules=all --enable-mods-shared=all --enable-imagemap --enable-authnz-ldap --enable-authnz-fcgi --enable-allowmethods --enable-isapi --enable-file-cache --enable-cache --enable-cache-disk --enable-cache-socache --enable-socache-shmcb --enable-socache-dbm --enable-socache-memcache --enable-socache-redis --enable-so --enable-rewrite --enable-ssl --enable-expires --enable-proxy-fcgi --enable-proxy-scgi --enable-proxy-html --enable-cgi --enable-cgid --enable-xml2enc --enable-cern-meta --enable-case-filter --enable-ident --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local/pcre/bin/pcre-config --with-mpm=prefork --enable-http --disable-http2 --enable-modules=all
##httpd 2.4 worker 컴파일 옵션
./configure --prefix=/usr/local/apache --enable-load-all-modules --enable-maintainer-mode --enable-debugger-mode --enable-pie --enable-modules=all --enable-mods-shared=all --enable-imagemap --enable-authnz-ldap --enable-authnz-fcgi --enable-allowmethods --enable-isapi --enable-file-cache --enable-cache --enable-cache-disk --enable-cache-socache --enable-socache-shmcb --enable-socache-dbm --enable-socache-memcache --enable-socache-redis --enable-so --enable-rewrite --enable-ssl --enable-expires --enable-proxy-fcgi --enable-proxy-scgi --enable-proxy-html --enable-cgi --enable-cgid --enable-xml2enc --enable-cern-meta --enable-case-filter --enable-ident --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local/pcre/bin/pcre-config --with-mpm=worker --enable-http --disable-http2 --enable-modules=all
##httpd 2.4 event 컴파일 옵션
./configure --prefix=/usr/local/apache --enable-load-all-modules --enable-maintainer-mode --enable-debugger-mode --enable-pie --enable-modules=all --enable-mods-shared=all --enable-imagemap --enable-authnz-ldap --enable-authnz-fcgi --enable-allowmethods --enable-isapi --enable-file-cache --enable-cache --enable-cache-disk --enable-cache-socache --enable-socache-shmcb --enable-socache-dbm --enable-socache-memcache --enable-socache-redis --enable-so --enable-rewrite --enable-ssl --enable-expires --enable-proxy-fcgi --enable-proxy-scgi --enable-proxy-html --enable-cgi --enable-cgid --enable-xml2enc --enable-cern-meta --enable-case-filter --enable-ident --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local/pcre/bin/pcre-config --with-mpm=event --enable-http --disable-http2 --enable-modules=all
make -j && make install
##httpd 설정파일 수정
sed -i "s/`grep '^User ' /usr/local/apache/conf/httpd.conf`/User nobody/g" /usr/local/apache/conf/httpd.conf
sed -i "s/`grep '^Group ' /usr/local/apache/conf/httpd.conf`/Group nobody/g" /usr/local/apache/conf/httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName localhost:80/g' /usr/local/apache/conf/httpd.conf
sed -i 's/ServerAdmin you@example.com/ServerAdmin root@localhost/g' /usr/local/apache/conf/httpd.conf
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.html index.php index.jsp/g' /usr/local/apache/conf/httpd.conf
sed -i 's/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi/g' /usr/local/apache/conf/httpd.conf
sed -i '/AddType application\/x-gzip .tgz/a\ #PHP Enable' /usr/local/apache/conf/httpd.conf
sed -i '/\ #PHP Enable/a \ AddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
sed -i '/\ #PHP Enable/a \ AddType application/x-httpd-php .php .jsp .html' /usr/local/apache/conf/httpd.conf
##home Web source file 설정
echo "" >> /usr/local/apache/conf/httpd.conf
echo "<Directory \"/home/*\">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>" >> /usr/local/apache/conf/httpd.conf
echo "" >> /usr/local/apache/conf/httpd.conf
##httpd 실행스크립트파일 설정
\cp -arpf /usr/local/apache/bin/apachectl /etc/init.d/
chmod 700 /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # It is used to serve HTML files and CGI.' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # description: Apache is a World Wide Web server. \' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # chkconfig: - 85 15' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # config: /usr/local/apache/conf/httpd.conf' /etc/init.d/apachectl
sed -i '/#!\/bin\/sh/a # pidfile: /usr/local/apache/logs/httpd.pid' /etc/init.d/apachectl
##mod_url 한글 html 설정
cd /usr/local/src/APM_Setup
wget https://kldp.net/modurl/release/2188-mod_url-apache2-1.25.tar.bz2
tar xvf 2188-mod_url-apache2-1.25.tar.bz2
cd /usr/local/src/APM_Setup/mod_url-apache2-1.25
/usr/local/apache/bin/apxs -iac mod_url.c
echo "" >> /usr/local/apache/conf/httpd.conf
echo "<IfModule mod_url.c>
CheckURL On
ServerEncoding EUC-KR
ClientEncoding UTF-8
</IfModule>" >> /usr/local/apache/conf/httpd.conf
echo "" >> /usr/local/apache/conf/httpd.conf
##httpd 로그로테이트 설정
echo "/usr/local/apache/logs/*_log {" > /etc/logrotate.d/apache
echo "weekly" >> /etc/logrotate.d/apache
echo "rotate 4" >> /etc/logrotate.d/apache
echo "size 1G" >> /etc/logrotate.d/apache
echo "missingok" >> /etc/logrotate.d/apache
echo "create 0600 root root" >> /etc/logrotate.d/apache
echo "postrotate" >> /etc/logrotate.d/apache
echo "/bin/kill -HUP \`cat /usr/local/apache/logs/httpd.pid 2>/dev/null\` 2> /dev/null || true" >> /etc/logrotate.d/apache
echo "endscript" >> /etc/logrotate.d/apache
echo "}" >> /etc/logrotate.d/apache
##apache시작
/etc/init.d/apachectl restart
##apachectl 서비스 등록
echo '[Unit]
Description=The Apache HTTP Server
[Service]
Type=forking
#EnvironmentFile=/usr/local/apache/bin/envvars
PIDFile=/usr/local/apache/logs/httpd.pid
ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/usr/local/apache/bin/apachectl graceful
ExecStop=/bin/kill -WINCH
#ExecStop=/usr/local/apacher/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
' > /usr/lib/systemd/system/apachectl.service
=========================================================================
systemctl daemon-reload
systemctl enable apachectl
/etc/init.d/apachectl stop
systemctl start apachectl
##httpd 환경변수 설정
echo " " >> /etc/profile
echo "APACHE_HOME=/usr/local/apache" >> /etc/profile
echo "export PATH="\$"APACHE_HOME/bin:"\$"MySQL_HOME/bin:"\$"PHP_HOME/bin:"\$"PHP_HOME/sbin"\$"{PATH:+:"\$"{PATH}}" >> /etc/profile
echo " " >> /etc/profile
source /etc/profile
'WEB & WAS > Apache' 카테고리의 다른 글
mod_rewrite 실전 (0) | 2023.03.08 |
---|---|
Apache MPM 튜닝 (0) | 2023.03.08 |
Apache 컴파일 옵션 (0) | 2023.03.08 |
무료인증서 (letsencrypt, buypass) (0) | 2023.03.08 |
CentOS 7 Apache 2.2 소스 컴파일 설치 (0) | 2023.03.08 |
댓글