The first step
Run command to close Nginx first
sudo kill ' cat/usr/local/nginx/logs/nginx.pid '
Step Two
Vi/etc/init.d/nginx
Enter the following content
#!/bin/sh
#
# Nginx-this script starts and stops the Nginx daemin
#
# Chkconfig:-85 15
# Description:nginx is an HTTP (s) server, HTTP (s) reverse \
# Proxy and IMAP/POP3 proxy server
# Processname:nginx
# config:/usr/local/nginx/conf/nginx.conf
# Pidfile:/usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
["$NETWORKING" = "no"] && exit 0
nginx= "/usr/local/nginx/sbin/nginx"
prog=$ (basename $nginx)
Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"
Lockfile=/var/lock/subsys/nginx
Start () {
[-X $nginx] | | Exit 5
[-F $NGINX _conf_file] | | Exit 6
Echo-n $ "Starting $prog:"
Daemon $nginx-C $NGINX _conf_file
Retval=$?
Echo
[$retval-eq 0] && Touch $lockfile
Return $retval
}
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $prog-quit
Retval=$?
Echo
[$retval-eq 0] && rm-f $lockfile
Return $retval
}
Restart () {
Configtest | | Return $?
Stop
Start
}
Reload () {
Configtest | | Return $?
Echo-n $ "Reloading $prog:"
Killproc $nginx-hup
Retval=$?
Echo
}
Force_reload () {
Restart
}
Configtest () {
$nginx-T-C $NGINX _conf_file
}
Rh_status () {
Status $prog
}
Rh_status_q () {
Rh_status >/dev/null 2>&1
}
Case "$" in
Start
Rh_status_q && Exit 0
$
;;
Stop
Rh_status_q | | Exit 0
$
;;
Restart|configtest)
$
;;
Reload
Rh_status_q | | Exit 7
$
;;
Force-reload)
Force_reload
;;
Status
Rh_status
;;
Condrestart|try-restart)
Rh_status_q | | Exit 0
;;
*)
echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
Exit 2
Esac
Save exit
Step Three
chmod +x/etc/init.d/nginx
Fourth Step
/sbin/chkconfig Nginx on
Check it out.
Sudo/sbin/chkconfig--list Nginx
Nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Complete!
After that, you can use the following command.
Service Nginx Start
Service Nginx Stop
Service Nginx Restart
Service Nginx Reload
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx restart
/etc/init.d/nginx Reload
Incoming Search terms:
- Nginx Boot
- Nginx Startup script
- Nginx Restart
- Nginx Boot
- Nginx Startup script
- Nginx Restart
- Start Nginx
- Nginx Stop
- Nginx Reload
- Nginx Restart Script
Nginx startup script/Restart script