首页 > Web开发 > 详细

Linux中将Apache加入到系统服务

时间:2015-11-05 15:26:19      阅读:262      评论:0      收藏:0      [点我收藏+]
  •  首先以apachectl脚本为模板生成Apache服务控制脚本:

  grep -v "#" /user/local/apache/bin/apachectl  > /etc/init.d/apache

  • 用vi编辑Apache服务控制脚本/etc/init.d/apache:

  vi /etc/init.d/apache

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

  #!/bin/sh              

  # chkconfig: 2345 85 15              

  # description: Apache is a World Wide Web server.

  • 保存后退出vi编辑器,执行下面的命令增加Apache服务控制脚本执行权限:    

  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

同理,为mysql添加开机自启动:chkconfig mysqld on

Linux中将Apache加入到系统服务

原文:http://my.oschina.net/smilelxb/blog/526462

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!