1. 다운로드
Apache HTTP Server 2.4는 http://httpd.apache.org/download.cgi 링크에서 다운로드할 수 있다.
2. Desupport platform
Apache HTTP Server 2.4는 BeOS, TPF, A/UX, Next, Tandem 플랫폼을 더 이상 지원하지 않는다.
3. Build
3.1. pcre-devel 설치
CentOS 기준으로 yum을 통해 pcre-devel 패키지를 설치한다.
# yum install pcre-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.kaist.ac.kr * extras: ftp.kaist.ac.kr * updates: ftp.kaist.ac.kr Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:7.8-6.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================== Installing: pcre-devel x86_64 7.8-6.el6 base 318 k Transaction Summary ================================================================================================================================== Install 1 Package(s) Total download size: 318 k Installed size: 954 k Is this ok [y/N]: y Downloading Packages: pcre-devel-7.8-6.el6.x86_64.rpm | 318 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : pcre-devel-7.8-6.el6.x86_64 1/1 Verifying : pcre-devel-7.8-6.el6.x86_64 1/1 Installed: pcre-devel.x86_64 0:7.8-6.el6 Complete!
3.2. apr 설치
Apache HTTP Server 2.4는 apr (Apache Portable Runtime) 1.4 이상을 요구하는데, 현재 (2015년 말 기준) yum을 통해 설치 가능한 apr 최신 버전은 1.3.9이다. 따라서 apr 관련 파일을 별도로 다운로드 한 후 build하는 과정을 거쳐야 한다.
3.2.1. apr 1.5.1
build 옵션은 다음과 같다.
--prefix=/apache/apr/1.5
3.2.2. apr-util 1.5.3
--prefix=/apache/apr-util/1.5 --with-apr=/apache/apr/1.5
3.3. build
다음과 같이 Apache HTTP Server 2.4를 build한다. 세부 build 옵션은 적절히 변경한다.
./configure \ --prefix=/apache/httpd/2.4 \ --enable-modules=all \ --enable-mods-shared=most \ --with-mpm=worker \ --enable-proxy \ --enable-proxy-http \ --enable-proxy-connect \ --enable-cache \ --enable-mem-cache \ --enable-disk-cache \ --enable-deflate \ --enable-ssl \ --with-ssl=/usr/include/openssl \ --with-apr=/apache/apr/1.5 \ --with-apr-util=/apache/apr-util/1.5 \ --with-pcre=/usr/bin/pcre-config
4. 변경된 설정 및 문법
4.1. conf/httpd.conf
4.1.1. DefaultType
Apache HTTP Server 2.4에서 DefaultType은 더 이상 사용되지 않는다. 2.2 버전에서는 다음과 같이 존재하였다.
# # DefaultType: the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text. # DefaultType text/plain
4.1.2. Require all
Apache HTTP Server 2.4 에서는 Access Control 관련하여 새로운 문법을 사용한다. Access Control 설정은 conf/httpd.conf 뿐 아니라 conf/extra/http-mod_jk.conf, conf/extra/httpd-info.conf 등에서도 사용된다.
먼저 모든 요청을 거절할 경우이다.
<2.2>
Order deny,allow Deny from all
<2.4>
Require all denied
어떤 상황에서는 모든 요청을 거절하되, 특정 호스트의 요청만 허용할 경우가 있다.
<2.2>
Order deny,allow Deny from all Allow from sarc.io
<2.4>
Require host sarc.io
이번에는 모든 요청을 허용할 경우이다.
<2.2>
Order allow,deny Allow from all
<2.4>
Require all granted
아직은 기존 문법도 병행하여 사용 가능하지만 새로운 문법으로 사용하길 권장한다. 또한 기존 문법을 사용할 경우 mod_access_compat 이 반드시 로드 되어야 한다.
LoadModule access_compat_module modules/mod_access_compat.so
만일 Apache HTTP Server 2.4 에서 mod_access_compat 없이 기존 문법을 사용할 경우 다음과 같은 오류가 발생한다.
AH00526: Syntax error on line … Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
4.1.3. Options
2.2 버전에서는 Options 항목에 아무 표시도 하지 않을 경우 +의 의미였다. 그러나 2.4 버전의 경우 명시적으로 + 또는 - 표시를 해야 한다.
<2.2>
Options -Indexes FollowSymLinks
<2.4>
Options -Indexes +FollowSymLinks
이를 지키지 않을 경우 다음과 같은 오류가 발생한다.
Either all Options must start with + or -, or no Option may.
4.1.4. mod_slotmem_shm
2.4 기동 시 error 로그에 다음과 같은 내용이 기록되면서, 프로세스가 올라오다가 곧바로 종료되어 버리는 경우가 있다.
…… AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded?? …… AH00020: Configuration Failed, exiting
이 경우 mod_slotmem_shm를 로드 하도록 한다. default 설정은 comment 되어 있어 해당 모듈을 로드 하지 않는다.
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
4.1.5. 사용되지 않는 module
다음 module은 2.4부터 더 이상 사용하지 않는다.
- mod_asis.so
- mod_authn_default.so
- mod_authz_default.so
- mod_disk_cache.so
- mod_ident.so
- mod_imagemap.so
- mod_mem_cache.so
4.2. conf/extra/httpd-mpm.conf
4.2.1. MaxConnectionsPerChild
MaxRequestsPerChild가 MaxConnectionsPerChild으로 이름이 변경되었다. 아직 MaxRequestsPerChild를 병행하여 사용할 수 있다.
4.2.2. MaxRequestWorkers
MaxClients가 MaxRequestWorkers로 이름이 변경되었다. 아직 MaxClients를 병행하여 사용할 수 있다.
4.3. conf/extra/httpd-vhosts.conf
4.3.1. NameVirtualHost
Apache HTTP Server 2.4 버전에서 NameVirtualHost 는 더 이상 사용되지 않는다. 2.2 버전에서는 다음과 같이 존재하였다.
# # Use name-based virtual hosting. # NameVirtualHost *:80
5. yum 설치
* 레드햇 리눅스 기준
$ /usr/sbin/httpd -V Server version: Apache/2.4.6 (Red Hat Enterprise Linux) Server built: Mar 8 2017 05:09:47 Server's Module Magic Number: 20120211:24 Server loaded: APR 1.4.8, APR-UTIL 1.5.2 Compiled using: APR 1.4.8, APR-UTIL 1.5.2 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="/run/httpd/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"