Ubuntu下Apache的安装

Ubuntu下可快速安装LAMP server(Apache+MySQL+PHP5),参见《Ubuntu下快速安装LAMP server》一文。

也可以手动安装Apache。本文介绍如何手动安装Apache。安装过程中会遇到很多问题,比如“configure: error: APR not found . Please read the documentation”,所以请按照下面的步骤进行安装。

首先,打开Ubuntu虚拟机,Terminal打开root权限:“sudo -s”。

一、安装apr 1.4.5

  (1)下载

  #wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz

  (2)解压

  #tar -zxf(或tar -xzvf) apr-1.4.5.tar.gz

  (3)配置configure文件

  #cd apr-1.4.5
  #./configure --prefix=/usr/local/apr

  (4)编译安装

  #make && make install

二、安装apr-util 1.3.12

  (1)下载

  #wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz  

  (2)解压

  #tar -zxf(或tar -xzvf) apr-util-1.3.12.tar.gz 

  (3)配置configure文件

  #cd apr-util-1.3.12
  #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config 

  (4)编译安装

  #make && make install

三、安装pcre 8.10

  (1)下载

  #wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip   

  (2)解压

  #unzip -o(或tar -xzvf) pcre-8.10.zip 

  (3)配置configure文件

  #cd pcre-8.10
  #./configure --prefix=/usr/local/pcre

  (4)编译安装

  #make && make install

四、重新安装apache 2.4.17

  (1)下载

  链接:http://httpd.apache.org/  资源:httpd-2.4.17.tar.gz

  (2)解压

  #tar -zxf(或tar -xzvf) httpd-2.4.17.tar.gz

  (3)配置configure文件

  #cd httpd-2.4.17
  #./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-so --enable-rewrite

  (4)编译安装

  #make && make install

五、去除警告

  (1)修改原因

  启动Apache时,会有警告“AH00558:httpd:could not reliably determine the service's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to    suppres this message.”

  (2)修改方法

  /usr/local/apache/conf/httpd.conf文件第188行

  把"ServerName www.example.com:80"改为"ServerName localhost:80"

六、设为开机启动

  /etc/rc.local文件中添加一行代码

  “#/usr/local/apache/bin/apachectl start”

七、启动和检测是否安装成功

  (1)启动Apache

  #/usr/local/apache/bin/apachectl start

  (2)检测是否安装成功

  打开浏览器,URL为“localhost:80”

  启动成功的页面会显示“It works!”

*八、若同时也使用LAMP安装了Apache的话,可能会有影响

  "(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80"

  (1)查看是谁占用我的80端口

  #netstat -lnp |grep 80

  (2)杀死占用80的apache2服务

  #pkill -9 apache2

  (3)重新启动apache服务

  #/usr/local/apache/bin/apachectl start

 

posted @ 2015-12-02 15:00  懒懒的小猪  阅读(828)  评论(0编辑  收藏  举报