编译 httpd2.4
"注意: httpd2.4 依赖 apr 1.4 + 以上 ,apr-util-1.4 + 以上"
1, 解压缩包至任意目录
- tar apr-1.6.3.tar.bz2
- tar apr-util-1.6.1.tar.bz2
- tar httpd-2.4.29.tar.bz2
2, 复制 apr 以及 apr-util 整个解压包目录, 复制到 httpd-2.4.29/srclib / 目录下, 并且改成相对应的名字
- cp -r apr-1.6.3 httpd-2.4.29/srclib/apr
- cp -r apr-util-1.6.1 httpd-2.4.29/srclib/apr-util
3, 安装相关的依赖包
yum install pcre-devel openssl-devel expat-devel -y
4, 开始编译
- ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite -with-zlib --with-pcre --with-included-apr \ #"注意这一项是指定 apr 程序的"
- -enable-modules=most --enable-mpms-shared=all -with-mpm=prefork
- make -j 4 &&make install
4. 添加 PATH 变量
echo PATH=/app/httpd24/bin:$PATH >/etc/profile.d/httpd24.sh
检查文件
#cat /etc/profile.d/httpd24.sh
加载环境变量文件 并检查
- source /etc/profile.d/httpd24.sh
- echo $PATH
5, 创建 apache 用户
useradd - r - s / sbin / nologin apache
6, 修改 httpd 配置文件
修改这些指令
- User apache
- Group apache
7, 将服务设置为开机自动启动
方法一: 写入 /etc/rc.d/rc.local
- vim /etc/rc.d/rc.local
- /app/httpd24/bin/apachectl start
方法二: 如果原来就有 httpd, 可以修改原有的 服务脚本 /etc/init.d/httpd/ 并改名 httpd24
- cd /etc/init.d
- mv httpd httpd24
将文件中的这几项修改为如下:
- vim httpd24
- apachectl=/app/http24/bin/apachectl
- httpd=${HTTPD-/app/httpd24/bin/httpd}
- pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
将 httpd24 加入服务, 并设为开机自动启动
chkconfig --add httpd24
查看
- chkconfig --list httpd24
- httpd24 0:off 1:off 2:off 3:off 4:off 5:off 6:off
设为开机自动启动
chkconfig httpd24 on
来源: http://www.bubuko.com/infodetail-2492229.html