共计 3312 个字符,预计需要花费 9 分钟才能阅读完成。
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