하은양 믿음군 효실맘 호홍홍집s

Centos 아파치 설치하기 본문

가벼운 배움/서버관련

Centos 아파치 설치하기

호홍홍집 2016. 4. 26. 13:59

참조 : 참고링크

1. 리눅스 컴파일 설치 준비 : 리눅스에서 컴파일 설치를 하려면 gcc, make 등이 필요하다.
yum install gcc make gcc-c++

2. 다운로드
cd /usr/local/src
wget http://ftp.neowiz.com/apache/httpd/httpd-2.4.18.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 확인

3. 압축 해제
tar xvf apr-1.5.2.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
tar xvf httpd-2.4.18.tar.bz2
tar xvf pcre-8.33.tar.bz2
mv apr-1.5.2 ./httpd-2.4.18/srclib/apr
mv apr-util-1.5.4 ./httpd-2.4.18/srclib/apr-util

4. pcre 설치
cd /usr/local/src/pcre-8.33
./configure
make
make install

5. open ssl 설치
기존 openssl의 /usr/bin/openssl 을 /root 이동시키고

1.0.2e 버전을 깔고 link 걸었음.
cd /usr/src
wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
tar -zxf openssl-1.0.2-latest.tar.gz

cd openssl-1.0.2e
./config -fPIC shared    <===  64bit 시에 -fPIC 옵션을 넣어야한다. 32bit : ./config
make
make install

mv /usr/bin/openssl /root/
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl


6. 아파치 설치
cd /usr/local/src/httpd-2.4.17
./configure --prefix=/usr/local/apache2 --enable-http --enable-info --enable-cgi --enable-so --with-pcre --with-included-apr --with-mpm=worker --enable-cache --enable-ssl --with-ssl=/usr/local/ssl --enable-rewrite --enable-lib64 --libdir=/usr/lib64
make
make install

7. conf 파일 설정

* / 폴더 권한 수정...
<Directory />
    Options FollowSymLinks
    AllowOverride none
#   Require all denied
    Order deny,allow
    Deny from all
</Directory>

* 홈페이지 home 폴더권한 설정....
<Directory "/home">
    Options FollowSymLinks
    AllowOverride none
    Order allow,deny
    Allow from all
</Directory>


<IfModule dir_module>
    DirectoryIndex index.jsp index.htm index.html index.php
</IfModule>


#<Files ".ht*">
#    Require all denied
#</Files>
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

<Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options None
#   Require all granted
    Order allow,deny
    Allow from all
</Directory>

8. httpd-vhosts.conf

<VirtualHost *:80>
    SetEnvIf Request_URI .jpg image-request
    SetEnvIf Request_URI .gif image-request
    SetEnvIf Request_URI .jpeg image-request
    SetEnvIf Request_URI .swf image-request
    SetEnvIf Request_URI .png image-request
    SetEnvIf Request_URI .js image-request
    SetEnvIf Request_URI .css image-request
    SetEnvIf Request_URI .java image-request
    JkMount /*.jsp ajp13
    JkMount /webapps/* ajp13
    JkMount /home/www/* ajp13

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /home/www
    ServerName www.host.or.kr
    ServerAlias host.or.kr

    ErrorLog logs/host-error_log
    CustomLog logs/host-access_log combined env=!image-request
</VirtualHost>