用service启动nginx
来源:互联网 发布:股市交易软件 编辑:程序博客网 时间:2024/05/20 06:40
其实很简单 按照下面的步骤一步步走就行了 。纯手打 不喜勿喷!
cd /etc/init.d
vim nginx
内容为
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
# Author: licess
# website: http://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
case "$1" in
start)
echo -n "Starting $NAME... "
if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
fi
$NGINX_BIN -c $CONFIGFILE
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Stoping $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi
$NGINX_BIN -s stop
if [ "$?" != 0 ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit 0
fi
;;
force-quit)
echo -n "Terminating $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi
kill `pidof $NAME`
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload)
echo -n "Reload service $NAME... "
if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit 1
fi
;;
configtest)
echo -n "Test $NAME configure files... "
$NGINX_BIN -t
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}"
exit 1
;;
esac
然后修改下权限就好了 chmod +x /etc/init.d/nginx
就可以用service 启动 停止 nginx了
- 用service启动nginx
- nginx 服务启动脚本 chkconfig service
- Linux 添加Nginx 到 service 启动
- nginx 加入contos服务启动 service
- Linux 添加Nginx 到 service 启动
- 如何把apache和nginx 加入到系统服务,用service 命令来控制启动、停止
- nginx设定成service启动(centos 6.8)
- Linux 添加Nginx 到 service 启动 (完整篇)
- lnmp环境后续(nginx添加到service启动)
- nginx.service
- nginx启动失败Failed to reload nginx.service: Unit not found.
- 启动Service
- nginx启动
- nginx 启动
- nginx 启动
- nginx启动
- nginx启动
- 启动service的时候用nohup
- c++primer plus 第六版第四章编程习题
- 深入浅出 JIT 编译器
- 静态类,抽象类,接口
- su root 与 su - root 的区别
- 用split()根据选项卡在url后面添加锚值
- 用service启动nginx
- 配置根据时间自动配置build
- java kettle 初步
- 文档解析之XML文档读取
- caffe增加自己的layer实战(中)--caffe学习(11)
- Linux平台的SVN服务器的配置及搭建
- LeetCode 1 Two Sum
- Android 系列 5.1使用自定义字体
- window.history