[root@localhost ~]# vi /etc/init.d/nginx
#!/bin/bash
# chkconfig: 345 99 20
# description: Nginx servicecontrol script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
echo "Nginx servicestart success."
;;
stop)
kill -s QUIT $(cat $PIDF)
echo "Nginx service stopsuccess."
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
echo"reload Nginx configsuccess."
;;
*)
echo "Usage: $0{start|stop|restart|reload}"
exit 1
esac
[root@localhost ~]# chmod +x/etc/init.d/nginx
[root@localhost ~]# service nginx restart
[root@localhost ~]# chkconfig --add nginx
[root@localhost ~]# chkconfig nginx on
Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里
推荐阅读:
Nginx做负载均衡报:nginx: [emerg] could not build the types_hash
Nginx 负载均衡模块 ngx_http_upstream_module 详述
Nginx+Firebug 让浏览器告诉你负载均衡将请求分到了哪台服务器
Ubuntu安装Nginx php5-fpm MySQL(LNMP环境搭建)