linux源码下载阿帕奇,Ubuntu 12.04下源码安装Apache

环境:Ubuntu 12.04

【简单安装】

一般第一次安装Apache都较为顺利。

1. 下载并解压

root@ubuntu:/home/qy/share#tar zxvf httpd-2.2.22.tar.gz

root@ubuntu:/home/qy/share#cd httpd-2.2.22

在http-2.2.22里有文件README和INSTALL,用more命令可以阅读。

2. 配置

root@ubuntu:/home/qy/share/httpd-2.2.22#./configure --prefix=/usr/local/apache

--prefix参数指定了将要安装到的目录。此时/usr/local下还没有该目录,make install后才会出现。

注意:Apache在安装时不会检查参数是否正确,错误的参数会直接被丢弃,不会报告给用户。所以使用echo $?命令检查是否有错误,当输出结果为0时表示没有错误。

3. 编译

root@ubuntu:/home/qy/share/httpd-2.2.22#make

4. 安装

root@ubuntu:/home/qy/share/httpd-2.2.22#make install

5. 启动服务器

root@ubuntu:/home/qy/share/httpd-2.2.22#cd /usr/local/apache/bin

root@ubuntu:/usr/local/apache/bin#./apachectl start

为了以后使用方便,可以把启动文件apachectl复制到/sbin下,以后直接apachectl start启动。

#vi /etc/rc.local

增加一行 /sbin/apachectl start

6. 验证Apache是否工作

此时,服务器端窗口应该显示:

7beeb4331bf2827d15107d5558275862.png

#ps -e|grep httpd

52fd7426eb1e1448fcbef27b7fe5f9ea.png

在客户端浏览器输入服务器的IP地址(或者http://localhost),IE应该显示:It works!画面。

Ubuntu重启后,需要重启Apache: apachectl start

停止服务器:  ./apachectl stop

重启服务器:  ./apachectl graceful  或   ./apachectl restarted

通常,第一次安装Apache没有什么问题,但以后安装,如果没有apr,apr-util,pcre,在执行./configure的配置过程中可能遇到的错误:

make[2]: *** [install] Error 1

make[2]: Leaving directory `/tmp/httpd-2.2.22/srclib/apr-util'

make[1]: *** [install-recursive] Error 1

make[1]: Leaving directory `/tmp/httpd-2.2.22/srclib'

make: *** [install-recursive] Error 1

Apache2.0.x与Apache2.2.x在apr上有本质的区别,前者为依赖公用apr,后者依赖于自身的apr。2.0.x的编译基本上没有apr方面的问题,除非,在编译前,安装了非2.0.x所需的apr,如果是这样,则需要将已经安装的apr去除,然后再编译。HTTP Sever2.2.22修复了不少重要安全问题,包含APR(Apache Portable Runtime)1.4.5和APR-util(Apache Utility Library)1.4.2。因此不需要像网上其它教程那样从外部找源码安装apr和apr-util。将安装前已存在于系统中的apr去除后,再编译apache2.2.x自身srclib里的apr和apr-util。其它操作系统这样解决就没问题了,但是Ubuntu不太一样。安装完apr和apr-util后,./configure配置Apache时可能会出现下面错误:

configure: error: Cannot use an external APR with the bundled APR-util

configure: error: APR version 1.2.0 or later is required

srclib目录中有apr,apr-util,pcre三个源码包,其中pcre是不可用的,编译不出来,有如下错误:

libtool: compile: unrecognized option `-DHAVE_CONFIG_H'

libtool: compile: Try `libtool --help' for more information.

make: *** [pcrecpp.lo] Error 1

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/上下载的pcre-8.30也不可用。不妨用make check命令查看下错误出在什么地方。一般怀疑是g++版本低,更新即可。我没有这样做,而是直接用apt-get install libpcre3-dev安装了pcre后,再安装apache就没问题了。0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值