码迷,mamicode.com
首页 > 其他好文 > 详细

配置nginx为系统服务(centos6.4)

时间:2015-03-02 11:06:48      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

vi /etc/init.d/nginx

 内容添加:

 1  #! /bin/bash
 2 
 3 # chkconfig: 35 85 15  
 4 # description: Nginx is an HTTP(S) server, HTTP(S) reverse
 5 
 6 set -e
 7 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 8 DESC="nginx daemon"
 9 NAME=nginx
10 DAEMON=/usr/local/nginx/$NAME
11 SCRIPTNAME=/etc/init.d/$NAME
12 
13 test -x $DAEMON || exit 0
14 
15 d_start(){
16     $DAEMON || echo -n " already running"
17 }
18 
19 d_stop() {
20     $DAEMON -s quit || echo -n " not running"
21 }
22 
23 d_reload() {
24     $DAEMON -s reload || echo -n " counld not reload"
25 }
26 
27 case "$1" in
28 start)
29     echo -n "Starting $DESC:$NAME"
30     d_start
31     echo "."
32 ;;
33 stop)
34     echo -n "Stopping $DESC:$NAME"
35     d_stop
36     echo "."
37 ;;
38 reload)
39     echo -n "Reloading $DESC configuration..."
40     d_reload
41     echo "reloaded."
42 ;;
43 restart)
44     echo -n "Restarting $DESC: $NAME"
45     d_stop
46     sleep 2
47     d_start
48     echo "."
49 ;;
50 *)
51     echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
52     exit 3
53 ;;
54 esac
55 
56 exit 0

将第10行nginx执行地址修改一下即可

启动nginx:service nginx start

停止nginx:service nginx stop

 

配置nginx为系统服务(centos6.4)

标签:

原文地址:http://www.cnblogs.com/hxy520/p/4308075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!