centos 中开机自启
centos 中开机自启
centos 中开机自启

systemctl 设置开机启动

1
2
3
yum install nginx     # 安装nginx 做开机启动测试
systemctl enable nginx.service # 设为开机启动
systemctl disable nginx.service # 停止开机启动

修改 rc.local 设置为开机启动

1
2
3
4
5
6
7
8
9
10
11
12
### /etc/rc.local 和 /etc/rc.d/rc.local 修改那个都行,我这里修改 /etc/rc.d/rc.local
[root@localhost vagrant]# locate rc.local
/etc/rc.local
/etc/rc.d/rc.local
[root@localhost vagrant]#

在 /etc/rc.d 目录下,修改 rc.local ,添加执行命令,比如 mkdir /fei_03
创建一个名字叫 fei_03 的目录; 然后 chmod +x /etc/rc.d/rc.local

##### ---- 温馨提示,请注意 rc.local 文件里面有个提示如下,
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

开机启动