프로젝트/컴파일 설치로 AWS 3-Tier 구축하기(+테라폼)

[AWS 3-Tier 구축하기 3] AWS Linux ATM 구성(Apache, Tomcat, MySQL) - Apache 설치

su-mmer 2023. 3. 28. 19:16
728x90

 

WEB01, 02 Apache 2.4.X
WAS01, 02 Tomcat 8.5.X
DB01 MySQL 5.7.X

 

소스 설치

소스설치, 수동설치, 컴파일설치?
Linux에서 소스를 직접 다운 받아 컴파일하여 설치하는 것

↔ 패키지 설치(yum 또는 apt 설치)
패키지 설치는 간편하지만 불필요하게 설치되는 파일들이 있고 패키지 단위로 설치되어 관리가 어렵다.

 

소스 파일은 /usr/local/src에 보관하고 /usr/local/에 설치하는 것이 관례

 

소스 설치 순서

  1. 소스파일을 내려받고
  2. ./configure로 설정하고
  3. make로 컴파일하고
  4. make install로 설치한다.

configure: 소스파일에 대한 환경설정. 서버 환경에 맞춰 makefile을 생성

make: 컴파일

make install: 컴파일된 설치 파일을 설치한다.

 

Apache HTTP Server 소스 설치

Apache Server 소스 설치를 위한 패키지 설치

 yum install -y gcc gcc-c++ pcre-devel expat-devel

 

Apache HTTP Server 설치를 위해 필요한 설치 파일 

  1. apr (Apache Portable Runtime), apr-util
    Apache HTTP 서버 2.X.의 핵심이며 휴대용 라이브러리이다. 고급 IO 기능(ex. sendfile, epoll and OpenSSL 등)에 대한 접근을 포함하여 OS 수준의 기능(난수 생성, 시스템 상태), 기본 프로세스 처리(공유 메모리, NT 파이프와 유닉스 소켓)등 많은 용도로 사용된다.
    Apache 2.4부터는 apr, apr-util이 없기 때문에 별도로 설치해야 한다.

  2. pcre(Perl Compatible Regular Expressions)
    펄 호환 정규 표현식

 

설치

cd /usr/local/src

/usr/local/src로 이동하여 소스들을 설치한다.

 

apache에서 권장하는 버전으로 설치했다.

https://apr.apache.org/download.cgi

 

Download - The Apache Portable Runtime Project

The currently selected mirror is https://dlcdn.apache.org/. If you encounter a problem with this mirror, please select another mirror. If all mirrors are failing, there are backup mirrors (at the end of the mirrors list) that should be available. You may a

apr.apache.org

 

APR 1.7.2 버전 파일 설치

wget https://dlcdn.apache.org//apr/apr-1.7.2.tar.gz

 

APR-util 1.6.3 버전 파일 설치

wget https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz

 

PCRE 8.4.5 버전 파일 설치

wget -O pcre-8.45.tar.gz https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz/download
wget은 기본적으로 다운로드 경로의 마지막 슬래시(’/’) 다음에 오는 단어를 파일 이름으로 사용한다.
근데 이렇게 하면 파일 이름이 헷갈릴 수 있어서 -O(대문자) 옵션을 사용한다.
wget -O [파일이름] [다운받을 주소]

 

Apache 2.4.56 버전 파일 설치

wget https://dlcdn.apache.org/httpd/httpd-2.4.56.tar.gz

 

각 zip 파일들 압축해제

tar xvfz apr-1.7.2.tar.gz
tar xvfz apr-util-1.6.3.tar.gz
tar xvfz pcre-8.45.tar.gz
tar xvfz httpd-2.4.56.tar.gz

 

pcre 구성

cd pcre-8.45/
./configure --prefix=/usr/local/pcre
make && make install

apr, apr-util 파일 이동

mv apr-1.7.2 ./httpd-2.4.56/srclib/apr
mv apr-util-1.6.3 ./httpd-2.4.56/srclib/apr-util
cd httpd-2.4.56/

http 컴파일 파일 생성

./configure \
--prefix=/usr/local/apache \
--with-included-apr \
--with-pcre=/usr/local/pcre

컴파일 및 실행

make && make install

apache를 Service에 등록

cd /usr/lib/systemd/system
vi apache.service

아래 코드 apache.service에 붙여넣고 저장하기

[Unit]

Description=apache

After=network.target syslog.target



[Service]

Type=forking

User=root

Group=root



ExecStart=/usr/local/apache/bin/apachectl start

ExecStop=/usr/local/apache/bin/apachectl stop



Umask=007

RestartSec=10

Restart=always



[Install]

WantedBy=multi-user.target

service에 apache 등록하기

systemctl daemon-reload
systemctl enable apache
systemctl start apache
curl localhost

curl로 페이지를 불러오면 It works!가 출력된다.

 

근데 나는 이제 It works!가 맘에 안들어서 바꿨다.

 

728x90