首页 技术 正文
技术 2022年11月12日
0 收藏 361 点赞 2,815 浏览 1082 个字

Apache安装后可通过其安装路径的bin目录下的apachectl脚本控制服务的启动和停止。本例中apache安装在/usr/local/apache-2.2.6,服务控制脚本为:

/usr/local/apache-2.2.6/bin/apachectl

执行下面的命令启动Apache服务:

/usr/local/apache-2.2.6/bin/apachectl start

执行下面的命令停止Apache服务:

/usr/local/apache-2.2.6/bin/apachectl stop

可以简单地把Apache启动命令加到/etc/rc.local文件,让Apache随系统启动而自动启动:

echo”/usr/local/apache-2.2.6/bin/apachectl start” >> /etc/rc.local

下面介绍如何把Apache加入到系统服务,用service命令来控制Apache的启动和停止。

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

grep -v “#”/usr/local/apache-2.2.6/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 Webserver.

保存后退出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

  执行下面的命令改变开机自启动的运行级别为3、5:

chkconfig –level 35 apache on

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,905
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,430
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,247
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,058
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,690
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,727