安装apache for linux server

来源:互联网 发布:旅游市场需求状况数据 编辑:程序博客网 时间:2024/04/27 16:32

1. 下载 http://httpd.apache.org/download.cgi

本人下载的是 httpd-2.4.6.tar.gz 

2. 进入目标文件所在目录,解压压缩包

tar -zxvfhttpd-2.4.6.tar.gz

3. cd httpd-2.2.6     //定位到httpd-2.2.6 文件夹下

4. ./configure --help | more    //查看安装apache配置参数

5. ./configure --prefix=/usr/local/apache --enable-so    //  配置apache路径,命令so模块是用来提DSO支持的apache核心模块,这里设置启动

//安装到此时遇到的问题可参考最后的解答,根据提示安装完成之后apache就已安装完成

// 第8步之后的可根据选择安装

6. make     //编译apache

7. make install    //安装apache

8. cd /usr/local/apache   //进入apache的目录

9. cd conf/

10. cp -a httpd.conf httpd.conf-     //备份apache配置文件

11. chkconfig  --list httpd     //查看httpd服务是否已存在

12. hkconfig httpd off    //关闭系统自带了httpd的服务,如果存在httpd服务   

13. service httpd status    //查看自带httpd服务状态

14. /usr/local/apache/bin/apachectl -k start    //linux启动apache命令

15. netstat -an | grep :80    //查看linux80端口是否开启

16. ps -aux | grep httpd     //linux下查看apache进程

17. cd ../../ (local folder)

18. cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache //拷贝apache启动脚本

19. i /etc/rc.d/init.d/apache    // 这里是编辑apache启动脚本

在开头的#!/bin/sh  下面加上
    #chkconfig: 2345  85  15 //2345表示2345四个启动级别里面加载这个服务,85表示启动(开机时)顺序号,15表示关闭(关机时)顺序号

20. chkconfig --add apache    //添加apache服务

21. chkconfig --list apache    //列出apache服务

22. service apache stop    //停止apache服务

23. etstat -an | grep :80     //查看linux的80端口是否关闭

24. ps -aux | grep httpd     //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败

25. service apache start    //启动apache服务

26. 打开你的服务器ip地址,看看是否出现了tomcat的默认首页,如果出现的话,那么恭喜你
linux下安装apache已经成功了

27. 至此Apache的安装工作完成,可以在每次启动系统时通过如下命令启动或重新启动Apache服务:

/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl restart

问题:

安装apache提示APR not found:

原因是:APR是Apache的关联软件在,apr.apache.org网站上可以下载此软件(apr-1.4.5.tar.gz);编译之后需要再下载apr-util-0.9.19.tar.bz2进行编译安装,请注意安装版本:APR version 1.3.0 or later is required.(本人是根据pcre -> aprl -> apr-util 顺序来安装的

1. 安装APR: http://apr.apache.org/download.cgi 

1.1.   tar -zxvf apr-1.4.5.tar.gz

1.2. ./configure --prefix=/usr/local/apr

1.3. make

1.4. make install

2. 安装APR-util:http://apr.apache.org/download.cgi

2.1. tar -zxvf apr-util-1.3.12.tar.gz

2.2. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

2.3. make

2.4. make install

3.

./configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

#./configure –help | grep pcre

--with-pcre=PATH        Use external PCRE library

下载:http://sourceforge.net/projects/pcre

#unzip -o pcre-8.10.zip

#cd pcre-8.10

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

#make

#make install

4.编译Apache

 ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

 make
 make install

 cd /usr/local/apache2/bin

./apachectl start

http://blog.sina.com.cn/s/blog_6122363d01015fao.html [将源码包编译的服务加入系统服务使用service控制启动关闭]

http://zhidao.zgsj.com/article/12/2012620170547.shtml [服务httpd不支持chkconfig]

原创粉丝点击