참조) http://blog.naver.com/PostView.nhn?blogId=hanajava&logNo=221348635940&categoryNo=0&parentCategoryNo=0&viewDate=¤tPage=1&postListTopCurrentPage=1&from=postView&userTopListOpen=true&userTopListCount=5&userTopListManageOpen=false&userTopListCurrentPage=1
[서버 환경]
OS : CentOS 7.5 64bit CPU : Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz RAM : 1G JAVA : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64
Apache : apache-2.4.x Tomcat : apache-tomcat-8.5.x
■ 테스트 환경 (Centos Minimal 로 설치)
[root@web00 ~]# cat /etc/redhat-release
CentOS Linux release 7.5 .1804 (Core)
[root@web00 ~]# uname -a
Linux web00 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linu
1. 컴파일 설치 준비 리눅스 컴파일 설치 준비 문서를 참고하십시오.
[root@web01 ~]# yum install gcc gcc-c++ pcre-devel expat-devel wget bzip2
2. 최신버전 다운로드
3. 다운로드
apr-util-1.6.1.tar.bz2
0.41MB
httpd-2.4.41.tar.bz2
6.74MB
4. 압축 해제
[root@ web01 src ]# tar xvf apr-1.6.5.tar.bz2
[root@web01 src ]# tar xvf apr-util-1.6.1.tar.bz2
[root@web01 src ]# tar xvf httpd-2.4.37.tar.bz2
[root@web01 src ]# tar xvf pcre-8.41.tar.bz2
[root@ web01 src]# ll
total 9676
drwxr-xr-x. 27 user01 1001 4096 Sep 11 06:14 apr-1.6.5
-rw-r--r--. 1 root root 855393 Sep 14 13:07 apr-1.6.5.tar.bz2
drwxr-xr-x. 20 user01 1001 4096 Oct 18 2017 apr-util-1.6.1
-rw-r--r--. 1 root root 428595 Oct 23 2017 apr-util-1.6.1.tar.bz2
drwxr-sr-x. 11 root 40 4096 Oct 18 23:34 httpd-2.4.37
-rw-r--r--. 1 root root 7031632 Oct 22 23:13 httpd-2.4.37.tar.bz2
drwxr-xr-x. 7 1169 1169 8192 Jul 6 2017 pcre-8.41
-rw-r--r--. 1 root root 1561874 Jul 6 2017 pcre-8.41.tar.bz2
[root@ web01 src]# mv apr-1.6.5 ./httpd-2.4.37/srclib/apr
[root@ web01 src]# mv apr-util-1.6.1 ./httpd-2.4.37/srclib/apr-util
[root@ web01 src]# ll ./httpd-2.4.37/srclib/
total 12
drwxr-xr-x. 27 user01 1001 4096 Sep 11 06:14 apr
drwxr-xr-x. 20 user01 1001 4096 Oct 18 2017 apr-util
-rw-r--r--. 1 root 40 121 Feb 11 2005 Makefile.in
5. pcre 설치
[root@web01 ~] # cd /usr/local/src/pcre-8.41 [root@web01 ~] # ./configure [root@web01 ~] # make [root@web01 ~] # make install
※ 오류 해결
[root@ web01 pcre-8.41]# ./configure checking for a BSD-compatible install... /usr/bin/install -c ~~~중략~~~
configure: error: in `/usr/local/src/pcre-8.41':configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
configure: error: You need a C++ compiler for C++ support.
==> 해결방법 : gcc, gcc-c++를 설치한다.
[root@web01 pcre-8.41]# rpm -qa gcc
[root@ web01 pcre-8.41]# yum install gcc
[root@ web01 pcre-8.41]# yum install gcc-c++
[root@ web01 pcre-8.41]# rpm -qa gcc* gcc-4.8.5-28.el7_5.1.x86_64 gcc-c++-4.8.5-28.el7_5.1.x86_64
6. 아파치 설치
# mpm 등 옵션 추가 참조 : https://sharonsahadevan.com/install-apache-2-4-33-from-source-in-centos-7/
[root@web01 ~]# cd /usr/local/src/httpd-2.4.37 [root@web01 ~]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-mpm=prefork [root@web01 ~]# make [root@web01 ~]# make install
ㅁ 아파치 설치 디렉토리 확인
[root@web00 ~]# cd /usr/local/apache2/
[root@web00 apache2]# ll
total 52
drwxr-xr-x. 2 root root 4096 Dec 1 23:45 bin
drwxr-xr-x. 2 root root 4096 Dec 1 23:46 build
drwxr-xr-x. 2 root root 78 Dec 1 23:45 cgi-bin
drwxr-xr-x. 4 root root 84 Dec 1 23:56 conf
drwxr-xr-x. 3 root root 4096 Dec 1 23:45 error
drwxr-sr-x. 2 root root 24 Oct 18 23:33 htdocs
drwxr-xr-x. 3 root root 8192 Dec 1 23:45 icons
drwxr-xr-x. 2 root root 8192 Dec 1 23:46 include
drwxr-xr-x. 3 root root 281 Dec 1 23:45 lib
drwxr-xr-x. 2 root root 41 Dec 2 00:08 logs
drwxr-xr-x. 4 root root 30 Dec 1 23:46 man
drwxr-sr-x. 14 root root 8192 Oct 18 23:34 manual
drwxr-xr-x. 2 root root 4096 Dec 1 23:45 modules
[root@web00 apache2]# ll conf/
total 100
drwxr-xr-x. 2 root root 4096 Dec 1 23:45 extra
-rw-r--r--. 1 root root 18313 Dec 1 23:56 httpd.conf
-rw-r--r--. 1 root root 13077 Dec 1 23:45 magic
-rw-r--r--. 1 root root 60847 Dec 1 23:45 mime.types
drwxr-xr-x. 3 root root 37 Dec 1 23:45 original
[root@web00 apache2]# ll conf/extra/
total 68
-rw-r--r--. 1 root root 2881 Dec 1 23:45 httpd-autoindex.conf
-rw-r--r--. 1 root root 1817 Dec 1 23:45 httpd-dav.conf
-rw-r--r--. 1 root root 2942 Dec 1 23:45 httpd-default.conf
-rw-r--r--. 1 root root 1119 Dec 1 23:45 httpd-info.conf
-rw-r--r--. 1 root root 5078 Dec 1 23:45 httpd-languages.conf
-rw-r--r--. 1 root root 1395 Dec 1 23:45 httpd-manual.conf
-rw-r--r--. 1 root root 4444 Dec 1 23:45 httpd-mpm.conf
-rw-r--r--. 1 root root 2222 Dec 1 23:45 httpd-multilang-errordoc.conf
-rw-r--r--. 1 root root 13371 Dec 1 23:45 httpd-ssl.conf
-rw-r--r--. 1 root root 694 Dec 1 23:45 httpd-userdir.conf
-rw-r--r--. 1 root root 1467 Dec 1 23:45 httpd-vhosts.conf
-rw-r--r--. 1 root root 3161 Dec 1 23:45 proxy-html.conf
※ 오류 해결
→ --prefix=/usr/local/apache2에 있는대로 /usr/local/apache2가 아파치 홈 폴더가 된다.[1] → configure: error: Cannot use an external APR-util with the bundled APR 오류 발생하면[2]
./configure --prefix=/usr/local/apache2 --with-included-apr를 해보자. [root@web01 pcre-8.33]# cd /usr/local/src/httpd-2.4.20 [root@web01 httpd-2.4.20]# ./configure --prefix=/usr/local/apache2 ... (생략) config.status: creating build/config_vars.sh config.status: creating include/ap_config_auto.h config.status: executing default commands [root@web01 httpd-2.4.20]# make ... (생략) make[2]: Leaving directory `/usr/local/src/httpd-2.4.20/support'
make[1]: Leaving directory `/usr/local/src/httpd-2.4.20'
[root@web01 httpd-2.4.20]# make install ... (생략) mkdir /usr/local/apache2/man/man8 mkdir /usr/local/apache2/manual make[1]: Leaving directory `/usr/local/src/httpd-2.4.20'
※ Apache 설치시 오류 해결
apache 2.4.x 버전부터는 apr과 apr-util를 별도로 설치해야 됩니다.
하위버전에서는 설치파일에 포함되어 있었으나 버전 업그레이드 되면서 삭제되어 configuration를 실행하면 아래와 같은 화면에 에러메시지를 발생하면서 종료됩니다.
이러한 경우는 추가적인 라이브러리를 설정하지 않아서 발생되는 문제입니다.
우선 apr과 apr-util을 다운로드 받고 압축을 풀어줍니다.
mv apr-1.4.6 /usr/local/src/httpd-2.4.3/srclib/apr
mv apr-util-1.4.1 /usr/local/src/httpd-2.4.3/srclib/apr-util
압축푼 apr과 apr-util 디렉토리를 해당경로에 이동시켜줍니다.
cd /usr/local/src/httpd-2.4.3/srclib/
해당 경로로 이동해서 제대로 옮겨졌는지 확인해줍니다.
7. 아파치 시작
[root@web ~]# /usr/local/apache2/bin/httpd -k start
[root@localhost ~]# ps -ef|grep httpd
root 7822 1 0 00:04 ? 00:00:00 httpd -k start
daemon 7823 7822 0 00:04 ? 00:00:00 httpd -k start
daemon 7824 7822 0 00:04 ? 00:00:00 httpd -k start
daemon 7825 7822 0 00:04 ? 00:00:00 httpd -k start
[root@web ~]# netstat -anp | grep httpd tcp 0 0 :::80 :::* LISTEN 35683/httpd
[root@web01 ~]# curl http://127.0.0.1 <html><body><h1>It works!</h1></body></html>
8. 방화벽 끄기
[root@web ~]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT) target prot opt source destination
[root@web ~]# lokkit --selinux=disabled --disabled [root@web ~]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination
Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain OUTPUT (policy ACCEPT) target prot opt source destination
[root@web ~]# iptables -F; iptables -X
9. 같이 보기 yum 아파치 설치 컴파일 설치 pcre httpd.conf의 위치 lokkit 아파치
10. 참고 http://snoopybox.co.kr/1704 http://httpd.apache.org/docs/2.4/install.html http://d.hatena.ne.jp/yohei-a/20120809/1344490042
============================================================================================
ㅁ /usr/local/apache2/conf/httpd.conf
[root@web00 conf]# cat httpd.conf | egrep -v "#|^$"
ServerRoot "/usr/local/apache2"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User apache #daemon
Group apache #daemon
</IfModule>
ServerAdmin you@example.com
ServerName www.hanajava.com:80
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
[root@mysql ~]# yum install gcc gcc-c++ pcre-devel expat-devel
[root@mysql apache]# wget https://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
[root@mysql apache]# wget http://archive.apache.org/dist/httpd/httpd-2.4.6.tar.gz
[root@mysql apache]# wget https://ftp.pcre.org/pub/pcre/pcre-8.31.tar.gz
[root@mysql apache]# wget https://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
[root@mysql apache]# ll total 8396 -rw-r--r--. 1 root root 1016391 Nov 17 2013 apr-1.5.0.tar.gz -rw-r--r--. 1 root root 874462 Nov 17 2013 apr-util-1.5.3.tar.gz -rw-r--r--. 1 root root 6700153 Jul 19 2013 httpd-2.4.6.tar.gz
-rw-r--r--. 1 root root 1661535 Jul 6 2012 pcre-8.31.tar.gz
[root@mysql apache]# tar -xzf apr-1.5.0.tar.gz [root@mysql apache]# tar -xzf apr-util-1.5.3.tar.gz [root@mysql apache]# tar -xzf pcre-8.31.tar.gz [root@mysql apache]# tar -xzf httpd-2.4.6.tar.gz
##apr 설치 cd apr-1.5.0 ./configure --prefix=/usr/local/apr
make && make install
##오류시 조치 config.status: executing libtool commands rm: cannot remove `libtoolT': No such file or directory config.status: executing default commands [root@mysql apr-1.5.0]# cp -arp libtool libtoolT
##apr-util 설치
cd apr-util-1.5.3 ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util make && make install
## pcre 설치
[root@mysql ~]# yum install pcre-config
cd pcre-8.31
./configure --prefix=/usr/local/pcre make && make install
## httpd 설치
# mpm 등 옵션 추가 참조 : https://sharonsahadevan.com/install-apache-2-4-33-from-source-in-centos-7/
cd httpd-2.4.6 ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/loca/pcre --enable-so --enable-rewrite --with-mpm=prefork
make && make install
##httpd.conf
ServerName 주석 해제 및 수정
[출처] [hana] CentOS 7 Apache 2.4.x 컴파일 설치 | 작성자 하나자바