간마늘작업소

[RHEL / CentOS / Rocky Linux / Ubuntu] Apache HTTP Server 컴파일 설치 본문

Linux/11.Apache HTTPD Server

[RHEL / CentOS / Rocky Linux / Ubuntu] Apache HTTP Server 컴파일 설치

간마늘 2022. 6. 29. 15:28

0.개요

  • Apache HTTP Server는 yum 및 dnf로도 설치할 수 있음.
  • 그러나 기본 리포지토리로 제공하는 패키지의 버전은 낮음.
  • 따라서, 최신 버전 설치를 위해서는 컴파일 설치를 진행해야함.

 

1.사전 조건

  1. 구성
    • Apache Engine 경로 /Infra/engine/web/apache

 

2.사전 패키지 설치

  • RHEL 7 / CentOS 7
yum install bind-utils wget unzip net-tools git vim

yum install gcc gcc-c++ zlib-devel openssl-devel expat-devel pcre-devel m4
  • RHEL 8, 9 / CentOS 8 / Rocky Linux 8, 9
dnf install bind-utils wget unzip net-tools git vim

dnf install gcc gcc-c++ zlib-devel openssl-devel expat-devel pcre-devel m4
  • Ubuntu 22.04
sudo apt-get install bind9-utils wget unzip net-tools git vim

sudo apt-get install gcc make libc6-dev g++ zlib1g-dev libssl-dev openssl libexpat1-dev libpcre3-dev m4

 

3.컴파일 설치 준비

mkdir -p /PROD/web/Apache_WEB
mkdir -p /Infra/engine/web/
  • 필요한 경로 사전 생성.
wget https://dlcdn.apache.org/httpd/httpd-2.4.57.tar.gz

wget http://mirror.navercorp.com/apache/apr/apr-1.7.4.tar.gz
wget http://mirror.navercorp.com/apache/apr/apr-util-1.6.3.tar.gz

wget https://ftp.gnu.org/gnu/libtool/libtool-2.4.7.tar.gz
wget https://ftp.exim.org/pub/pcre/pcre-8.45.tar.gz
wget http://mirror.navercorp.com/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz
  • 컴파일 설치에 필요한 파일들을 다운로드 받음.
    • 다운로드 경로는 /root로 가정.

 

4.사전 컴파일 설치

cd /root

tar -xvf libtool-2.4.7.tar.gz

cd libtool-*/

./configure --prefix=/usr

make && make install
  • Libtool library 설치.

 

5.Apache HTTP Server 컴파일 설치

cd /root

tar -xvf httpd-*.tar.gz

tar -xvf apr-1.7.4.tar.gz
tar -xvf apr-util-1.6.3.tar.gz
tar -xvf pcre-8.45.tar.gz

cd httpd-*/srclib/

cp -rp /root/apr-1.7.4 apr/
cp -rp /root/apr-util-1.6.3 apr-util/
cp -rp /root/pcre-8.45 pcre/

cd /root/httpd-*/

./configure \
--prefix=/Infra/engine/web/apache-2.4.57 \
--with-mpm=worker \
--enable-modules=most \
--enable-mods-shared=most \
--enable-mpms-shared=all \
--enable-cache \
--enable-file-cache \
--enable-so \
--enable-mime-magic \
--enable-expires \
--enable-header \
--enable-proxy \
--enable-ssl \
--enable-vhosts-alias \
--enable-rewrite \
--with-included-apr \
--with-included-pcre

make && make install

 

6.Apache HTTP Server Engine 작동 확인

cd /Infra/engine/web/
ln -s apache-2.4.57 apache

cd apache/bin

./apachectl start

ps -ef | grep -v grep | grep httpd
  • Apache Engine 디렉토리로 이동.
  • bin 디렉토리 내부의 apachectl로 Apache Engine 시동.
  • 프로세스가 뜨는지 확인.
groupadd -g 48 -r apache
/usr/sbin/useradd -c "Apache" -u 48 -g apache -s /sbin/nologin -r apache

cd /Infra/engine/web/
chown -R apache.apache apache apache-2.4.57/
  • apache 계정 및 apache 그룹 생성.
  • 권한 부여.
cd /Infra/engine/web/Apache_ENG
cd bin

chown -R root.root httpd
chmod +s httpd
  • 설치 마무리.
  • httpd 파일에 대한 권한 재조정.
    • TCP Port 중 10000 이하를 사용하려면 httpd 파일이 root 계정으로 작동하되 s 심볼를 부여하여 apache 계정으로도 동작할 수 있도록 해야함.

 

번외.Tomcat Connector library 설치

cd /root/

tar -xvf tomcat-connectors-1.2.48-src.tar.gz

cd tomcat-*/native

./configure --with-apxs=/Infra/engine/web/apache-2.4.54/bin/apxs

make && make install
Comments