CentOS 7 ํ๊ฒฝ์์ Apache HTTP Server 2.4๋ฅผ ์์ค ์ฝ๋๋ก ์ปดํ์ผํ์ฌ ์ค์นํ๋ ์ ์ฒด ๊ณผ์ ์ ๋ค๋ฃน๋๋ค. APR, APR-Util, PCRE, OpenSSL ๋ฑ ํ์ ์์กด์ฑ ํจํค์ง๋ฅผ ๋ณ๋ ๊ฒฝ๋ก(Custom Path)์ ์ค์นํ๊ณ ์ด๋ฅผ Apache์ ์ฐ๋ํ๋ ๋ฐฉ๋ฒ์ ์ค์ ์ ์ผ๋ก ์ค๋ช
ํฉ๋๋ค.
0. ์ฌ์ ์ค๋น (Prerequisites)
์์ค ์ปดํ์ผ์ ์ํด ํ์ํ C ์ปดํ์ผ๋ฌ์ ๊ธฐ๋ณธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํฉ๋๋ค.
OS ๋ฐ ์ปดํ์ผ ๋๊ตฌ ํ์ธ
- OS: CentOS 7 (Kernel 3.10.0)
- ํจํค์ง ์ค์น:
yum -y install gcc make gcc-c++ pcre-devel expat-devel
1. ์์กด์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น (Dependencies)
Apache 2.4 ๊ตฌ๋์ ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ /SW/web/tools ํ์์ ๊ฒฉ๋ฆฌํ์ฌ ์ค์นํฉ๋๋ค. ์ด๋ ์์คํ
๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ถฉ๋์ ๋ฐฉ์งํ๊ธฐ ์ํจ์
๋๋ค.
1) APR (Apache Portable Runtime)
OS ๊ฐ์ ์ฐจ์ด๋ฅผ ์ถ์ํํด ์ฃผ๋ ํต์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค.
# ๋ค์ด๋ก๋ ๋ฐ ์์ถ ํด์ ํ ์ด๋
./configure --prefix=/SW/web/tools/apr
make && make install
2) APR-Util
APR์ ์ ํธ๋ฆฌํฐ ํ์ฅํ์ด๋ฉฐ, ๋ฐ๋์ APR์ด ๋จผ์ ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค.
# --with-apr ์ต์
์ผ๋ก ์์์ ์ค์นํ ๊ฒฝ๋ก ์ง์ ํ์
./configure --prefix=/SW/web/tools/apr-util --with-apr=/SW/web/tools/apr
make && make install
3) PCRE (Perl Compatible Regular Expressions)
URL ์ฌ์์ฑ(Rewrite) ๋ชจ๋ ๋ฑ ์ ๊ท ํํ์ ์ฒ๋ฆฌ์ ์ฌ์ฉ๋ฉ๋๋ค.
./configure --prefix=/SW/web/tools/pcre
make && make install
4) OpenSSL (HTTPS ์ง์)
๋ณด์ ํต์ (SSL/TLS)์ ์ํด OpenSSL ์์ค๋ฅผ ์ปดํ์ผํฉ๋๋ค.
# config ๋ช
๋ น์ด๋ก ๊ฒฝ๋ก ์ค์
./config --prefix=/SW/web/tools/openssl --openssldir=/SW/web/tools/openssl
make && make install
2. Apache (HTTPD) ์ปดํ์ผ ๋ฐ ์ค์น
๋ชจ๋ ์์กด์ฑ์ด ์ค๋น๋์์ผ๋ฏ๋ก Apache๋ฅผ ์ปดํ์ผํฉ๋๋ค. configure ๋จ๊ณ์์ ์์ ์ค์นํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ๊ฒฝ๋ก๋ฅผ ์ ํํ ์ง์ ํ๋ ๊ฒ์ด ํต์ฌ์
๋๋ค.
Configure ์คํ
tar -zxvf httpd-2.4.41.tar.gz
cd httpd-2.4.41
# ์ค์ (ํ ์ค๋ก ์
๋ ฅ)
./configure \
--prefix=/SW/web/httpd24 \
--enable-so \
--enable-rewrite \
--enable-proxy \
--enable-ssl \
--enable-mods-shared=all \
--enable-modules=shared \
--enable-mpms-shared=all \
--with-mpm=worker \
--with-apr=/SW/web/tools/apr \
--with-apr-util=/SW/web/tools/apr-util \
--with-pcre=/SW/web/tools/pcre \
--with-ssl=/SW/web/tools/openssl \
--enable-unique-id
์ฃผ์ ์ต์
์ค๋ช
--enable-so: DSO(Dynamic Shared Object) ๋ชจ๋ ์ ์ฌ ๊ธฐ๋ฅ ํ์ฑํ (ํ์)
--enable-mods-shared=all: ๋ชจ๋ ๋ชจ๋์ ๋์ ๋ชจ๋๋ก ์ปดํ์ผ
--with-mpm=worker: ๋ฉํฐ ํ๋ก์ธ์ค ๋ชจ๋(MPM)์ Worker ๋ฐฉ์์ผ๋ก ์ง์ (์ฑ๋ฅ ์ ๋ฆฌ)
--with-[lib]: ์์ ์ค์นํ ์์กด์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก ์ฐ๊ฒฐ
์ปดํ์ผ ๋ฐ ์ค์น
make && make install
3. ๊ตฌ๋ ๋ฐ ๊ฒ์ฆ (Verification)
์ค์น๊ฐ ์๋ฃ๋๋ฉด ์๋น์ค๋ฅผ ๊ธฐ๋ํ๊ณ ๋ธ๋ผ์ฐ์ ์ ์์ ํ
์คํธํฉ๋๋ค.
์๋น์ค ๊ธฐ๋
# Apache ์ปจํธ๋กค๋ฌ ์คํ
/SW/web/httpd24/bin/apachectl start
# ํ๋ก์ธ์ค ํ์ธ
ps -ef | grep httpd
netstat -anotp | grep :80
๋ฐฉํ๋ฒฝ ์ค์ (CentOS 7)
ํ๋ก์ธ์ค๊ฐ ๋ ์์ด๋ ๋ฐฉํ๋ฒฝ์ด ๋งํ์์ผ๋ฉด ์ ์์ด ์ ๋ฉ๋๋ค. 80 ํฌํธ๋ฅผ ์ด์ด์ค๋๋ค.
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
์ ์ ํ์ธ
๋ธ๋ผ์ฐ์ ์ฃผ์์ฐฝ์ ์๋ฒ IP๋ฅผ ์
๋ ฅํ์ฌ "It works!" ํ์ด์ง๊ฐ ๋จ๋์ง ํ์ธํฉ๋๋ค.
[๊ทธ๋ฆผ] ์ค์น ์ฑ๊ณต ์ ํ์ธ ๊ฐ๋ฅํ ๊ธฐ๋ณธ ํ์ด์ง
Next Step:
๊ธฐ๋ณธ ์ค์น๊ฐ ์๋ฃ๋์์ต๋๋ค. ์ด์ ์ด์ ํ๊ฒฝ์ ๋ง์ถฐ httpd.conf์์ ServerName ๊ฒฝ๊ณ ๋ฅผ ํด๊ฒฐํ๊ณ , httpd-mpm.conf์์ Worker ํ๋ก์ธ์ค ํ๋์ ์งํํด ๋ณด์ญ์์ค.