1.环境介绍
系统:2.6.32-279.el6.i686
2.准备编译环境
[root@localhost ~]# yum groupinstall "Server Platform Development" "Development tools" -y
[root@localhost ~]# yum install pcre-devel -y
3.下载安装需要软件
[root@localhost ~]# cd /usr/src #切换到src目录
[root@localhost ~]# wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz #下载apr文件
[root@localhost src]# wget ftp://ftp.mirrorservice.org/sites/ftp.apache.org/apr/ apr-util-1.5.4.tar.gz #下载apr-util文件
[root@localhost src]# wget http://mirrors.cnnic.cn/apache//httpd/ httpd-2.4.25.tar.bz2 #下载httpd文件
[root@localhost src]# ls
apr-1.5..tar.gz apr-util-1.5..tar.gz debug httpd-2.4..tar.bz2 kernels
4.安装apr,apr-tuil
[root@localhost src]# tar xf apr-1.5..tar.gz #解压
[root@localhost src]# cd apr-1.5.
[root@localhost apr-1.5.]# ./configure --prefix=/usr/local/apr/ #编译
[root@localhost apr-1.5.]# make && make install #安装
[root@localhost src]# tar xf apr-util-1.5..tar.gz
[root@localhost src]# cd apr-util-1.5.
[root@localhost apr-util-1.5.]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
[root@localhost apr-1.5.]# make && make install
5.编译httpd
[root@localhost src]# tar xf httpd-2.4..tar.bz2
[root@localhost src]# cd httpd-2.4.
[root@localhost httpd-2.4.]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-include-apr
[root@localhost httpd-2.4.] make && make install
6.其他必要的配置
[root@localhost httpd-2.4.]# ln -sv /etc/httpd24/ /etc/httpd #创建符号链接
`/etc/httpd' -> `/etc/httpd24/'
[root@localhost httpd-2.4.]# vim /etc/profile.d/httpd.sh #添加path变量
[root@localhost httpd-2.4.]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
[root@localhost httpd-2.4.]# source /etc/profile.d/httpd.sh #生效httpd.sh文件
[root@localhost httpd-2.4.]# httpd -v #查看版本
Server version: Apache/2.4. (Unix)
Server built: Apr ::
[root@localhost httpd-2.4.]# vim /etc/man.config #配置man文档
#添加行
MANPATH /usr/local/apache/man
7启动httpd
[root@localhost httpd-2.4.]# apachectl start #启动
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
httpd (pid ) already running
[root@localhost httpd-2.4.]# elinks -source 192.168.168.152 #测试网页
<html><body><h1>It works!</h1></body></html>