리눅스 아파치 2.4

컴코리아 2020.08.14 11:12 조회 수 : 85

[Apache2.4 Source 설치]

1. 빌드 환경 설정
```
- yum install -y make gcc g++ gcc-c++ autoconf automake libtool pkgconfig findutils oepnssl openssl-devel openldap-devel pcre-devel libxml2-devel lua-devel curl curl-devel libcurl-devel flex
```

2. 관련 모듈 다운로드 및 설치
apr 다운로드
```
cd /usr/local/src  
wget http://mirror.apache-kr.org/apr/apr-1.6.5.tar.gz
tar xvfz apr-1.6.5.tar.gz  
cd apr-1.6.5 
./configure --prefix=/usr/local/apr 
make 
make install
```

apr-util 다운로드
```
yum install expat-devel

cd /usr/local/src 
wget http://mirror.apache-kr.org/apr/apr-util-1.6.1
tar.gz tar xvzf apr-util-1.6.1.tar.gz 
cd apr-util-1.6.1 
./configure --with-apr=/usr/local/apr/ 
make 
make install 
```

pcre 다운로드
```
cd /usr/local/src 
wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz 
tar xvzf pcre-8.37.tar.gz 
cd pcre-8.37 
./configure 
--prefix=/usr/local/pcre 
make 
make install 
```

3. Apache 다운로드 및 설치
```
cd /usr/local/src 
wget http://apache.mirror.cdnetworks.com//httpd/httpd-2.4.43.tar.gz
tar xvfz httpd-2.4.43.tar.gz 
mv apr-1.5.2 httpd-2.4.43/srclib/apr 
mv apr-util-1.5.4 httpd-2.4.43/srclib/apr-util 
cd httpd-2.4.43 
./configure --enable-module=so --enable-mods-shared=most --enable-lib64 --libdir=/usr/lib64 --enable-maintainer-mode --enable-deflate --enable-headers --enable-rewrite --enable-ssl --enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-proxy-balance --with-pcre=/usr/local/pcre --prefix=/usr/local/apache 
make 
make install 
```
*** make[2]: * [htpasswd] 오류 1 ***
***해결***
vi build/config_vars.mk 파일 수정해서
AP_LIBS = 시작하는 라인을 찾아
-lexpat를 추가 후 다시 make


4. Apache 웹서버 서비스 등록 및 설정
httpd 서비스 파일 만들기
```
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd 
vim /etc/init.d/httpd 

*** chkconfig --add httpd

# chkconfig: 2345 90 90 
# description: init file for Apache server daemon 
# processname: /usr/local/apache/bin/apachectl 
# config: /usr/local/apache/conf/httpd.conf 
# pidfile: /usr/local/apache/logs/httpd.pid
// 위의 내용을 주석까지 그대로 추가
```

httpd.conf 파일 수정
```
vim /usr/local/apache/conf/httpd.conf

#ServerName localhost -> ServerName localhost
// 주석 제거
#LoadModule unique_id_module modules/mod_unique_id.so 
// 위의 행을 주석처리하고 저장
```

httpd 서비스 시작 및 실행확인
```
systemctl start httpd
systemctl enable httpd
ps -ef | grep httpd
```

5. 방화벽 설정(iptables)
```
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

* iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

//추가
systemctl restart iptables
```

주소창에 localhost & IP주소 입력시 텍스트 출력