https://httpd.apache.org/download.cgi
Apache http server 소스코드 다운로드 

 

0. 리눅스 및 유닉스 서버 업로드 및 tar.gz 파일 압축해제

1. 소스 트리 구성
모두 기본 옵션을 사용하여 소스 트리를 구성하려면 간단히 ./configure를 입력하면된다.
가장 중요한 옵션은 아파치가 정상적으로 작동하기위해 아파치를 구성하고 설치할 장소인 --prefix다. 
PREFIX는 서버가 설치될 파일시스템 경로로 대체해야 한다. PREFIX를 지정하지 않으면 기본값으로 /usr/local/apache2를 사용한다.

$ ./configure --prefix=/app/httpserver/
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.


APR(아파치포터블런타임) 라이브러리가 부재라고 나오면 아래 내용처럼 APR유틸리티를 따로 설치 해주거나 변수를 붙여준다.

2. APR 유틸리티 설치 또는 변수 사용

$ ./configure --prefix=/app/httpserver/ --with-included-apr


OR

$ dnf install apr apr-devel apr-util apr-util-devel


3. C 컴파일러가 없다는 에러가 나오면 gcc 도 설치한다.

$ ./configure --prefix=/app/apache/
.
.
.

checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in '/app/httpserver/httpd-2.4.62':
configure: error: C compiler cannot create executables
See 'config.log' for more details
[root@jwV5 httpd-2.4.62]#
[root@jwV5 httpd-2.4.62]# gcc --version
bash: gcc: command not found...

Install package 'gcc' to provide command 'gcc'? [N/y] y


4.PRCE 가 없다는 내용이 나오면서 친절하게 wget 으로 tar.gz 을 받아오라는 가이드를 전달해준다.
쉽지 않다.

$ ./configure --prefix=/app/httpserver/
.
.
.
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/


wget으로 받아온다.
최신 파일 링크 - https://sourceforge.net/projects/pcre/files/pcre/8.45/

$ wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz


tar.gz 해제해주고

$ gzip -dc pcre-8.45.tar.gz | tar xvf - -C .


pcre-devel 유틸리티 및 gcc-c++ 컴파일러도 설치해준다.

$ dnf install pcre-devel gcc-c++


prce 설치가 계속 잘 안된다...
떨어지는 에러 로그를 확인해보니 configura 할 때 --disable--dependency-tracking 옵션을 변수로 처리해서 최소 설치를 할 수 있다고 한다.
진행해보자

$ ./configure --prefix=/usr/local/pcre


config.status: error: in `/app/httpserver/httpd-2.4.62/pcre-8.45':
config.status: error: Something went wrong bootstrapping makefile fragments
    for automatic dependency tracking.  If GNU make was not used, consider
    re-running the configure script with MAKE="gmake" (or whatever is
    necessary).  You can also try re-running configure with the
    '--disable-dependency-tracking' option to at least be able to build
    the package (albeit without support for automatic dependency tracking).
See `config.log' for more details


설치가 잘 됐다.

$ ./configure --prefix=/usr/local/pcre --disable-dependency-tracking

pcre-8.45 configuration summary:

    Install prefix .................. : /usr/local/pcre
    C preprocessor .................. :
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ :
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... :
    Extra libraries ................. :

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no


위에 까지 정상적으로 진행됐으면 PRCE를 컴파일하고 설치해보자
make  (컴파일)

make install (컴파일 설치)

5. 다시 돌아와서 apache http server 컴파일 (apache 설치 디렉토리에서 해야함)

$ ./configure --prefix=/app/httpserver/ --with-pcre=/usr/local/pcre


configure: summary of build options:

    Server Version: 2.4.62
    Install prefix: /app/httpserver/
    C compiler:     gcc
    CFLAGS:           -pthread
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:
    LIBS:
    C preprocessor: gcc -E


그리고 make 로 컴파일 해준다

컴파일 중에 아래와 같이 redhat rpm config 가 없다고 나오면 또 설치해준다...

4.62/server -I/app/httpserver/httpd-2.4.62/modules/md -I/app/httpserver/httpd-2.4.62/modules/arch/unix -I/app/httpserver/httpd-2.4.62/modules/dav/main -I/app/httpserver/httpd-2.4.62/modules/generators -I/app/httpserver/httpd-2.4.62/server -I/app/httpserver/httpd-2.4.62/modules/mappers -prefer-pic -c mod_authn_file.c && touch mod_authn_file.slo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc  -pthread           -o mod_authn_file.la -rpath /app/httpserver//modules -module -avoid-version  mod_authn_file.lo
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/app/httpserver/httpd-2.4.62/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1
make[4]: Leaving directory '/app/httpserver/httpd-2.4.62/modules/aaa'
make[3]: *** [/app/httpserver/httpd-2.4.62/build/rules.mk:117: shared-build-recursive] Error 1
make[3]: Leaving directory '/app/httpserver/httpd-2.4.62/modules/aaa'
make[2]: *** [/app/httpserver/httpd-2.4.62/build/rules.mk:117: shared-build-recursive] Error 1
make[2]: Leaving directory '/app/httpserver/httpd-2.4.62/modules'
make[1]: *** [/app/httpserver/httpd-2.4.62/build/rules.mk:117: shared-build-recursive] Error 1
make[1]: Leaving directory '/app/httpserver/httpd-2.4.62'
make: *** [/app/httpserver/httpd-2.4.62/build/rules.mk:75: all-recursive] Error 1
[root@jwV5 httpd-2.4.62]#
$ dnf install redhat-rpm-config


다시 make 컴파일 해주면 아래와 같이 정상적으로 컴파일이 된다.

$ make 
.
.
make[4]: Leaving directory '/app/httpserver/httpd-2.4.62/modules/mappers'
make[3]: Leaving directory '/app/httpserver/httpd-2.4.62/modules/mappers'
make[2]: Leaving directory '/app/httpserver/httpd-2.4.62/modules'
make[2]: Entering directory '/app/httpserver/httpd-2.4.62/support'
make[2]: Leaving directory '/app/httpserver/httpd-2.4.62/support'

make[1]: Leaving directory '/app/httpserver/httpd-2.4.62'
[root@jwV5 httpd-2.4.62]#


지정한 prefix (/app/httpserver) 에 설치

$ make install
.
.

Installing configuration files
mkdir /app/httpserver/conf
mkdir /app/httpserver/conf/extra
mkdir /app/httpserver/conf/original
mkdir /app/httpserver/conf/original/extra
Installing HTML documents
mkdir /app/httpserver/htdocs
Installing error documents
mkdir /app/httpserver/error
Installing icons
mkdir /app/httpserver/icons
mkdir /app/httpserver/logs
Installing CGIs
mkdir /app/httpserver/cgi-bin
Installing header files
mkdir /app/httpserver/include
Installing build system files
mkdir /app/httpserver/build
Installing man pages and online manual
mkdir /app/httpserver/man
mkdir /app/httpserver/man/man1
mkdir /app/httpserver/man/man8
mkdir /app/httpserver/manual
make[1]: Leaving directory '/app/httpserver/httpd-2.4.62'


설치된 prefix 에서 config/httpd.conf 편집

vi /app/httpserver/conf/httpd.conf

 

 

apache 시작

/app/httpserver/bin/apachectl start

 

중지

/app/httpserver/bin/apachectl stop

 

 

 

계속 까먹네;