添加开启自动启动 Apache nginx redis 脚本
来源:互联网 发布:乖离数据下载很慢 编辑:程序博客网 时间:2024/05/21 09:46
把以下脚本保存为nginx文件放入/etc/init.d/nginx
然后可以通过
/etc/init.d/nginx start 命令启动nginx
/etc/init.d/nginx stop 命令停止nginx
/etc/init.d/nginx restart 命令重启nginx
开机自动启动nginx,
如果需要开机启动服务,保存好 /etc/init.d/nginx文件后,
执行以下命令:
chkconfig --add nginx
chkconfig --level 2345 nginx on
vim /etc/init.d/nginx
---------------------分割线下是脚本内容,红色字体需要你修改-------------------------------------------
#! /bin/sh
# chkconfig: 35 70 30
# description: nginx
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
vim /etc/init.d/redis
#! /bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/binREDISPORT=6379EXEC=/usr/local/redis/bin/redis-serverREDIS_CLI=/usr/local/redis/bin/redis-cliPIDFILE=/var/run/redis.pidCONF="/usr/local/redis/etc/redis.conf"
AUTH="1234"case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed." else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT -a $AUTH SHUTDOWN sleep 2 while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1esac
- cd /etc/rc.d/
- vi rc.local
- 添加开启自动启动 Apache nginx redis 脚本
- nginx开机自动启动脚本
- nginx开机自动启动脚本
- nginx开机自动启动脚本
- nginx整合php自动启动脚本
- CentOS设置开启自动启动Redis的方法
- apache定时自动启动脚本程序代码-apache-Php教程
- Dubbo之添加到开启自动启动-yellowcong
- nginx设置开启启动
- web自动安装脚本(apache/nginx+php+mysql)
- systemctl开启启动redis
- win redis开启启动
- redis 设置开启启动
- Linux下ssl+apache开机自动启动脚本
- Apache&Nginx开启SSL配置
- apache和nginx开启https
- apache和nginx开启https
- apache和nginx开启https
- iOS 常见 Crash 及解决方案
- HDU 1568
- iTOP-4412开发板Linux系统下使用wifi模块配置
- android学习笔记-事件处理
- HDU ACM 5233 Gunner II
- 添加开启自动启动 Apache nginx redis 脚本
- No JVM installation found
- Android网络编程之四:Socket编程
- 证照速打王注册器使用说明
- 【转】 MATLAB图像增强程序举例
- java替换字符串中符合正则表达式的内容
- 异地多活数据流基础设施DRC --双11支持571亿交易额背后的武器
- QT5.4程序发布
- Spark 1.3.1 部署