아파치 컴파일 설치

리눅스 아파치 컴파일 설치
리눅스 아파치 최신버전 설치 (컴파일)

1 컴파일 설치 준비[ | ]

2 최신버전 다운로드[ | ]

  • http://httpd.apache.org/download.cgi 접속
  • Stable Release - Lasted Version 아래의 버전 확인(예: 2.4.9) 후 클릭
  • Source: 오른쪽의 bz2 파일 링크(예: httpd-2.4.9.tar.bz2) 클릭하여 다운로드

3 다운로드[ | ]

cd /usr/local/src
wget http://ftp.neowiz.com/apache/httpd/httpd-2.4.29.tar.bz2
wget http://ftp.neowiz.com/apache/apr/apr-1.6.3.tar.bz2
wget http://ftp.neowiz.com/apache/apr/apr-util-1.6.1.tar.bz2
wget http://downloads.syntaxhighlightforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.bz2
→ 다운로드 안되면 http://ftp.neowiz.com/apache/httpd 에서 버전 및 URL 확인
[root@web01 src]# ll
total 7772
-rw-r--r--. 1 root root  853363 Jun 13 00:35 apr-1.6.3.tar.bz2
-rw-r--r--. 1 root root  428750 Jun 13 00:35 apr-util-1.6.1.tar.bz2
-rw-r--r--. 1 root root 6527394 Jul 10 03:10 httpd-2.4.29.tar.bz2
-rw-r--r--. 1 root root 1561874 Jul  6 05:22 pcre-8.41.tar.bz2
[root@web01 src]#

4 압축 해제[ | ]

tar xvf apr-1.6.3.tar.bz2
tar xvf apr-util-1.6.1.tar.bz2
tar xvf httpd-2.4.29.tar.bz2
tar xvf pcre-8.41.tar.bz2
mv apr-1.6.2 ./httpd-2.4.27/srclib/apr
mv apr-util-1.6.0 ./httpd-2.4.27/srclib/apr-util
[root@web01 ~]# tar xvf apr-1.5.2.tar.bz2
... (생략)
apr-1.5.2/encoding/
apr-1.5.2/encoding/apr_escape.c
[root@web01 ~]# tar xvf apr-util-1.5.4.tar.bz2
... (생략)
apr-util-1.5.4/encoding/
apr-util-1.5.4/encoding/apr_base64.c
[root@web01 ~]# tar xvf httpd-2.4.25.tar.bz2
... (생략)
httpd-2.4.25/build/aix/mkinstallp.ksh
httpd-2.4.25/build/aix/README
[root@web01 ~]# tar xvf pcre-8.33.tar.bz2
... (생략)
pcre-8.33/makevp_c.txt
pcre-8.33/pcredemo.c
[root@web01 src]# ll
total 7788
drwxr-xr-x. 27 1000  1000    4096 Nov 13 08:14 apr-1.5.2
-rw-r--r--.  1 root root   813976 Nov 16 09:50 apr-1.5.2.tar.bz2
drwxr-xr-x. 19 1000  1000    4096 Nov 13 08:41 apr-util-1.5.4
-rw-r--r--.  1 root root   695303 Nov 16 09:52 apr-util-1.5.4.tar.bz2
drwxr-xr-x. 11  501 games    4096 Nov 19 09:36 httpd-2.4.20
-rw-r--r--.  1 root root  5004719 Nov 22 09:49 httpd-2.4.20.tar.bz2
drwxr-xr-x.  7 1169  1169    4096 May 28 02:14 pcre-8.33
-rw-r--r--.  1 root root  1440869 May 28 01:16 pcre-8.33.tar.bz2
[root@web01 src]# mv apr-1.5.2 ./httpd-2.4.25/srclib/apr
[root@web01 src]# mv apr-util-1.5.4 ./httpd-2.4.25/srclib/apr-util
[root@web01 src]# ll
total 7780
-rw-r--r--.  1 root root   813976 Nov 16 09:50 apr-1.5.2.tar.bz2
-rw-r--r--.  1 root root   695303 Nov 16 09:52 apr-util-1.5.4.tar.bz2
drwxr-xr-x. 11  501 games    4096 Nov 19 09:36 httpd-2.4.20
-rw-r--r--.  1 root root  5004719 Nov 22 09:49 httpd-2.4.20.tar.bz2
drwxr-xr-x.  7 1169  1169    4096 May 28 02:14 pcre-8.33
-rw-r--r--.  1 root root  1440869 May 28 01:16 pcre-8.33.tar.bz2

5 pcre 설치[ | ]

cd /usr/local/src/pcre-8.41
./configure
make
make install
[root@web01 ~]# cd /usr/local/src/pcre-8.33
[root@web01 pcre-8.33]# ./configure
... (생략)
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no
[root@web01 pcre-8.33]# make
... (생략)
  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
  CXXLD    pcre_stringpiece_unittest
make[1]: Leaving directory `/usr/local/src/pcre-8.33'
[root@web01 pcre-8.33]# make install
make[3]: Leaving directory `/usr/local/src/pcre-8.33'
make[2]: Leaving directory `/usr/local/src/pcre-8.33'
make[1]: Leaving directory `/usr/local/src/pcre-8.33'

6 아파치 설치[ | ]

cd /usr/local/src/httpd-2.4.27
./configure --prefix=/usr/local/apache2
make
make install
--prefix=/usr/local/apache2에 있는대로 /usr/local/apache2가 아파치 홈 폴더가 된다.[1]
configure: error: Cannot use an external APR-util with the bundled APR 오류 발생하면[2] ./configure --prefix=/usr/local/apache2 --with-included-apr를 해보자.
[root@web01 pcre-8.33]# cd /usr/local/src/httpd-2.4.20
[root@web01 httpd-2.4.20]# ./configure --prefix=/usr/local/apache2
... (생략)
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
[root@web01 httpd-2.4.20]# make
... (생략)
make[2]: Leaving directory `/usr/local/src/httpd-2.4.20/support'

make[1]: Leaving directory `/usr/local/src/httpd-2.4.20'
[root@web01 httpd-2.4.20]# make install
... (생략)
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/usr/local/src/httpd-2.4.20'

7 아파치 시작[ | ]

[root@web ~]# /usr/local/apache2/bin/httpd -k start
[root@web ~]# ps -ef | grep httpd | grep -v grep
root     35683     1  0 17:09 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   35684 35683  0 17:09 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   35685 35683  0 17:09 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon   35686 35683  0 17:09 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
[root@web ~]# netstat -anp | grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      35683/httpd
[root@web01 ~]# curl http://127.0.0.1
<html><body><h1>It works!</h1></body></html>

8 방화벽 끄기[ | ]

[root@web ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt syntaxhighlight               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt syntaxhighlight               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt syntaxhighlight               destination
[root@web ~]# lokkit --selinux=disabled --disabled
[root@web ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt syntaxhighlight               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt syntaxhighlight               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt syntaxhighlight               destination 

[root@web ~]# iptables -F; iptables -X

9 같이 보기[ | ]

10 참고[ | ]

  1. 다른 위치를 원한다면 변경해도 된다.
  2. CentOS 6에 아파치 2.4.12 설치하니 발생했음. https://bz.apache.org/bugzilla/show_bug.cgi?id=42089
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}