我们这里以新建nginx为例子:
1.进入/etc/init.d目录下
touch nginx
vim nginx
将一下代码考入,将XXXX修改为你nginx的安装目录
chkconfig: - 85 15
description: nginx is a World Wide Web server. It is used to serve
stop(){
XXXX/sbin/nginx -s stop && echo "nginx stoped"
}
restart(){
XXXX/sbin/nginx -s reload && echo "nginx restarted"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
执行
esc
:wq
将nginx的文件的权限给相应的用户
chmod 777 nginx
然后就可以用service nginx restart来启动,停止和重启nginx了
打赏地址:http://blog.youkuaiyun.com/assassinsshadow/article/details/76086401