美文网首页
linux(centos)下增加httpd为系统服务

linux(centos)下增加httpd为系统服务

作者: rightchen | 来源:发表于2018-04-23 15:41 被阅读0次

新编译安装的apache没有作为系统服务,每次启动关闭都是执行命令:/usr/local/apache/bin/apachectl restart。所以安装一个service服务。

1、查看一下/etc/init.d/下是否存在httpd这个服务

ls /etc/init.d/ | grep httpd 如果没有执行下一步

2、将自己安装目录下的apachectl复制到etc/init.d/目录下并改为httpd

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd(结合你的apache安装目录,检查文件存在再复制)

3、执行 chkconfig --add httpd 目的是想新增所制定的系统服务 但是会出现以下警告:

service httpd does not support chkconfig

这里说的是httpd服务不支持chkconfig , 添加支持: vi /etc/init.d/httpd 在 #!/bin/sh 下添加这两句:

#chkconfig:345 85 15

#description:Start and stop the Apache HTTP Server

保存,退出。

4、执行: chkconfig --add httpd

chkconfig httpd on 就可以添加成功了

5、查看一下是否添加成功:

chkconfig --list httpd

相关文章

网友评论

      本文标题:linux(centos)下增加httpd为系统服务

      本文链接:https://www.haomeiwen.com/subject/uorllftx.html