标签:编译安装apache 2.4.29 Centos 6.9 httpd2.4
实验环境:VMware Workstation Pro 14(试用版)
系统平台:
CentOS release 6.9 (Final) 内核 2.6.32-696.el6.x86_64
http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.bz2
http://mirror.bit.edu.cn/apache//apr/apr-1.6.3.tar.bz2
http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
http://mirror.bit.edu.cn/apache//apr/apr-iconv-1.2.2.tar.bz2
# cd /app/sdb/httpd
# tar xvf httpd-2.4.29.tar.bz2
# tar xvf apr-1.6.3.tar.bz2 -C httpd-2.4.29/srclib/ && mv httpd-2.4.29/srclib/apr-1.6.3 httpd-2.4.29/srclib/apr
# tar xvf apr-util-1.6.1.tar.bz2 -C httpd-2.4.29/srclib/ && mv httpd-2.4.29/srclib/apr-util-1.6.1 httpd-2.4.29/srclib/apr-util
# tar xvf apr-iconv-1.2.2.tar.bz2 -C httpd-2.4.29/srclib/ && mv httpd-2.4.29/srclib/apr-iconv-1.2.2 httpd-2.4.29/srclib/apr-iconv
把apr相关的源码必须解压至httpd源码目录中的srclib目录,在编译httpd的时候,指定相关源码位置。确保目录名称没有版本号
# yum install gcc gcc++ pcre-devel expat-devel openssl-devel
参数:
--no-create
该configure脚本运行正常,但不会创建输出文件。这在生成用于编译的makefile前检查测试结果很有用。
编译参数
# cd httpd-2.4.29
./configure --prefix=/usr/local/httpd2.4.29 --sysconfdir=/etc/httpd2.4 --enable-so --enable-ssl --enable-cgi --enable-cgid --enable-rewrite --with-zlib --with-pcre --with-included-apr --with-apr-iconv=srclib/apr-iconv --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --enable-include
编译安装
# make -j 8 && make install
#ln -s httpd2.4.29/ httpd
PATH=/usr/local/cmake/bin:/usr/local/httpd/bin:$PATH
#httpd -v
Server version: Apache/2.4.29 (Unix)
# getent group apache > /dev/null || groupadd -g 48 -r apache
# getent passwd apache > /dev/null || useradd -r -u 48 -g apache -s /sbin/nologin apache
#chown -R apache:apache /usr/local/httpd2.4.29/
# vim /etc/httpd2.4/httpd.conf
User apache
Group apache
直接提取一个光盘内的rpm包中的启动脚本吧(或者网上某些源找到的)
rpm2cpio的输出结果会以./开头
# rpm2cpio /misc/cd/Packages/httpd-2.2.15-59.el6.centos.x86_64.rpm |cpio -id ./etc/rc.d/init.d/httpd
修改以下几项为编译后的目录,没有目录自行创建
#mkdir /var/run/httpd
apachectl=/usr/local/httpd/bin/apachectl
httpd=${HTTPD-/usr/local/httpd/bin/httpd}
prog=httpd
# cp etc/rc.d/init.d/httpd /etc/rc.d/init.d/
# chkconfig --add httpd
# chkconfig httpd on
# service httpd start
Starting httpd: httpd (pid 93324) already running
[ OK ]
#curl 192.168.5.128
<html><body><h1>It works!</h1></body></html>
#ps aux|grep httpd
apache 93325 0.0 0.0 76464 2124 ? S 11:36 0:00 /usr/local/httpd2.4.29/bin/httpd -k start
默认编译下,除了主配置文件之外,配置文件存放在 指定的配置文件路径中extra目录,这个需要注意了,
比如要启用虚拟主机,则先在主配置文件内把相关功能启用
# Virtual hosts
#Include /etc/httpd2.4/extra/httpd-vhosts.conf
标签:编译安装apache 2.4.29 Centos 6.9 httpd2.4
原文地址:http://blog.51cto.com/191226139/2082620