代码改变世界

Linux下安装APache

2014-08-06 14:02  合翅  阅读(166)  评论(0编辑  收藏  举报

1:在图形界面下下载apache 安装包,我下的是 httpd-2.2.9.tar.gz 源码安装包,地址是http://httpd.apache.org/download.cgi 
2:用:gzip -d httpd-2.2.9.tar.gz 
           tar xvf httpd-2.2.9.tar
     解压安装包,之后会出现 httpd-2.2.9 的文件夹,进入该文件夹。
3:在httpd-2.2.9文件夹下可以看到configure 的文件夹,此时用:sudo ./configure --prefix=/usr/local/apache --enable-so 设置安装 目录和参数设置。 命令so模块是用来提DSO支持的apache核心模块,这里设置启动。

4:用make 和make install 编译安装apache :sudo make
5:/usr/local/apache/bin/apachectl start ,该命令用来启用apache。

 

若执行第四步的时候提示错误:httpd: Could not reliably determine the server's fully qualified domain name

解决方案:

进入apache的安装目录:

linux : /usr/local/apache/conf

sudo  gedit httpd.conf

将里面的#ServerName localhost:80注释去掉

再执行httpd

然后可以通过浏览器访问http://localhost:80,如果页面显示“It works!”,即表示apache已安装并启动成功。