您的位置:首页 > 运维架构 > Apache

L​i​n​u​x​注​册​a​p​a​c​h​e服务开机启动

2014-04-18 10:57 561 查看
将apache添加为开机启动有两个方法:

1、在/etc/rc.d/rc.local内加入启动命令

/usr/local/apache2/bin/apachectl start
2、将http添加为系统服务 

cp /usr/local/apache2/bin/apachectl  /etc/rc.d/init.d/httpd

chmod +x  /etc/rc.d/init.d/httpd

[root@localhost ~]# chkconfig --add httpd
[root@localhost ~]# chkconfig --list|grep httpd

httpd           0:关闭 1:关闭  2:关闭 3:关闭  4:关闭  5:关闭  6:关闭

[root@localhost ~]# chkconfig --level 345 httpd on
[root@localhost ~]# chkconfig --list|grep httpd

httpd           0:关闭  1:关闭 2:关闭 3:启用 4:启用 5:启用  6:关闭

如果出现

root@localhost ~]# chkconfig --add httpd
httpd 服务不支持 chkconfig

解决过程如下:

编辑/etc/rc.d/init.d/httpd

#chkconfig:345 61 61   //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
#description:Apache httpd   //此行必写,描述服务.
添加上面2行就可以了。
[root@localhost ~]# chkconfig --add httpd
[root@localhost ~]# chkconfig --list|grep httpd

httpd           0:关闭 1:关闭  2:关闭 3:关闭  4:关闭  5:关闭  6:关闭
[root@localhost ~]# chkconfig --level 345 httpd on
[root@localhost ~]# chkconfig --list|grep httpd

httpd           0:关闭  1:关闭 2:关闭 3:启用 4:启用 5:启用  6:关闭
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息