linux之写nginx的启动脚本
本文简单介绍了,linux写nginx的启动脚本,基本属于傻瓜式操作,很简单,几行代码,复制黏贴即可!
例如:home目录
[root@localhost home]# mkdir shell
[root@localhost shell]# vi http.sh
精简版
#!/bin/bash
#include functions
# chkconfig:- 50 60
. /etc/init.d/functions
exec=/usr/local/nginx/sbin/nginx
prog=nginx
function start(){
pidofproc $exec
[ $? = 0 ] && echo " It s already started $prog " && exit
daemon $exec
[ $? = 0 ] && echo " Start successful $prog "
}
function stop(){
pidofproc $exec
[ $? != 0 ] && echo " Not running $prog" && exit
killproc $exec
[ $? = 0 ] && echo " stop $prog "
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
;;
esac
启动nginx脚本
[root@localhost shell]# ./http.sh start
停止nginx脚本
[root@localhost shell]# ./http.sh stop
重启nginx脚本
[root@localhost shell]# ./http.sh restart
查看端口
[root@localhost shell]# netstat -ntlp