ubuntu14下nginx自启动脚步编写
来源:互联网 发布:不用网络的游戏大全 编辑:程序博客网 时间:2024/06/05 00:56
手动安装安装完nginx,如果需要下次开机自动启动还需要写一个简单脚步,以下为具体步骤(默认root用户操作,非root用户 部分指令禁止操作)
在 /etc/init.d/目录下新建一个nginx脚本文件
执行指令 vi /etc/init.d/nginx 写好脚本后,:wq保存退出
给文件增加可执行权限 chmod +x nginx
切换到 /etc/init.d/下
执行 ./nginx start
执行 ps -ef|grep nginx 查看进程是否存在,显示以为内容说明启动成功
root 1502 1 0 14:06 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 1503 1502 0 14:06 ? 00:00:00 nginx: worker process
重启系统后 nginx将自动启动
以下为nginx脚步内容 脚本头部的变量可能因系统的不同需要修改
#! /bin/sh
PATH=/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/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() {
if [ -f "$PIDFILE" ]; then
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
fi
}
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
阅读全文
0 0
- ubuntu14下nginx自启动脚步编写
- Ubuntu14.04配置nginx开机自启动项
- Ubuntu14.04配置nginx开机自启动项
- ubuntu下设置Nginx自启动
- ubuntu 下 nginx 自启动设置
- Linux下nginx的自启动脚本
- centos6.x下nginx自启动脚本
- win10 下nginx开机自启动
- linux 下nginx 开启自启动
- 用lazarus开发Linux daemon程序及编写启动脚步
- 开机自启动nginx
- nginx自启动脚本
- nginx没有自启动
- nginx自启动脚本
- 开机自启动nginx
- nginx开机自启动
- nginx 自启动
- 编写自启动脚本
- SQL Server索引的维护
- Java反射机制总结
- UIFactory打开新页面,传递参数
- 文件类型
- pointer_7
- ubuntu14下nginx自启动脚步编写
- 【总结】:summary
- FTP和相关http、smtp 错误代码失败对照 550 什么的整理
- 高性能mysql读书笔记(一)
- 渲染web视图
- C语言求1000以内完数
- 戴尔服务器命名规则
- 使用 PHP 把 16 进制的颜色代码转换成 RGB 数组
- 微信公众号开发之图片,音乐等文件出现该公众号无法提供服务的问题