365bet网上娱乐:nginx1.10.3起动脚本

CentOS下Nginx 设置开机 自运营 代码 脚本 命令

一、新建文本文件

vi /etc/init.d/nginx

二、添加

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.1.12.0 version.
# chkconfig: – 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it’s not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
#modify
nginxd=/data/nginx/sbin/nginx
nginx_config=/data/nginx/conf/nginx.conf
nginx_pid=/data/nginx/nginx.pid
#modify
RETVAL=0
prog=”nginx”
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = “no” ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo “nginx already running….”
exit 1
fi
echo -n $”Starting $prog: “
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $”Stopping $prog: “
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $”Reloading $prog: “
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case “$1” in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog

RETVAL=$?
;;
*)
echo $”Usage: $prog {start|stop|restart|reload|status|help}”
exit 1
esac

exit $RETVAL

三、修改路线

修改#modify节点的途径(已经标红)

四、授权

chmod 755 /etc/init.d/nginx

就足以service nginx start stop 等一声令下了

设置开机 自运营 代码 脚本 命令
一、新建文本文件 vi /etc/init.d/nginx 二、增加 #!/bin/bash # nginx
Startup script for the Nginx HTTP Server #…

fi

把Nginx插手种类服务 service nginx (start | stop | restart | reload),nginxreload

vim /etc/init.d/nginx

 1 #!/bin/bash
  2 # nginx Startup script for the Nginx HTTP Server
  3 # it is v.0.0.2 version.
  4 # chkconfig: 2345 30 30
  5 # description: Nginx is a high-performance web and proxy server.
  6 #              It has a lot of features, but it’s not for
everyone.
  7 # processname: nginx
  8 # pidfile: /usr/local/nginx/logs/nginx.pid
  9 # config: /usr/local/nginx/conf/nginx.conf
 10
 11 #nginx程序路线
 12 nginxd=/usr/local/nginx/sbin/nginx
 13
 14 #nginx配置文件路线
 15 nginx_config=/usr/local/nginx/conf/nginx.conf
 16
 17 #nginx pid文件的门径,能够在nginx的计划文件中找到
 18 nginx_pid=/usr/local/nginx/logs/nginx.pid
 19 RETVAL=0
 20 prog=”nginx”
 21 # Source function library.
 22 . /etc/rc.d/init.d/functions
 23 # Source networking configuration.
 24 . /etc/sysconfig/network
 25 # Check that networking is up.
 26 [ ${NETWORKING} = “no” ] && exit 0
 27 [ -x $nginxd ] || exit 0
 28 # Start nginx daemons functions.
 29 start() {
 30 if [ -e $nginx_pid ];then
 31    echo “nginx already running….”
 32    exit 1
 33 fi
 34    echo -n $”Starting $prog: “
 35    daemon $nginxd -c ${nginx_config}
 36    RETVAL=$?
 37    echo
 38    [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
 39    return $RETVAL
 40 }
 41 # Stop nginx daemons functions.
 42 stop() {
 43         echo -n $”Stopping $prog: “
 44         killproc $nginxd
 45         RETVAL=$?
 46         echo
 47         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx
/usr/local/nginx/logs/nginx.pid
 48 }
 49 # reload nginx service functions.
 50 reload() {
 51     echo -n $”Reloading $prog: “
 52     #kill -HUP `cat ${nginx_pid}`
 53     killproc $nginxd -HUP
 54     RETVAL=$?
 55     echo
 56 }
 57 # See how we were called.
 58 case “$1” in
 59 start)
 60         start
 61         ;;
 62 stop)
 63         stop
 64         ;;
 65 reload)
 66         reload
 67         ;;
 68 restart)
 69         stop
 70         start
 71         ;;
 72 status)
 73         status $prog
 74         RETVAL=$?
 75         ;;
 76 *)
 77         echo $”Usage: $prog
{start|stop|restart|reload|status|help}”
 78         exit 1
 79 esac
 80 exit $RETVAL

chkconfig –add nginx

chkconfig nginx on

 

service nginx (start | stop |
restart | reload),nginxreload vim /etc/init.d/nginx 1 #!/bin/bash 2 #
nginx Startup script for the Nginx HTTP Server 3 #…

四.nginx的启动,停止

   (1)启动。进入nginx的sbin目录,./nginx

   (2)停止。进入nginx的sbin目录,./nginx -s stop**

RETVAL=$?

环境:CentOS6.5_x86_64;nginx1.8.0

# description: Nginx is a high-performance web and proxy server.

三.盛放80端口(直接施行二条命令即可)

  (1)/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT

  (2)/etc/rc.d/init.d/iptables save

echo -n $”Starting $prog: “

二.nginx安装

 (1)在var下创立temp以及Nginx目录,供存放零时文件

(2)上传nginx-1.8.0.tar.gz至linux,解压

(3)步入nginx目录,./configure======make=====make
install(安装后的暗中认可位          置/usr/local/nginx)

;;

五.nginx设置开机运维

  (1)vi /etc/init.d/nginx

=================================================

        #!/bin/bash

       # nginx Startup script for the Nginx HTTP Server

       # it is v.0.0.2 version.

# chkconfig: – 85 15

# description: Nginx is a high-performance web and proxy server.

#              It has a lot of features, but it’s not for everyone.

# processname: nginx

# pidfile: /var/run/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/var/run/nginx.pid

RETVAL=0

prog=”nginx”

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING} = “no” ] && exit 0

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then

echo “nginx already running….”

exit 1

fi

echo -n $”Starting $prog: “

daemon $nginxd -c ${nginx_config}

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

return $RETVAL

}

# Stop nginx daemons functions.

stop() {

echo -n $”Stopping $prog: “

killproc $nginxd

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid

}

# reload nginx service functions.

reload() {

echo -n $”Reloading $prog: “

#kill -HUP `cat ${nginx_pid}`

killproc $nginxd -HUP

RETVAL=$?

echo

}

# See how we were called.

case “$1” in

start)

start

;;

stop)

stop

;;

reload)

reload

;;

restart)

stop

start

;;

status)

status $prog

RETVAL=$?

;;

*)

echo $”Usage: $prog {start|stop|restart|reload|status|help}”

exit 1

esac

exit $RETVAL

=============================================================

(2)设置文件的寻访权限

chmod a+x /etc/init.d/nginx

=============================================================

vi /etc/rc.local

最后一行加上:/etc/init.d/nginx start 保存并退出,后一次再度开动生效

  

 

     

 

case “$1” in

一.安装nginx的重视包

(1)gcc: yum install gcc-c++

(2)PCRE:yuminstall -y pcre pcre-devel

(3)zlib:yuminstall -y zlib zlib-devel**

**(4)openssl:yuminstall -y openssl openssl-devel**

nginxd=/usr/local/nginx/sbin/nginx

prog=”nginx”

start() {

[ -x $nginxd ] || exit 0

reload

stop

;;

echo -n $”Stopping $prog: “

start)

echo

*)

# it is v.0.0.2 version.

return $RETVAL

# Check that networking is up.

发表评论

电子邮件地址不会被公开。 必填项已用*标注