一、软件环境
1、系统:Ubuntu11.04
2、Apache:httpd-2.4.6.tar.bz2
3、依赖包:
apr-1.4.8.tar.bz2、apr-util-1.5.2.tar.bz2(下载地址:http://apr.apache.org/download.cgi)
pcre-8.12.tar.bz2(下载地址:http://www.pcre.org)
假设所需软件包放于:/work/tools/
二、安装过程
1、安装apr
#cd/work/tools/
#tar -jxvf apr-1.4.8.tar.bz2
#cdapr-1.4.8
#./configure
#make
#make install
2、安装apr-util
#cd/work/tools/
#tar -jxvf apr-util-1.5.2.tar.bz2
#cdapr-util-1.5.2
#./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr
#make
#make install
3、安装pcre
#cd/work/tools/
#tar -jxvf pcre-8.30.tar.bz2
#cdpcre-8.30
#./configure --prefix=/usr/local/pcre
#make
#makeinstall
4、安装apache
#cd/work/tools/
#tar -jxvf httpd-2.4.6.tar.bz2
#cdhttpd-2.4.6
#./configure –prefix=/work/apache/--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr-util/bin/apu-1-config--with-pcre=/usr/local/pcre/bin/pcre-config
#make
#make install
可以用./configure–help | grep apr 查看帮助。
--with-included-apr Use bundled copies of APR/APR-Util
--with-apr=PATH prefix for installed APR or the full path toapr-config
--with-apr-util=PATH prefix forinstalled APU or the full path to
5.几条命令
chkconfig --list httpd //查看httpd服务是否已存在
chkconfighttpd off //关闭系统自带了httpd的服务,如果存在httpd服务
/work/apache/bin/apachectl-k start //linux启动apache命令
netstat-an | grep :80 //查看linux80端口是否开启
ps-aux | grep httpd //linux下查看apache进程
chkconfig--add apache //添加apache服务
chkconfig--list apache //列出apache服务
netstat-an | grep :80 //查看linux的80端口是否关闭
ps-aux | grephttpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败
三、运行
1、进入/usr/local/apache/conf,将httpd.conf中:
#ServerNamewww.example.com:80
改为: ServerNamelocalhost:80
2、进入/work/apache/bin,执行#./apachectlstart
3、在浏览器输入http://127.0.0.1 地址即可访问。