Apache 2.4.1 is the latest stable version available on Apache.org download section. Since it is the latest version so it may have plenty of dependencies issues. In my case, i am installing it from source(httpd-2.4.1.tar.bz2).

Currently i am logged in using SSH on Plain CentOS 6.2 server and it has very basic packages installed.

Downloading and compiling Apache 2.4.1

cd /usr/local/src/
wget http://apache.mirrors.pair.com//httpd/httpd-2.4.1.tar.bz2
tar -jxf httpd-2.4.1.tar.bz2
cd httpd-2.4.1
./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite

Note : Here i required deflate,expires,headers and other modules so i included that.

Ops, failed to dependencies.. because we don’t have gcc compiler and other devel packages for apr, apr-utils, openssl and so on.
yum install apr-devel apr-util-devel gcc pcre-devel.x86_64 zlib-devel openssl-devel

Great. Here we go;
make
again ERROR :

rotatelogs.c:298: warning: implicit declaration of function ‘apr_file_link’
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -std=gnu99 -pthread
-o rotatelogs  rotatelogs.lo      /usr/lib64/libaprutil-1.la -ldb-4.7 -lexpat
-ldb-4.7 /usr/lib64/libapr-1.la -lpthread
rotatelogs.o: In function `post_rotate':
rotatelogs.c:(.text+0x5ed): undefined reference to `apr_file_link'
collect2: ld returned 1 exit status
make[2]: *** [rotatelogs] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.1/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.1/support'
make: *** [all-recursive] Error 1

Current apr and apr-util version is older while Apache 2.4.1 requires latest APR and APR-utils e.g 1.4.x is the latest available version.
Lets include the latest apr and apr-util into apache srlib/ so it can also be compiled along with Apache.
cd /usr/local/src/httpd-2.4.1/srclib/

Installing APR & APR-Utils dependencies :

wget http://mirror-cybernet.lums.edu.pk/pub/apache//apr/apr-util-1.4.1.tar.bz2
wget http://mirror-cybernet.lums.edu.pk/pub/apache//apr/apr-1.4.6.tar.bz2

Note : If this mirror doesn’t work, chose other mirrors

tar -jxf apr-1.4.6.tar.bz2
tar -jxf apr-util-1.4.1.tar.bz2
mv apr-1.4.6 apr
mv apr-util-1.4.1 apr-util

Lets configure it now :
./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util
make
make install

Following this tutorial i was able to install Apache 2.4.1 successfully on CentOS 6.2. If you are unable to install or having difficulty you can leave a comment and i will try to respond you quickly as much possible.

 

출처 : http://www.hackersgarage.com/installing-apache-2-4-1-from-source-on-centos-6-2-linux.html

'apache' 카테고리의 다른 글

APM(apache 2.4.1) 설치시 문제 해결  (0) 2012.07.10
[Ubuntu] Apache2.4.x 설치  (0) 2012.07.10
mod_deflate 설치 / 사용  (0) 2012.02.16
아파치 mod_deflate로 압축 전송하기  (0) 2012.02.16
[Apache] MPM(Prefork VS Worker)  (0) 2011.04.19

설치 환경
OS : CentOS release 6.2 (Final)
Mysql : 5.1.60
Apache : 2.4.1
Php : 5.3.10

[Mysql]
# groupadd mysql
# useradd -g mysql mysql
./configure --prefix=/data/mysql --localstatedir=/data/mysql/data --with-charset=euckr --with-extra-charsets=all
make && make install

/data/mysql/bin/mysql_install_db --datadir=/data/mysql/var --force
chown -R mysql:mysql /data/mysql

*오류*
mysql checking for termcap functions library... configure: error: No curses/termcap library found
*해결 방법*
yum install libtermcap-devel

*오류*
my_global.h:1110: error: redeclaration of C++ built-in
*해결 방법*
1.yum install gcc-c++설치
2.make clean
3. 재 컴파일

[Apache]
./configure --prefix=/data/apache --enable-so --enable-rewrite --enable-proxy --enable-ssl --enable-unique-id

make && make install

Apache 컴파일 시 오류 처리 사항

*오류*
checking for OpenSSL version >= 0.9.7... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
*해결 방법*
yum install openssl-devel
yum update openssl

*오류*
rotatelogs.o: In function `post_rotate':
rotatelogs.c:(.text+0x5ed): undefined reference to `apr_file_link'
collect2: ld returned 1 exit status
make[2]: *** [rotatelogs] Error 1
make[2]: Leaving directory `/root/src/httpd-2.4.1/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/src/httpd-2.4.1/support'
make: *** [all-recursive] Error 1
*해결 방법*
Apache 2.4.에서는 apr 1.4이상이 필요하다 따라서 rpm apr 패키지 버전이 1.4이하라면 소스컴파일을 해야 한다.
1. yum remove "apr*"
2.APR 소스 설치
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.4.6.tar.gz
tar xzf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure ; make ; make install
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.4.1.tar.gz
tar zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --with-apr=/usr/local/apr
yum install -y pcre-devel lua-devel libxml2-devel

[php]
./configure --prefix=/data/php --with-mysql=/data/mysql --with-apxs2=/data/apache/bin/apxs --enable-sysvshm=yes --enable-sysvsem --enable-debug=no --with-ttf --with-png-dir=/usr --with-zlib-dir --with-jpeg-
dir=/usr --with-gdbm=/usr --enable-ftp --enable-mbstring --enable-sockets --enable-wddx --with-freetype-dir=/usr --enable-bcmath --with-curl --with-mcrypt --enable-mbregex --enable-exif --with-gd --enable-gd-
native-ttf --enable-calendar --with-openssl --with-mysqli=/data/mysql/bin/mysql_config

make && make install

출처 : http://absorbed.tistory.com/
Apache2.4.x 버전부터는 APR 과 APR-util을 별로도 설치하여야 한다. 하위버전에서는 설치파일에 포함되어 있었으나 버전 업이 되면서 삭제되어 configure를 실행하면 아래와 같은 에러메시지를 발생하면서 종료된다.

Configuring Apache Portable Runtime library ...

Checking for APR... no
Confgirue: error: APR not found. Please read the documentation

http://apr.apache.org/ 에서 다운받아 설치함



*APR(Apache Portable Runtime) 설치

$ wget http://mirror.sdunix.com/apache//apr/apr-1.4.6.tar.gz
$ tar xvf apr-1.4.6.tar.gz
~/apr-1.4.6$ ./configure
~/apr-1.4.6$ ./make
~/apr-1.4.6$ ./sudo make install




*ARP-Util 설치

$ wget http://apache.tt.co.kr//apr/apr-util-1.4.1.tar.gz
$ tar xvf apr-util-1.4.1.tar.gz
~/apr-util-1.4.1$ ./configure --with-apr=/usr/local/apr
~/apr-util-1.4.1$ make
~/apr-util-1.4.1$ sudo make install


Apache 재설치시 Error 발생.
configure: error: pcre-config for libpcre not found.PCRE is required and available from http://pcre.org/




*PCRE(Perl Compatible Regular Expressions) 설치

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xvf pcre-8.30.tar.gz
~/pcre-8.30$ ./configure
~/pcre-8.30$ make
~/pcre-8.30$ sudo make install

*Apache 2.4.x 설치
$ wget http://apache.cs.utah.edu//httpd/httpd-2.4.2.tar.gz
$ tar xvf httpd-2.4.2.tar.gz
~/httpd-2.4.2$ ./configure --prefix=/home/www/apache2 --enable-module=so --enable-mods-shared-all --enable-so --enable-rewrite --enable-sll

~/httpd-2.4.2$ make
~/httpd-2.4.2$ sudo make install



~/apache2/bin$ ldd httpd
linux-gate.so.1 => (0xb779b000)
libpcre.so.1 => not found ------------------------------------> problem
libaprutil-1.so.0 => /usr/local/apr/lib/libaprutil-1.so.0 (0xb775a000)
libapr-1.so.0 => /usr/local/apr/lib/libapr-1.so.0 (0xb7728000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb76f8000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7553000)
libexpat.so.0 => /usr/local/apr/lib/libexpat.so.0 (0xb752a000)
libcrypt.so.1 => /lib/i386-linux-gnu/libcrypt.so.1 (0xb74f9000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb74f3000)
/lib/ld-linux.so.2 (0xb779c000)




~/.profile 에 export LD_LIBRARY_PATH=/usr/local/lib 를 추가

~/apache2/bin$ ldd httpd
linux-gate.so.1 => (0xb779b000)
libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0xb777c000) ---------- 라이브러리를 찾아옴
libaprutil-1.so.0 => /usr/local/apr/lib/libaprutil-1.so.0 (0xb775a000)
libapr-1.so.0 => /usr/local/apr/lib/libapr-1.so.0 (0xb7728000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb76f8000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7553000)
libexpat.so.0 => /usr/local/apr/lib/libexpat.so.0 (0xb752a000)
libcrypt.so.1 => /lib/i386-linux-gnu/libcrypt.so.1 (0xb74f9000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb74f3000)
/lib/ld-linux.so.2 (0xb779c000)



/etc/sudoers 파일을 수정하여 root 계정이 아닌 다른 계정으로 Apache 실행하기

# User privilege specification
root ALL=(ALL:ALL) ALL
www ALL=/home/www/apache2/httpd ------ www 계정만이 httpd 를 sudo 를 통한 실행 권한을 가짐



*sudo 실행시에 LD_LIBRARY_PATH 를 적용시키기

/etc/ld.so.conf.d$ ls -alrt
합계 24
-rw-r--r-- 1 root root 44 9월 11 2010 libc.conf
-rw-r--r-- 1 root root 108 3월 7 06:50 i686-linux-gnu.conf
lrwxrwxrwx 1 root root 40 5월 29 01:10 i386-linux-gnu_GL.conf -> /etc/alternatives/i386-linux-gnu_gl_conf

/etc/ld.so.conf.d$ cat i386-linux-gnu_GL.conf
/usr/lib/i386-linux-gnu/mesa


i386-linux-gnu_GL.conf 파일에 라이브러리 패스를 추가

/etc/ld.so.conf.d$ cat i386-linux-gnu_GL.conf
/usr/lib/i386-linux-gnu/mesa
/usr/local/lib

 

출처 :  http://it-korea-well.tistory.com/

 

1. 설치
cd apache_home/bin
./apxs -i -a -c /usr/local/src/httpd-2.2.8/modules/filters/mod_deflate.c

2. 설정

추가
LoadModule deflate_module     modules/mod_deflate.so

<IfModule deflate_module>

   AddOutputFilterByType DEFLATE text/html text/plain text/xml
   AddOutputFilterByType DEFLATE application/xhtml+xml application/xml application/rss+xml
   AddOutputFilterByType DEFLATE text/css application/javascript application/x-javascript
   AddOutputFilterByType DEFLATE audio/midi

   DeflateCompressionLevel 9

   DeflateFilterNote Input instream
   DeflateFilterNote Output outstream
   DeflateFilterNote ratio

   #LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
   LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
   CustomLog logs/deflate_log deflate

   # Netscape 4.x problem
   BrowserMatch ^Mozilla/4 gzip-only-text/html

   # Netscape 4.06-4.08 problem
   BrowserMatch ^Mozilla/4\.0[678] no-gzip

   # MSIE
   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

   # no-gzip
   SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|jpg|png|bmp|zip|tar|rar|alz|a00|ace|txt|mp3|mpe?g|wav|asf|wma|wmv|swf|exe|pdf|doc|xsl|hwp|java|c|t?gz|bz2|7z)$ no-gzip dont-vary

</IfModule>



아파치 재시작

3. 테스트

로그 확인

phpinfo();

HTTP Compression Test



4. 참고
http://httpd.apache.org/docs/2.2/mod/mod_deflate.html


 웹호스팅으로 누리집을 꾸릴 때는 전송량(traffic)을 의식하지 않을 수 없다. 웹호스팅 상품들은 일정 기간 동안의 전송량 한계가 클수록 많은 값을 치러야 하기 때문이다. 그래서 gzip를 통한 실시간 압축 전송은 한정된 전송량을 알차게 쓰는 길이 되곤 한다. 압축하는 과정이 서버에겐 짐이지만, 전송할 내용이 줄어든 만큼 전송 시간이 줄어들어 오히려 서버의 짐을 덜 수 있다.

CSS/JavaScript를 압축하는 Minify, 텍스트큐브의 압축 전송 플러그인, 워드프레스의 WP-Cache 플러그인 따위는 서버 관리 권한이 없는 일반 호스팅 계정에서 쓸 수 있는 gzip 압축 전송 도구들이다. Minify는 HTML/XML 파일까지 압축하지 못하고, 플러그인으로 제공되는 도구들은 웹 풀그림의 관리 화면을 압축하지 못한다. 특정 웹 풀그림의 PHP 핵심 코드를 고쳐서 관리 화면까지 압축하는 방법(텍스트큐브 gzip 전체 적용시키기)이 있긴 하지만, 웹 풀그림이 판올림하면 다시 고쳐 주어야 하는 점이 번거롭다.

아파치(Apache) 웹 서버를 쓰고 있고 아파치 내장 모듈인 mod_deflate이 켜져 있다면, httpd.conf나 .htaccess에서 mod_deflate를 통하여 gzip 압축 전송을 설정할 수 있다. /etc/httpd/conf/httpd.conf의 전체 설정 또는 개별 가상 호스트(Virtual Host)나 .htaccess 파일의 적당한 곳에 다음과 같은 내용을 끼워 넣는다.

<IfModule mod_deflate>
AddOutputFilterByType DEFLATE text/plain text/html text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml application/xml application/rss+xml
AddOutputFilterByType DEFLATE text/css application/javascript application/x-javascript
AddOutputFilterByType DEFLATE audio/midi

DeflateCompressionLevel 9

BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.xx에는 HTML만 압축해서 보냄
BrowserMatch ^Mozilla/4\.0[678] no-gzip # Netscape 4.06~4.08에는 압축해서 보내지 않음
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # 자신을 Mozilla로 알리는 MSIE에는 그대로 압축해서 보냄
</ifModule>

위 설정이 적용되면 Text/HTML/CSS/JS/MIDI 파일들은 웹 서버에서 바로 gzip로 압축하여 보낸다.주1 BrowserMatch 구문은 이제는 거의 쓰이지 않는 넷스케이프(Netscape)의 문제를 피하게 하기 위함이다.

.htaccess 파일은 저장하면 바로 적용되지만, httpd.conf에 넣은 내용은 서버를 다시 시작하거나 명령창에서 다음과 같은 명령으로 웹 서버 설정을 다시 읽어 들여서 설정한 내용을 반영할 수 있다.

[root@??? /]# /etc/init.d/httpd graceful

이렇게 하면 텍스트큐브 압축 전송 플러그인처럼 단순하게 gzip 압축만을 돕는 도구는 쓸 필요가 없다. 다만 CSS/JS 파일 압축은 mod_deflate로 그때그때 압축하는 것보다 Minify를 쓰는 쪽이 더 좋을 것이다. Minify는 gzip 압축뿐만 아니라 쓸모 없는 내용을 줄이고 압축한 내용을 갈무리하여 꺼내 쓰는 시렁(캐시) 기능까지 갖추었기 때문이다. Minify를 쓰고 있다면, 위에서 끼워 넣은 것 가운데 다음 내용만 '#' 기호를 붙여 주석으로 만들어서 CSS/JS 파일 압축을 Minify에게 고스란히 맡길 수 있다.

# AddOutputFilterByType DEFLATE text/css application/javascript application/x-javascript

mod_deflate를 통한 압축 전송은 mod_deflate 모듈이 켜져 있는 서버에서 쓸 수 있다. 따라서 서버 관리 권한이 없는 웹호스팅 계정에서는 아파치에서 mod_deflate가 꺼져 있으면 mod_deflate를 통한 압축 기능을 쓸 수 없다. phpinfo() 함수를 통하면 이 모듈이 켜져 있는지를 알 수 있다.

<?php
phpinfo();
?>

개별 파일이 잘 압축되어 보내지는지는 HTTP Compression Test에서 확인할 수 있다.

 출처 : http://pat.im/

'apache' 카테고리의 다른 글

Installing Apache 2.4.1 from source on CentOS 6.2 Linux  (0) 2012.07.10
APM(apache 2.4.1) 설치시 문제 해결  (0) 2012.07.10
[Ubuntu] Apache2.4.x 설치  (0) 2012.07.10
mod_deflate 설치 / 사용  (0) 2012.02.16
[Apache] MPM(Prefork VS Worker)  (0) 2011.04.19

MPM : Multi-Processing Modules, MPMs (다중 처리 모듈)

- 여러 방식이 존재하지만, 대표적으로 Prefork 와 Worker 방식을 많이 사용함.

Prefork

- 쓰레드가 한개의 자식 프로세스를 여러개 사용하며 각 프로세스는 한번에 한 연결을 담당

- worker보다 좀 더 많은 메모리를 사용함

- 프로세스간 메모리를 직접 공유하지 않으므로, 메모리 공간이 독립적이어서 안정적임

 

 

 

 

 

 

설정 예
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>


옵션 설명
StartServer
아파치 구동시에 자식 프로세스 개수 지정

MinSpareServersMaxSpareServers
부하가 적어서 MinSpareServers 개수 보다 적었을 경우 최소한 이 개수 만큼 유지하려고 아파치가 노력하고
부하가 증가하여 프로세스 개수가 많아질 경우에 MaxSpareServers 개수 이하로 줄이려고 아파치는 노력한다.
즉, 절대적인 수치가 아니다.

MaxClient
초기 시작시 실행가능한 최대 아파치 자식 프로세스의 개수를 지정
*worker방식의 MaxClient 와는 전혀 다른 의미임.

MaxReqeustPerChild
클라이언트들의 요청 개수를 제한. 만약 자식 프로세스가 이 값만큼의 클라이언트 요청을 받았다면 이 자식 프로세스는 자동으로 죽게 된다. 0 일 경우엔 무한대

 

 

 

 

Worker

- 자식 프로세스들이 각각 여러 쓰레드를 사용하며, 각 쓰레드는 한번에 한 연결을 담당

- Prefork보다 메모리 사용량이 적음. 통신량이 많은 서버에 적절

- 쓰레드 간에 메모리 공간을 공유함. 리소스 경합이 발생하지 않도록 주의 필요.

 

 

 

 

설정 예
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

   

옵션 설명
StartServers
시작시에 생성되는 서버 프로세스의 개수

MaxClient
동시 연결가능한 클라이언트의 최대 개수.

MinSpareThreads
최소 thread 개수

MaxSpareThreads
최대 thread개수

ThreadPerChild
개별 자식 프로세스가 지속적으로 가질 수 있는 Thread의 개수

MaxRequestPerChild
자식 프로세스가 서비스할 수 있는 최대 요청 개수

 

 

 

 

 

 

* 확장성이 필요한 사이트는 worker방식을 택하고, 안정성과 오래된 소프트웨어와 호환성이 필요한 사이트는 Prefork를 사용하기도 한다.

* Linux의 경우, Prefork 방식이 Default이며, Worker방식을 사용하기 위해서는 설치시에 -with-mpm=worker 옵션을 주어야 한다.

  ex) ./configure --prefix=/home/paint/apache-2.2.15 --enable-mods-shared=all --enable-module=so --enable-so  --with-mpm=worker

Posted by 빼인트

+ Recent posts