参看:http://blog.csdn.net/cookies_6362/article/details/2881206
(1) 获得源代码
# lynx http://www.apache.org/dist/httpd/httpd-2_0_NN.tar.gz
NN表示当前所用的版本号。
(2) 解压缩
# gzip -d httpd-2_0_NN.tar.gz
# tar xvf httpd-2_0_NN.tar
(3) 配置.
# ./configure --prefix= /usr/local/apache --enable-so
表示Apache将安装在/usr/local/apache目录下
(4) 编译与安装
# make
# make install
(5) 测试
# /usr/local/apache/bin/apachectl start
碰到的问题:
1、configure failed for srclib/apr
解决:(参看:http://hi.baidu.com/marsjin/item/31721ed4c1e05295260ae783)
在linux cent OS5.3安装apache 运用命令httpd-2.2.11]# ./configure --sysconfdir=/etc --enable-ssl --enable-modules 时出现了
........................
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/httpd-2.2.11/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure failed for srclib/apr
查看了一下原来是错误开始于srclib/apr文件,检查gcc编译器时提示没发现并且在系统环境变量$PATH中没有合适的c编译器,以是使用yum -y install gcc来安装gcc编译器,就可继续安装了.
2、启动apache遇到错误:httpd: Could not reliably determine the server's fully qualified domain name
解决:(参看:http://www.2cto.com/os/201201/117797.html)
[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
1)进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
2)编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
3)再重新启动apache 即可。
[root@server ~]# /usr/local/apache/bin/apachectl restart