CentOS 6.5编译安装httpd-2.4.7

Centos 编译安装 Apache 2.4 准备:

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

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

1
2
3
[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.插入方法安装

1
2
3
4
5
[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 ~] # mkdir -p /webserver/httpd/conf
[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-deflate --enable-expires --enable-headers --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支持

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

再编译一下即可

编译完成后

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


2.一步一步安装

a.编译安装apr

1
2
3
[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

加入在安装apr的过程中出现rm: cannot remove `libtoolT': No such file or directory
则编辑configure文件,把RM='$RM'改为RM='$RM  -f'


b.编译安装apr-util

1
2
3
[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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@NFSServer ~] # cd httpd-2.4.7
[root@NFSServer httpd-2.4.7] # ./configure \
>--prefix= /webserver/httpd  \
>--sysconfdir= /webserver/httpd/conf  \
>-- enable -deflate \
>-- enable -expires \
>-- enable -headers \
>-- 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-deflate :支持以deflate方式压缩

--enable-expires:支持客户端缓存

--enable-headers :支持头部信息

--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路径


编译完成后

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


配置启动脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[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的时候出现

1
2
3
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,增加一行

1
127.0.0.1  NFServer

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

1
ServerName   NFSServer

注意:NFSServer为机器名称


本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1360429


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值