apache2.4安装说明详细文档
安装apache2.4.29
需要下载下列所示的几个源码包:
httpd-2.4.29.tar.gz
apr-1.6.3.tar.gz
apr-util-1.6.1.tar.gz
pcre-8.41.tar.gz
#安装apr
tar -zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr && make -j 4 && make install
#安装apr-util
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make -j 4 && make install
#安装pcre2
tar -zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure --prefix=/usr/local/pcre && make -j 4 && make install
#安装apache24
tar -zxvf httpd-2.4.29.tar.gz
cd httpd-2.4.29
./configure --prefix=/home/apache2 --enable-cgi --enable-cgid --enable-ssl --enable-rewrite --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --with-mpm=event --enable-proxy --enable-proxy-fcgi --enable-expires --enable-deflate --enable-suexec --with-suexec-caller=daemon
make -j 4 && make install
#--enable-suexec 负责处理CGI和SSI程序的请求,确保网页使用者能以该目录或程序的用户ID来执行远程程序。
###############生成mod_jk连接tomcat###############
mod_jk下载地址为:http://tomcat.apache.org/download-connectors.cgi
tomcat-connectors-1.2.41-src.tar.gz
tar -zxvf tomcat-connectors-1.2.41-src.tar.gz
cd tomcat-connectors-1.2.41-src/native
./configure --with-apxs=/home/apache2/bin/apxs && make -j 4
apache-2.0文件夹下可以找到mod_jk.so。将这个文件复制到apache安装路径下的modules文件夹下
###############生成mod_jk连接tomcat###############
################安全模块安装###############
#依赖包
#lua 5.1.tar.gz https://www.lua.org/ftp/lua-5.1.5.tar.gz
#automake-1.15.tar.gz https://codeload.github.com/lloyd/yajl/zip/master
#autoconf-2.65.tar.gz http://ftpmirror.gnu.org/autoconf/autoconf-2.65.tar.gz
#yajl-master.zip https://codeload.github.com/lloyd/yajl/zip/master
#modsecurity-2.9.2.tar.gz https://www.modsecurity.org/tarball/2.9.2/modsecurity-2.9.2.tar.gz
#安装modsecurity https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#Installation_for_Apache
wget https://www.modsecurity.org/tarball/2.9.2/modsecurity-2.9.2.tar.gz
tar -zxf modsecurity-2.9.2.tar.gz
cd modsecurity-2.9.2
./autogen.sh #libtoolize: command not found -- should install libtool*
./configure --with-apxs=/home/apache2/bin/apxs
make
make install
# 2.x版本与 3.x版本安装有差别
################安全模块安装###############
#check
ls /home/apache2/modules/
/home/apache2/bin/apachectl configtest
if [ $? -eq '0' ];then countinue; else echo "apachectl check filed";exit 1;fi
cp ModSecurity/modsecurity.conf-recommended /home/apache2/conf/modsecurity.conf
cat >> /home/apache2/conf/httpd.conf << EOF
#必须在ModSecurity之前加载libxml2和lua5.1
LoadFile /usr/lib64/libxml2.so
LoadFile /usr/lib64/liblua-5.1.so
#加载ModSecurity模块
LoadModule security2_module modules/mod_security2.so
EOF
cd /home/apache2
sed -i "s/ServerName/ServerName 0.0.0.0/g" httpd.conf
sed -i "s/SecUnicodeMapFile/\#SecUnicodeMapFile/g" modsecurity.conf
/home/apache2/bin/apachectl configtest
+++++++make
安装编译过程中第一个错xml/apr_xml.c:35:19: error: expat.h: No such file or directory
参考:Linux 编译 apr-util 时报错 - mingc - 博客园 https://www.cnblogs.com/mingc/p/7695610.html
应安装:yum -y install expat-devel
重新编译./configure make. make install..三部曲
+++++++make
安装编译过程中第二个错make[2]: *** [htpasswd] Error 1
参考:APACHE 编译错误:make[2]: *** [htpasswd] Error 1 解决办法-kennyluo-51CTO博客 http://blog.51cto.com/uppower/1123033
解决办法
#mv /usr/lib/libm.a /usr/lib/libm.a.bak
#mv /usr/lib/libm.so /usr/lib/libm.so.bak
#mv /usr/lib/libexpat.so /usr/lib/libexpat.so.bak
#ln -s /usr/lib64/libm.a /usr/lib/libm.a
#ln -s /usr/lib64/libm.so /usr/lib/libm.so
#ln -s /usr/lib64/libexpat.so /usr/lib/libexpat.so
然后这个解决不了。有说是apr版本过高建议换成[1.5版本](http://archive.apache.org/dist/apr/)
++++++++make
make时出现server/.libs/libmain.a(exports.o):(.data+0xcfc): undefined reference to `apr_os_uuid_get’,
解决办法:
cd srclib/apr; make
cd srclib/apr-util; make
++++++++start启动报错
AH00534: httpd: Configuration error: No MPM loaded.
配置文件httpd.conf,启用此模块
LoadModule mpm_event_module modules/mod_mpm_event.so
参考
使用modzecurity加强apache安全
https://blog.csdn.net/jiangxinyu/article/details/1473017
详解Apache 2.4web服务器
http://www.mamicode.com/info-detail-1719788.html
深度剖析apache 2.4web服务器(史上最全)-Mr大表哥-51CTO博客
http://blog.51cto.com/zpf666/1920921
apache2.4 tomcat8整合 - CSDN博客
http://blog.csdn.net/ttttaaaagggg/article/details/70155920
Apache性能优化(1):多处理模块event性能优化 – 健翔桥的小站
https://www.jianxiangqiao.com/apache2-4-optimizing/
Apache2.4+Tomcat7集群搭建 -fhadmin24-ITPUB博客
http://blog.itpub.net/30372520/viewspace-1754339/