前提条件

rpm -qa httpd

yum -y install pcre-devel

1、编译安装apr

tar xf apr-1.5.2.tar.gz

cd apr-1.5.2

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

make && make install

2、编译安装apr-util

tar xf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4

#--with-apr=PATH

#--prefix=PREFIX

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

make && make install

3、编译安装apache

tar xf httpd-2.4.18.tar.gz

cd httpd-2.4.18

./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so \ 

--enable-ssl --enable-cgi --enable-rewrite --with-zlib --enable-mpms-shared=all \

--with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \

--enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer \

--enable-lbmethod-heartbeat --enable-slotmem-shm --enable-slotmem-plain \

--enable-heartbeat --enable-heartmonitor --enable-watchdog

make && make install


配置apache通过mod_proxy模块与tomcat结合

要使用mod_proxy与tomcat结合,需要apache已经安装mod_proxy、mod_proxy_http、mod_proxy_ajp和proxy_balancer_module

(实现tomcat集群时会用到)等模块


尝试启动apache

/usr/local/apache/bin/httpd -k start

netstat -tunlp

发现并没有80端口起来,尝试几遍还是启动不来

查看httpd日志

cat /usr/local/apache/logs/error_log发现如下错误:

[Tue May 17 07:10:46.572233 2016] [proxy_balancer:emerg] [pid 1434:tid 139691988010752] AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??

[Tue May 17 07:10:46.572778 2016] [:emerg] [pid 1434:tid 139691988010752] AH00020: Configuration Failed, exiting

[Tue May 17 07:16:15.916227 2016] [proxy_balancer:emerg] [pid 1438:tid 139879976126208] AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??

[Tue May 17 07:16:15.916951 2016] [:emerg] [pid 1438:tid 139879976126208] AH00020: Configuration Failed, exiting

根据错误信息发现模块mod_slotmem_shm并没有加载,于是修改配置文件

vim /etc/httpd/httpd.conf

#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so将注释#去掉

/usr/local/apache/bin/httpd -k start

netstat -tunlp

于是服务终于启动上来了