开发者社区 问答 正文

云服务器 ECS Linux 编译安装 Apache 添加 chkconfig 配置自启动的方法是什么



问题描述



如何实现编译安装的 Apache 服务,随系统自动启动

解决方案



假设 Apache 安装的路径为 /usr/local/apache/
注意:实际安装路径以您真实的安装路径为准
1、首选需要将 /usr/local/apache/bin/apachectl 文件拷贝到 /etc/rc.d/init.d 目录中并更名为 httpd,具体操作命令为: cp /usr/local/apache/bin/apachectl  /etc/rc.d/init.d/httpd
并且还需要在/etc/rc.d/rc5.d/加入链接,具体操作命令为: ln -s /etc/rc.d/init.d/httpd  /etc/rc.d/rc5.d/S85httpd

2、这时可以运行 chkconfig --list | grep httpd,查看服务列表中是否存在 httpd 这个服务;如果没有,可以通过 chkconfig --add httpd 来添加。如果在添加时出现提示:service httpd does not support chkconfig

需要编辑 /etc/rc.d/init.d/httpd,在文件空白行添加以下信息,可以使用vi进行编辑操作
#chkconfig: 345 85 15#description: Activates/Deactivates Apache Web Server
其中3个数字参数意义分别为:
哪些Linux级别需要启动httpd(3,4,5);启动序号(85);关闭序号(15)
保存后执行:chkconfig --add httpd 成功添加

3、运行 chkconfig --list | grep httpd 查看启动级别3,4,5 已经处于on的状态,说明已经设置成功。


如果问题还未能解决,您可以到阿里云社区进行 免费咨询,或联系云市场商家 寻求帮助

展开
收起
boxti 2017-10-23 10:39:41 1858 分享 版权
0 条回答
写回答
取消 提交回答