日期:2014-05-16  浏览次数:20961 次

Apache的提取、编译与安装

?

在linux下的软件的安装并不看windows下那么简单,要经过一系列的指令才能完成安装。

?

Ubuntu的默认下载路径是/root/Downloads,要通过命令的方式先进入这个路径,找到apache的压缩文件才能进行安装工作。以下是按顺序的相关linux命令:

?

cd /root/Downloads

?

tar xzf httpd-2.2.22.tar.gz? //提取后会生成httpd-2.2.22文件夹

?

cd httpd-2.2.22? //进入httpd-2.2.22文件夹

?

./configure --prefix=/usr/local/apache --enable-so --enable-proxy --enable-proxy-http --enable-proxy-balancer --enable-modules=all --enable-mods-shared=all?? //指定安装路径为/usr/local/apache,后面的参数为要编译加载入内核的模块

?

make??

?

make install? //安装

?

三、检查是否成功安装

?

cd /usr/local/apache/modules

?

四、启动

shell>cd /usr/local/apache
shell>bin/apachectl start 启动web服务
shell>bin/apachectl stop 停止web服务
shell>cp bin/apachectl /etc/init.d/httpd
shell>/etc/init.d/httpd restart

apache设为linux服务

?

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd

?

在在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.

?

然后
chmod x /etc/rc.d/init.d/httpd
chkconfig --add httpd
?
注:在启动时报httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName此异常
进入apache的安装目录:
linux : /usr/local/apache/conf?????? 打开httpd.conf
将里面的#ServerName localhost:80注释去掉即可。
再执行httpd
然后可以通过浏览器访问http://localhost:80,如果页面显示“It works!”,即表示apache已安装并启动成功。
如果提示using localhost.localdomain for ServerName? 说不能确认服务器完全确认域名 localhost.localdoman?
那么修改此文件:
vi /etc/httpd/conf/httpd.conf ? 加入一句? ServerName? localhost:80