본문 바로가기
시스템/wildfly

아파치 웹서버 forbidden

by cbwstar 2021. 9. 10.
728x90
반응형

ls - Z

drwxrwxr-x. root  root  system_u:object_r:httpd_sys_content_t apache

 

httpd_sys_content_t 상태가 되어야 웹서비스가 외부에서 접속가능하다.

Ls -Z 명령으로 확인후 안되어 있으면 아래 명령어로 변경한다.

chcon -h system_u:object_r:httpd_sys_content_t ./apache

 

Apache 소스 설치 및 구동

우선 설치 할 apache 소스는 wget 명령어 또는 winscp로 CentOS로 옮깁니다. tar -zxvf httpd-2.4.37.tar.gz로 압축을 풀면 아래와 같이 폴더가 생깁니다.

 

httpd-2.4.37

apache 설치에는 apr apr-util 모듈이 필요합니다. 아래와 같이 모듈을 다운받습니다.

wget http://apache.tt.co.kr/apr/apr-1.6.5.tar.gz

wget http://apache.tt.co.kr/apr/apr-util-1.6.1.tar.gz

tar -zxvf apr-1.6.5.tar.gz

tar -zxvf apr-util-1.6.1.tar.gz

압축 풀린 apr과 apr-util을 httpd-2.4.37/srclib/ 하위로 옮겨야 합니다. 이 때, 파일 이름 그대로 옮기면 안되고 apr과 apr-util로 이름을 변경해야 합니다.

mv apr-1.6.5 apr

mv apr-util-1.6.1 apr-util

mv apr httpd-2.4.37/srclib/

mv apr-util httpd-2.4.37/srclib/

apache 설치에는 pcre와 zlib가 필요합니다. pcre 설치 과정에서 g++ 이 없으면 에러가 발생하므로 설치 후 pcre를 다운받아 설치 작업을 진행합니다.

yum install -y gcc-c++    // g++ 설치

yum install -y zlib-devel // zlib 설치wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

tar -zxvf pcre-8.42.tar.gz

cd pcre-8.42

./configure

make && make install

현 상태에서 configure 입력 후 make 작업을 하면 아래와 같이 에러가 발생합니다.

xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’

xml/apr_xml.c:364: error: ‘apr_xml_parser’ has no member named ‘xp’

이런 에러를 보지 않으려면 아래와 같이 expat-devel을 설치합니다.

yum install -y expat-devel

이제 configure 명령을 입력합니다. 제 경우는 이미 설치된 apache 옵션이 아래와 같은 형태라서 그대로 따라했습니다.

cd ../httpd-2.4.37

./configure --prefix=/home1/apache --enable-module=so --enable-mods-shared=all --enable-so --enable-deflate --enable-rewrite --with-included-apr

make && make install

위 과정에 에러가 없다면 apache 설치 경로는 prefix 경로인 /home1/apache입니다. 이동해서 확인해 보겠습니다.

[root@localhost apache]# ll

total 60

drwxr-xr-x. 2 root root 4096 Jan 1 16:45 bin

drwxr-xr-x. 2 root root 4096 Jan 1 16:46 build

drwxr-xr-x. 2 root root 4096 Jan 1 16:45 cgi-bin

drwxr-xr-x. 4 root root 4096 Jan 1 17:02 conf

drwxr-xr-x. 3 root root 4096 Jan 1 16:45 error

drwxr-sr-x. 2 root root 4096 Oct 18 07:33 htdocs

drwxr-xr-x. 3 root root 4096 Jan 1 16:45 icons

drwxr-xr-x. 2 root root 4096 Jan 1 16:45 include

drwxr-xr-x. 3 root root 4096 Jan 1 16:45 lib

drwxr-xr-x. 2 root root 4096 Jan 1 17:03 logs

drwxr-xr-x. 4 root root 4096 Jan 1 16:46 man

drwxr-sr-x. 14 root root 12288 Oct 18 07:34 manual

drwxr-xr-x. 2 root root 4096 Jan 1 16:45 modules

bin 폴더로 들어가면 apachectl 바이너리가 있는데, 이를 통해 apache를 실행할 경우 아래 에러가 발생합니다.

 

[root@localhost conf]# /home1/apache/bin/apachectl start

 

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName’ directive globally to suppress this message

http.conf에서 ServerName을 찾아 주석을 해제합니다.

#ServerName www.example.com:80  // 변경전

ServerName www.example.com:80  // 변경후

 

최종적으로 실행하기 전에 iptables 서비스를 해제하고 실행합니다.

[root@localhost conf]# service iptables stop

[root@localhost conf]# /home1/apache/bin/apachectl start

CentOS IP로 웹에 접속하면 확인할 수 있습니다.

 

 

리눅스 아파치(httpd 2.4.x) 설치시 pcre-config 에러 해결

configure: error: pcre-config for libpcre not found. PCRE is required and available fromhttp://pcre.org/

 

해결책 : # yum install pcre-devel

 

소스설치:

# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz

# tar - pcre08.10.tar.gz

./configure --prefix=/usr/local/

728x90
반응형

'시스템 > wildfly' 카테고리의 다른 글

ear 만들기(세션공유)  (0) 2021.09.13
아파치+wildfly 연동  (0) 2021.09.10
wildfly 자동배포  (0) 2021.09.10
jboss-deployment-structure.xml  (0) 2021.08.07
윈도우에서 포트 죽이기  (0) 2021.08.03

댓글



"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

loading