1.首先下载httpd-2.2.27.tar.gz
用linux命令下载wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.2.27.tar.gz
2.下载完成之后要解压httpd-2.2.27.tar.gz(linux文件后缀带gz的都要gzip解压下)
gzip -d httpd-2.2.27.tar.gz
3.gzip -d之后文件名会变成httpd-2.2.27.tar没有了.gz了,再用tar解压
tar xvf httpd-2.2.27.tar
4.执行第三步之后会解压出来一个httpd-2.2.27目录,cd进入httpd-2.2.27目录
cd httpd-2.2.27
5.进入httpd-2.2.27之后设置安装目录(/home/web/apache/是安装目录)
./configure --prefix=/home/web/apache/
6.配置好安装目录之后就开始编译(linux编译就用make就行)
make
7.编译完之后,执行安装命令(make install)
make install
8.修改配置文件(一定要修改不然启动不的)
vi /home/web/apache/conf/httpd.conf
打开httpd.conf之后查找Listen这行
改成Listen 80
注:80端口要是被占用了就启动不了的,如果被占用可以改成7160之类的
再查找ServerName
改成ServerName localhost:80就修改这2个地方就完成了,可以启动了
9.启动apache(如果有问题请用root重启)
/home/web/apache//bin/apachectl -k start
10.用ps查看apache是否启动成功
ps -ef | grep httpd
结果如下就是成功了
[root@localhost web]# ps -ef | grep httpd root 13972 1 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startdaemon 13973 13972 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startdaemon 13974 13972 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startdaemon 13975 13972 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startdaemon 13976 13972 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startdaemon 13977 13972 0 16:19 ? 00:00:00 /home/web/apache//bin/httpd -k startroot 13979 16929 0 16:19 pts/1 00:00:00 grep httpd
11.说一下停止apache的命令
/home/web/apache/bin/apachectl -k stop