linux开机启动脚本

linux开机启动脚本

用户自定义开机程序(/etc/rc.d/rc.local)

操作最简单,方便。每次都自己启动PHP啊,Nginx啊 烦死了,其他方式还要弄shell啊,连接啊,太繁琐。

操作事例如下:

    vim /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#添加执行命令
/usr/local/nginx/sbin/nginx
/usr/local/sbin/php-fpm
/usr/local/mysql/support-files/mysql.server  start

redis启动需要点处理

进入Redis源码包

$ cp /utils/redis_init_script /etc/init.d #/utils/redis_init_script复制到/etc/init.d
$ cp /etc/init.d/redis_6379 #重命名(这样做为以后可能做集群做准备)
$ vi /etc/init.d/redis_6379 #第六行 REDISPORT修改同样端口号
chmod 0777 /etc/init.d/redis_6379
chkconfig redis_6379 on

加入到开机启动 vi /etc/rc.d/rc.local

加入下面行

service redis start

最后重启 reboot,完成所有服务启动。

原文地址:https://www.cnblogs.com/followyou/p/7644299.html