CentOS6.4 下安装 Apache2.4.16
1、准备工作
1.1、yum安装部分工具
1)yum -y install vim
2)yum -y install wget
3)yum -y install gcc
4)yum -y install make
5)yum -y install gcc-c++ (用于编译prce)
1.2、下载Apache及组件
1)httpd2.4.16
wget http://archive.apache.org/dist/httpd/httpd-2.4.16.tar.gz
2)apr、apr-util
wget http://archive.apache.org/dist/httpd/httpd-2.4.16-deps.tar.gz
3)zlib1.2.8(或1.2.11)
wget http://zlib.net/zlib-1.2.8.tar.gz
(wget http://zlib.net/zlib-1.2.11.tar.gz)
4)pcre8.36(或8.39)
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
(wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz)
5)openssl-1.0.1t
wget http://www.openssl.org/source/openssl-1.0.1t.tar.gz
1.3、将下载的压缩包放到安装目录(此文档中放在/ROOT下)
2、安装
2.1、安装apr和 apr-util
[root@xhTest-1 ~]# cd /root
[root@xhTest-1 ~]# tar zxvf httpd-2.4.16-deps.tar.gz
[root@xhTest-1 ~]# cd httpd-2.4.16/srclib/apr
[root@xhTest-1 apr]# ./configure --prefix=/work/local/apr
[root@xhTest-1 apr]# make && make install
[root@xhTest-1 apr]# cd ../apr-util
[root@xhTest-1 apr-util]# ./configure --prefix=/work/local/apr-util --with-apr=/work/local/apr
[root@xhTest-1 apr-util]# make && make install
2.2、安装 zlib1.2.8
[root@xhTest-1 ~]# cd /root
[root@xhTest-1 ~]# tar zxvf zlib-1.2.8.tar.gz
[root@xhTest-1 ~]# cd zlib-1.2.8
[root@xhTest-1 zlib-1.2.8]# ./configure --prefix=/work/local/zlib
[root@xhTest-1 zlib-1.2.8]# make && make install
2.3、安装pcre
[root@xhTest-1 ~]# cd /root
[root@xhTest-1 ~]# tar zxvf pcre-8.36.tar.gz
[root@xhTest-1 ~]# cd pcre-8.36
[root@xhTest-1 pcre-8.36]# ./configure --prefix=/work/local/pcre
[root@xhTest-1 pcre-8.36]# make && make install
2.4、安装openssl-1.0.1t
[root@xhTest-1 ~]# cd /root
[root@xhTest-1 ~]# tar zxvf openssl-1.0.1t.tar.gz
[root@xhTest-1 ~]# cd openssl-1.0.1t
[root@xhTest-1 openssl-1.0.1t]# ./config --prefix=/work/local/openssl -fPIC no-gost no-shared no-zlib --shared
[root@xhTest-02 openssl-1.0.1t]# make && make install
2.5、openssl升级(内网不需要升级)
[root@xhTest-1 openssl-1.0.1t]# mv /usr/bin/openssl /usr/bin/openssl.bak
[root@xhTest-1 openssl-1.0.1t]# mv /usr/include/openssl /usr/include/openssl.bak
[root@xhTest-1 openssl-1.0.1t]# ln -s /work/local/openssl/bin/openssl /usr/bin/openssl
[root@xhTest-1 openssl-1.0.1t]# ln -s /work/local/openssl/include/openssl /usr/include/openssl
2.6、安装httpd2.4.16
[root@xhTest-1 ~]# cd /root
[root@xhTest-1 ~]# tar zxvf httpd-2.4.16.tar.gz
[root@xhTest-1 ~]# cd httpd-2.4.16
[root@xhTest-1 httpd-2.4.16]# ./configure --prefix=/work/local/apache --sysconfdir=/work/httpd --enable-so --enable-cgi --enable-ssl --enable-rewrite --with-ssl=/work/local/openssl --with-pcre=/work/local/pcre --with-z=/work/local/zlib --with-apr=/work/local/apr --with-apr-util=/work/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@xhTest-1 httpd-2.4.16]# make && make install
3、配置
3.1、httpd.conf(主配置文件,根据各种需求自行配置)
[root@xhTest-1 ~]# vim /work/httpd/httpd.conf
3.2、httpd-vhosts.conf(此处为与tomcat整合,根据各种需求自行配置)
[root@xhTest-1 ~]# vim /work/httpd/extra/httpd-vhosts.conf
3.3、打开防火墙80端口
1)编辑iptables
[root@xhTest-1 ~]# vim /etc/sysconfig/iptables
2)增加如下一行配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
(增加位置在 “--reject-with icmp-host-prohibited” 之前)
3)重启防火墙
[root@xhTest-1 ~]# service iptables restart
4、启动及关闭Apache服务器
[root@xhTest-1 httpd-2.4.16]# cd /work/local/apache/bin
[root@xhTest-1 httpd-2.4.16]#./apachectl start
[root@xhTest-1 httpd-2.4.16]#./apachectl stop