CentOS 6下编译安装 httpd-2.4(方法一)

说明:在centos6上默认安装的是 apr-1.3+,centos7上默认安装的是apr-1.4+。
httpd2.2是基于apr-1.3+运行的,httpd2.4是基于apr-1.4+运行的,所以默认在centos6上yum安装的是httpd2.2,默认在centos7上yum安装的是httpd2.4。
要想在centos6上运行 httpd2.4 就需要编译安装apr-1.4+以及相关的软件才可以。

开始正题:
1. 如果之前虚拟机中有装httpd相关的程序包,则需卸载;

[root@gentoo ~]# yum remove httpd

2.准备下列程序包:apr-1.6.5.tar.gz 、apr-util-1.6.1.tar.gz 、httpd-2.4.48.tar.bz2
在这里插入图片描述
链接地址:
http://apache.fayea.com/apr/
http://archive.apache.org/dist/httpd/
首先进行解压:

[root@gentoo ~]# tar xvf apr-1.6.5.tar.gz  
[root@gentoo ~]# tar xvf apr-util-1.6.1.tar.gz  
[root@gentoo ~]# tar xvf httpd-2.4.48.tar.bz2

3.1 编译apr,先装包组:

[root@gentoo ~]# cd  apr-1.6.5
[root@grntoo  apr-1.6.5]# pwd

编译:

[root@grntoo  apr-1.6.5]# yum groupinstall "development tools" Loaded plugins: fastestmirror, refresh-pacjagekit, security
[root@grntoo  apr-1.6.5]# ./configure --prefix=/app/apr
[root@grntoo  apr-1.6.5]# make && make install

3.2 编译apr-util,先装包组:

[root@gentoo ~]# cd apr-util-1.6.1
[root@gentoo  apr-util-1.6.1]# ls

在这里插入图片描述

[root@gentoo apr-util-1.6.1]# yum install expat-devel
[root@gentoo  apr-util-1.6.1]# ./configure     --prefix=/app/apr-util --with-apr=/app/apr/
[root@gentoo  apr-util-1.6.1]# make && make install

3.3 编译httpd,安装包组:
安装包:

[root@gentoo ~]# yum install pcre-devel openssl-devel 

进行编译:

[root@gentoo ~]# cd  /httpd-2.4.48
[root@gentoo httpd-2.4.28]# yum install pcre-devel openssl-devel
[root@gentoo httpd-2.4.48]# ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/app/apr/ --with-apr-util=/app/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[root@gentoo httpd-2.4.48]# make -j 4 && make install

以上就为编译安装的全部步骤

启动服务:

[root@gentoo httpd-2.4.28]# pwd
/root/httpd-2.4.28
[root@gentoo httpd-2.4.28]# cd /app/http24/
[root@gentoo httpd-2.4.28]# ls
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@gentoo http24]# cd bin
[root@gentoo bin]# ls
ab         checkgid   envvars-std   htdbm     httpd       rotatelogs
apachectl  dbmmanage  fcgistarter   htdigest  httxt2dbm
apxs       envvars    htcacheclean  htpasswd  logresolve
[root@gentoo bin]# ss -ntl
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port
LISTEN     0      128                      :::22                      :::*
LISTEN     0      128                       *:22                       *:*
LISTEN     0      100                     ::1:25                      :::*
LISTEN     0      100               127.0.0.1:25                       *:*
LISTEN     0      128               127.0.0.1:6010                     *:*
LISTEN     0      128                     ::1:6010                    :::*

启动服务:

[root@gentoo bin]# ./apachectl
Starting httpd: AH00557: httpd: apr_sockaddr_info_get() failed for centos6
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message'

解决:

[root@gentoo /]# cd  /app/http24/conf
[root@gentoo conf]# vim httpd.conf

将httpd.conf中 #ServerName www.example.com:80 取消注释,或指定其他的主机名即可。

再次查看端口:有 :80端口即表示编译安装成功

[root@gentoo bin]# ss -ntl
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port
LISTEN     0      128                      :::80                      :::*
LISTEN     0      128                      :::22                      :::*
LISTEN     0      128                       *:22                       *:*
LISTEN     0      100                     ::1:25                      :::*
LISTEN     0      100               127.0.0.1:25                       *:*
LISTEN     0      128               127.0.0.1:6010                     *:*
LISTEN     0      128                     ::1:6010                    :::*

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值