编译安装apache添加开机自启动
2021-01-19 04:19
标签:local 报错信息 解决 开机 emctl init redirect pac daemon [root@linux /]# cat /etc/redhat-release [root@linux ~]# systemctl enable httpd [root@linux ~]# chkconfig --add httpd [root@linux ~]# cd /etc/init.d/ function httpd_start(){ function httpd_stop(){ case $1 in #chkconfig:345 85 15 [root@linux ~]# chmod +x httpd -rwxr-xr-x 1 root root 496 Jul 18 10:12 httpd [root@linux ~]# systemctl daemon-reload #先加载守护进程,否则无法启动服务 [root@linux ~]# chkconfig --add httpd [root@linux ~]# chkconfig --list|grep httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off /usr/local/apachectl 编译安装apache添加开机自启动 标签:local 报错信息 解决 开机 emctl init redirect pac daemon 原文地址:https://blog.51cto.com/1283684/2511576
CentOS Linux release 7.4.1708 (Core)
[root@linux /]# uname -r
3.10.0-693.el7.x86_642、源码编译安装apache服务后,设置开机自启动报错信息
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd on
service httpd does not support chkconfig 3、解决方法或思路
1)编写apache启动脚本
[root@linux init.d]# touch httpd
[root@linux ~]# vim httpd
#!/bin/bash
#chkconfig:345 85 15
#description:Start and stop the Apache HTTP Server
/usr/local/apache/bin/apachectl start
}
/usr/local/apache/bin/apachectl stop
}
start)
httpd_start
;;
stop)
httpd_stop
;;
restart)
httpd_stop
httpd_start
;;
*)
echo "Usage: httpd start|stop|restart!"
;;
esac注意:以下两行内容是服务能够在chkconfig里添加的必要代码
#description:Start and stop the Apache HTTP Server
2)把编写的启动脚本赋予执行权限,(添加到系统服务中)
[root@linux ~]# ll3)重新加载守护进程,启动服务
[root@linux ~]# systemctl start httpd
[root@linux ~]# netstat -lnpt|grep http
tcp6 0 0 :::80 :::* LISTEN 1077/httpd4)设置开机自启动
5)查看开机自启动结果:
6)apache的安装路径:
[root@linux apache]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules