通过编译安装的apache无法直接使用service和systemctl来控制开关的。需要用chkconfig来加载为服务才可以。
用cp /opt/httpd/bin/apachectl /etc/rc.d/init.d/httpd #将apachectl复制一份到init.d
vim /etc/rc.d/init.d/httpd
加上chkconfig的配置:
#!/bin/sh
#chkconfig: 2345 20 80
#description: Apache web server
#
主要是chkconfig: 2345 20 80
2345是运行等级 20是启动优先级 80是关闭优先级,优先级越大就延迟动作
运行#runlevel 可以查看当前的运行等级
The following runlevels are defined by default under Red Hat Enterprise Linux:
0
— Halt
1
— Single-user text mode
2
— Not used (user-definable)
3
— Full multi-user text mode
4
— Not used (user-definable)
5
— Full multi-user graphical mode (with an X-based login screen)
6
— Reboot