본문 바로가기

Server

CentOS 7 Apache 2.4.23 컴파일 설치


- 리눅스 버전을 확인 합니다.

[root@localhost ~]# cat /proc/version
Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015

[root@localhost ~]# ip addr | grep "inet "
    inet 127.0.0.1/8 scope host lo
    inet xxx.xxx.xxx.xxx/26 brd xxx.xxx.xxx.xxx scope global eth0


- Apache 설치 패키지 정보를 확인 합니다.

  • Apache HTTP Server
Apache httpd 2.4.23

  • APR(Apache Portable Runtime)
APR 1.5.2 
APR-util 1.5.4 

톰캣은 뛰어난 확장성, 성능 및 기본 서버 기술로 더 나은 통합을 제공하기 위해 Apache Portable Runtime를 사용할 수 있습니다. 아파치 포터블 런타임은 아파치 HTTP 서버 2.x.의 핵심이며 휴대용 라이브러리입니다. 이런 APR은 고급 IO 기능(예:sendfile, epoll and OpenSSL 등)에 대한 접근을 포함하여 OS 수준의 기능 (난수 생성, 시스템 상태), 그리고 기본 프로세스 처리(공유 메모리, NT 파이프와 유닉스 소켓) 등 많은 용도로 사용되고 있습니다.

이러한 기능은 일반적인 목적의 웹 서버를 톰캣을 이용하도록 하며, 다른 기본 웹 기술과 훨씬 더 통합을 가능하게 하고, 전반적인 자바가 단순히 백엔드에 주력한 기술보다 전체 본격적인 웹서버 플랫폼으로 훨씬 더 성공할 수 있도록 만들어 줍니다.

  • PCRE(Perl Compatible Regular Expressions) - Perl 호환 정규 표현식들
pcre-8.37 
          
PCRE 라이브러리는 Perl 5 같은 구문과 의미를 사용하여 정규식 패턴 일치를 구현하는 함수의 집합이다. PCRE는 자체 native API 뿐만 아니라 POSIX 정규식 API에 대응하는 래퍼 함수의 집합도 포함하고 있다. PCRE 라이브러리는 심지어 proprietary software 개발에 사용되어도 무료이다.
PCRE는 원래 Exim MTA(Exim은 Mail Transfer Agent의 한 종류)를 위해 만들어졌으나, 요즘에는 Apache, PHP, KDE 등을 포함한 유명한 오픈소스 프로젝트에서 사용되고 있다. PCRE는 애플사의 사파리와 같은 몇몇의 잘 알려진 사용 제품에서 그 방법을 찾기도 했다.
PCRE를 사용하는 다른 프로젝트는 다음과 같다.
Chicken, Ferite, Onyx 등...
Perl 5의 사용법(또는 문법)과 유사하게 만들어 졌고, 자제 API도 있고, POSIX와의 호환성도 좋고, 심지어 소유권을 주장할 수 있는 소프트웨어 개발에도 무료로 사용할 수 있고, 원래는 메일 전송 에이전트 용으로 만들었는데 장안의 화제가 되어 주옥같은 오프 소스 프로젝트에서 두루두루 사용되고 있으며, 애플사의 사파리와 같이 엄청 유명한 상용 제품에도 사용되고 있다고 한다
 



- Apache 설치 전 기존 설치 확인 합니다. - YUM

[root@localhost ~]# yum list httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: mirror.premi.st
Available Packages --> 설치가능한 페키지만 존재, 즉 설치된 패키지 미존재
httpd.x86_64                           2.4.6-40.el7.centos.4                           updates
[root@localhost ~]#
[root@localhost ~]# yum list apache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: mirror.premi.st
Error: No matching Packages to list


- Apache 설치 전 기존 설치 확인 합니다. - RPM

[root@localhost ~]# rpm -qa | grep apache
[root@localhost ~]# rpm -qa | grep httpd
[root@localhost ~]#


- 설치 전 필요 패키지를 설치 합니다. - yum update

[root@localhost ~]# yum update

[root@localhost ~]# yum groupinstall "Development Tools"

[root@localhost ~]# yum install libxml2-devel.x86_64 openssl-devel.x86_64 pcre-devel.x86_64 curl-devel libjpeg-devel libpng-devel.x86_64 freetype-devel.x86_64 libmcrypt libmcrypt-devel mhash.x86_64 mhash-devel.x86_64 php-mysql.x86_64 mysql-devel.x86_64 bzip2-devel.x86_64 aspell-devel.x86_64 libtidy.x86_64 libtidy-devel.x86_64 libxslt.x86_64 libxslt-devel.x86_64 glibc-utils.x86_64 libtool-ltdl-devel.x86_64[root@localhost ~]# yum install libxml2-devel.x86_64 openssl-devel.x86_64 pcre-devel.x86_64 curl-devel libjpeg-devel libpng-devel.x86_64 freetype-devel.x86_64 libmcrypt libmcrypt-devel mhash.x86_64 mhash-devel.x86_64 php-mysql.x86_64 mysql-devel.x86_64 bzip2-devel.x86_64 aspell-devel.x86_64 libtidy.x86_64 libtidy-devel.x86_64 libxslt.x86_64 libxslt-devel.x86_64 glibc-utils.x86_64 libtool-ltdl-devel.x86_64 zlib-devel openssl-devel gcc gcc-c++
* 하이라이트 부분은 추후 추가됨* httpd-devel 은 apache를 compile로 설치 할것이므로 제외하였습니다.



- 설치 패키지 일부 확인 합니다.

[root@localhost ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@localhost ~]# g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@localhost ~]# perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 29 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

[root@localhost ~]#



- 설치

  • wget을 설치 합니다.

[root@localhost src]# rpm -qa | grep wget
[root@localhost src]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: mirror.navercorp.com
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-10.el7_0.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================
 Package           Arch                Version                        Repository         Size
==============================================================================================
Installing:
 wget              x86_64              1.14-10.el7_0.1                base              545 k

Transaction Summary
==============================================================================================
Install  1 Package

Total download size: 545 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-10.el7_0.1.x86_64.rpm                                        | 545 kB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : wget-1.14-10.el7_0.1.x86_64                                                1/1
  Verifying  : wget-1.14-10.el7_0.1.x86_64                                                1/1

Installed:
  wget.x86_64 0:1.14-10.el7_0.1

Complete!
[root@localhost src]#

  • Apache 다운로드 및 압축 해제 합니다.

[root@localhost src]# cd /usr/local/src/
[root@localhost src]# wget http://apache.tt.co.kr//httpd/httpd-2.4.23.tar.gz
[root@localhost src]# tar xzf httpd-2.4.23.tar.gz
[root@localhost src]# ls -al
합계 8220
drwxr-xr-x.  3 root root       51  8월 24 14:55 .
drwxr-xr-x. 12 root root     4096  8월 24 10:19 ..
drwxr-xr-x. 11  501 games    4096  7월  1 02:15 httpd-2.4.23
-rw-r--r--.  1 root root  8406575  7월  5 04:50 httpd-2.4.23.tar.gz

  • APR(Apache Portable Runtime) 모듈을 설치 합니다.

[root@localhost src]# cd /usr/local/src
[root@localhost src]# wget http://mirror.apache-kr.org/apr/apr-1.5.2.tar.gz
[root@localhost src]# tar xzf apr-1.5.2.tar.gz
[root@localhost src]# cd apr-1.5.2
[root@localhost apr-1.5.2]# ./configure -> 1차 시기 에러 발생
[root@localhost apr-1.5.2]# cp -arp libtool libtoolT
[root@localhost apr-1.5.2]# ./configure
[root@localhost apr-1.5.2]# make
[root@localhost apr-1.5.2]# make install

  • APR-util 1.5.4 모듈을 설치 합니다.

[root@localhost src]# cd /usr/local/src
[root@localhost src]# wget http://mirror.apache-kr.org/apr/apr-util-1.5.4.tar.gz
[root@localhost src]# tar xzf apr-util-1.5.4.tar.gz
[root@localhost src]# cd apr-util-1.5.4
[root@localhost apr-util-1.5.4]# ./configure --with-apr=/usr/local/apr/
[root@localhost apr-util-1.5.4]# make
[root@localhost apr-util-1.5.4]# make install

  • PCRE 모듈을 설치 합니다.

[root@localhost src]# cd /usr/local/src
[root@localhost src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
[root@localhost src]# tar xzf pcre-8.37.tar.gz
[root@localhost src]# cd pcre-8.37
[root@localhost pcre-8.37]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.37]# make
[root@localhost pcre-8.37]# make install

  • 아파치 웹서버 소스 컴파일 전 작업

[root@localhost src]# cd /usr/local/src
[root@localhost src]# mv apr-1.5.2 httpd-2.4.23/srclib/apr
[root@localhost src]# mv apr-util-1.5.4 httpd-2.4.23/srclib/apr-util

-- 아래 두줄은 configure 후 make 시 해당 경로를 찾지 못하는 오류 발생하여 링크를 생성합니다. --> 미진행후 테스트 해봅시다. --> 성공 --> 원인:기존 httpd-devel의 yum 설치로 httpd 의존성 있는 모듈들이 설치되면서 충돌이 있었던것으로 판단됨.
[root@localhost src]# ln -s /usr/local/src/httpd-2.4.23/srclib/apr-util /usr/local/src/apr-util-1.5.4
[root@localhost src]# ln -s /usr/local/src/httpd-2.4.23/srclib/apr /usr/local/src/apr-1.5.2

  • 아파치 웹서버 소스 컴파일을 합니다.

[root@localhost src]# cd /usr/local/src
[root@localhost src]# cd httpd-2.4.23
[root@localhost httpd-2.4.23] # ./configure --enable-module=so --enable-mods-shared=most --enable-maintainer-mode --enable-deflate --enable-headers --enable-rewrite --enable-ssl --enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-proxy-balance --with-included-apr --with-pcre=/usr/local/pcre --prefix=/usr/local/apache2
[root@localhost httpd-2.4.23] # make
[root@localhost httpd-2.4.23] # make install



- 설정파일 수정 합니다.

ServerName 수정 합니다.
LoadModule unique_id_module moudles/mod_unique_id.so 주석 처리 합니다.

[root@localhost httpd-2.4.23]#  vi /usr/local/apache2/conf/httpd.conf
. . .
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName localhost

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other

. . .

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
. . .



- 방화벽 포트 열기 : http://ironpapa.tistory.com/52 

[root@localhost src]# firewall-cmd --get-active-zones
public
  interfaces: eth0
[root@localhost src]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@localhost src]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@localhost src]# firewall-cmd --reload
success
[root@localhost src]#


- 아파치 웹 서버를 서비스에 등록 및 실행 합니다.

[root@localhost src]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
[root@localhost src]# vi /etc/init.d/httpd

  #!/bin/sh
  # chkconfig: 2345 90 90
  # description: init file for Apache server daemon
  # processname: /usr/local/apache2/bin/apachectl
  # config: /usr/local/apache2/conf/httpd.conf
  # pidfile: /usr/local/apache2/logs/httpd.pid
  #
[root@localhost src]# service httpd start 


- Apache 설치를 확인 합니다.

웹브라우저에 해당 IP 로 접속후 페이지 확인 후 : http://xxx.xxx.xxx.xxx/ 
[root@localhost src]# vi /usr/local/apache2/htdocs/index.html

It works!