Linux安装配置apache

1.获取软件: http://httpd.apache.org/  httpd-2.2.21.tar.gz

2.安装步骤:

解压源文件:

运行./configure 命令进行编译源代码,

–prefix=/usr/local/apach2 是设置编译安装到的系统目录,

 –enable-s  参数是使httpd服务能够动态加载模块功能,

–enable-rewrite  是使httpd服务具有 页地址重写功能。

3.启动apache:

/usr/local/apache2/bin/apachectl start

4.将apache加入到系统服务,用service命令来控制apache的启动和停止

  •  首先以apachectl脚本为模板生成Apache服务控制脚本:

  grep -v “#” /usr/local/apache2/bin/apachectl  > /etc/init.d/apache

  vi /etc/init.d/apache

  • 在文件最前面插入下面的行,使其支持chkconfig命令:

  #!/bin/sh              

  # chkconfig: 2345 85 15              

  # description: Apache is a World Wide Web server.

  chmod  +x  /etc/init.d/apache

  • 执行下面的命令将Apache服务加入到系统服务:    

  chkconfig –add apache

  • 执行下面的命令检查Apache服务是否已经生效:    

  chkconfig –list apache              

  • 命令输出类似下面的结果:              

  apache          0:off 1:off 2:on 3:on 4:on 5:on 6:off       

  表明apache服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制Apache的启动和停止。  

  • 启动Apache服务:   service apache start   
  • 停止Apache服务:        service apache stop   
  • 执行下面的命令关闭开机自启动:      chkconfig apache off

文章知识点与官方知识档案匹配,可进一步学习相关知识CS入门技能树Linux入门在线安装软件24909 人正在系统学习中

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2013年1月14日
下一篇 2013年1月15日

相关推荐