CentOS 6.5编译安装httpd-2.4.7

CentOS 6.5编译安装httpd-2.4.7


CentOS 编译安装 Apache 2.4 准备:

[root@NFSServer ~]# yum groupinstall "Development tools"

从http://httpd.apache.org下载最新的httpd、apr、apr-util,然后解压缩

[root@NFSServer ~]# tar zxvf apr-1.5.0.tar.gz
[root@NFSServer ~]# tar zxvf apr-util-1.5.3.tar.gz
[root@NFSServer ~]# tar zxvf httpd-2.4.7.tar.gz

由于现在最新的httpd-2.4都需要apr、apr-util。
1.插入方法安装
[root@NFSServer ~]# mv apr-1.5.0 httpd-2.4.7/srclib/apr
[root@NFSServer ~]# mv apr-util-1.5.3 httpd-2.4.7/srclib/apr-util
[root@NFSServer ~]# cd httpd-2.4.7
[root@NFSServer httpd-2.4.7]#  ./configure  --prefix=/webserver/httpd --sysconfdir=/webserver/httpd/conf/ --with-inculded-apr --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mpms-shared=all

如果在编译中出现
1 configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

则是因为rewirte需要pcre-devel支持

[root@NFSServer httpd-2.4.7]# yum -y install pcre pcre-devel

再编译一下即可
编译完成后

[root@NFSServer httpd-2.4.7]# make && make install

2.一步一步安装
a.编译安装apr
[root@NFSServer ~]# cd apr-1.5.0
[root@NFSServer apr-1.5.0]# ./configure --prefix=/webserver/apr
[root@NFSServer apr-1.5.0]# make && make install

b.编译安装apr-util
[root@NFSServer ~]# apr-util-1.5.3
[root@NFSServer apr-util-1.5.3]# ./configure --prefix=/webserver/apr-util --with-apr=/webserver/apr
[root@NFSServer apr-util-1.5.3]# make && make install

c.编译安装httpd
[root@NFSServer ~]# cd httpd-2.4.7
[root@NFSServer httpd-2.4.7]# ./configure \
>--prefix=/webserver/httpd \
>--sysconfdir=/webserver/httpd/conf \
>--enable-so \
>--enable-rewirte \
>--enable-ssl \
>--enable-cgi \
>--enable-cgid \
>--enable-modules=most \
>--enable-modules-shared=most \
>--enable-mpms-shared=all \
>--with-apr=/webserver/apr \
>--with-apr-util=/webserver/apr-util

--prefix=/webserver/httpd :指定安装目标路径
--sysconfdir=/webserver/httpd/conf :指定配置文件安装位置
--enable-so :支持动态共享模块,如果没有这个模块PHP将无法与apache结合工作
--enable-rewirte :支持URL重写
--enable-ssl :启用支持ssl
--enable-cgi :启用支持cgi
--enable-cgid :启用支持带线状图形的CGI脚本 MPMs
--enable-modules=most :安装大多数模块
--enable-modules-shared=most :安装大多数共享模块
--enable-mpms-shared=all :支持全部多道处理方式
--with-apr=/webserver/apr :指定apr路径
--with-apr-util=/webserver/apr-util :指定apr-util路径

编译完成后

[root@NFSServer httpd-2.4.7]# make && make install

配置启动脚本:
[root@NFSServer httpd-2.4.7]# cp build/rpm/httpd.init /etc/init.d/httpd //使用init脚本管理httpd
[root@NFSServer httpd-2.4.7]# vim /etc/init.d/httpd
          httpd=${HTTPD-/usr/sbin/httpd}          修改成 httpd=${HTTPD-/webserver/httpd/bin/httpd}
          pidfile=${PIDFILE-/var/run/${prog}.pid}  修改成pidfile=${PIDFILE-/webserver/httpd/logs/${prog}.pid}
          lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
          RETVAL=0
          # check for 1.3 configuration
        check13 () {
              CONFFILE=/etc/httpd/conf/httpd.conf  修改成CONFFILE=/webserver/httpd/conf/httpd.conf
[root@NFSServer httpd-2.4.7]# chmod 755 /etc/init.d/httpd //增加执行权限
[root@NFSServer httpd-2.4.7]# chkconfig --add httpd //添加httpd到服务开机启动
root@NFSServer httpd-2.4.7]# cd /usr/sbin/
[root@NFSServer sbin]# ln -s /webserver/httpd/bin/* .
为日志文件创建软链接
[root@NFSServer sbin]# ln -s /webserver/httpd/logs /var/log/httpd

如果启动httpd的时候出现

Starting httpd: AH00557: httpd: apr_sockaddr_info_get() failed for NFSServer
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
                                                          [  OK  ]

则需要修改2处:

1.修改/etc/hosts,增加一行
127.0.0.1  NFServer

2.修改 /webserver/httpd/conf/httpd.conf,增加一行

ServerName  NFSServer

注意:NFSServer为机器名称

更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值