리눅스
리눅스 Apache 소스 코드 설치
징쟝
2017. 6. 20. 15:25
1 컴파일 설치 준비
yum -y gcc
yum -y gcc-c++
yum -y wget (초기 설차라서 wget 없을 경우)
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.25.tar.bz2
wget http://ftp.neowiz.com/apache/apr/apr-1.5.2.tar.bz2
wget http://ftp.neowiz.com/apache/apr/apr-util-1.5.4.tar.bz2
wget http://downloads.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.bz2
- → 다운로드 안되면 http://ftp.neowiz.com/apache/httpd 에서 버전 및 URL 확인
[root@web01 src]# ll
total 7772
-rw-r--r--. 1 root root 826885 2015-04-29 09:37 apr-1.5.2.tar.bz2
-rw-r--r--. 1 root root 694427 2014-09-20 20:59 apr-util-1.5.4.tar.bz2
-rw-r--r--. 1 root root 1532608 2015-10-13 02:42 httpd-2.4.20.tar.bz2
-rw-r--r--. 1 root root 1440869 2013-05-30 01:19 pcre-8.33.tar.bz2
[root@web01 src]#
4 압축 해제
tar xvf apr-1.5.2.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
tar xvf httpd-2.4.25.tar.bz2
tar xvf pcre-8.33.tar.bz2
mv apr-1.5.2 ./httpd-2.4.25/srclib/apr
mv apr-util-1.5.4 ./httpd-2.4.25/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.33
./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.20
./configure --prefix=/usr/local/apache2
make
make install
- →
--prefix=/usr/local/apache2
에 있는대로 /usr/local/apache2가 아파치 홈 폴더가 된다. - →
configure: error: Cannot use an external APR-util with the bundled APR
오류 발생하면./configure --prefix=/usr/local/httpd --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>
#출처 :https://zetawiki.com/wiki/리눅스_아파치_최신버전_설치_(컴파일)
방화벽 내리는 부분은 보안때문에 배제시켰음.