Ubuntu12.04下安装Apache

提示:本教程使用的是Apache编译安装的方式,相对而言较困难,对于初学者,建议直接使用ubuntu的安装包管理工具apt-get命令安装:

sudo apt-get install apache2

在安装Apache之前,必须要安装它所依赖的类库,如下步骤本人亲测,注意下载上面提到的包时需解压,下面的命令都是在进入解压后的目录下执行的。

1.安装libtool

http://www.gnu.org/software/libtool/下载libtool

./configure
make
sudo make install

2.安装expat

http://sourceforge.net/projects/expat/下载expat,XML Parser

./configure
make
sudo make install

3.安装pcre

http://pcre.org/下载pcre(Perl Compatible Regular Expressions)依赖库

./configure --prefix=/usr/local/pcre
make
sudo make install

这里的--prefix表示设置安装目录.

4.安装APR(Apache Portable Runtime)

http://apr.apache.org/download.cgi处下载APR 1.4.6与APR-util 1.5.2

4.1安装APR

./configure --prefix=/usr/local/apr
make
sudo make install

4.2安装APR-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
sudo make install

5.安装Apache

从Apache的官网http://httpd.apache.org/下载最近的Apache服务器包,我下载的是最新的httpd-2.4.4.tar.gz,2.4.4版。

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
sudo make install

6.检证安装

检查配置是否正常,输入如下命令:

cd /usr/local/apache2/bin

进入apache的bin目录,执行命令:

sudo ./apachectl configtest

测试配置信息是否正确,这时会出现一个错误:httpd: Could not reliably determine the server's fully qualified domain name:

解决办法,输入如下命令:

sudo gedit ../conf/httpd.conf

打开gedit编辑器,修改httpd.conf文件,将里面的大概187行#ServerName www.example.com:80 注释去掉并改为ServerName localhost:80即可,参考: http://www.cnblogs.com/52linux/archive/2012/03/24/2415637.html

再次运行:sudo ./apachectl configtest,提示:Syntax OK

启动服务:

sudo ./apachectl start

对应停止命令为stop, 重启为restart

运行start命令后,在浏览器中输入http://localhost,出现如下页面就说明Apache安装成功:

这里运行的页面为<apach安装目录>/htdocs目录下的index.html文件,从这可知,htdocs为Apache默认的web根目录。

附:参考网址:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值