the Nginx service program written by Shell
can be added to the/etc/init.d/directory first.
chkconfig--add nginxd
chkconfig nginxd on
Service Nginxd Start
Service Nginxd Stop
service Nginxd "Restart | Reload | Test | Status "
#!/bin/bash#chkconfig:-15#author:[email protected] #FUNC: Nginx service Script. #DATE: 2015-06-08#source function library. /etc/init.d/functions#source networking configuration. /etc/sysconfig/networknginx= "/usr/local/nginx/sbin/nginx" nginx_config_file= "/usr/local/nginx/conf/nginx.conf" lockfile= "/var/lock/subsys/nginx" function start () {Test/usr/local/nginx/sbin/nginx retval=$? If [$retval-eq 0] then touch $lockfile echo "Start Nginx OK!!!" Fi return $retval}function stop () {killall nginx retval=$? If [$retval-eq 0] then rm-f $lockfile echo "Stop Nginx OK!!!" Fi return $retval}function restart () {Stop start}function reload () {echo "Reload ......... ..."/usr/ Local/nginx/sbin/nginx-s Reload retval=$? If [$retval-eq 0] then echo "Reload Nginx Configure OK!!!" Fi return $retval}function status () {if [-f $lockfile] then echoes "Nginx is Running ... "echo" Please useing ps-ef check process. " Elseecho "Nginx is not Run ..." fi}function Test () {/usr/local/nginx/sbin/nginx-t retval=$? If [$retval-eq 0] then touch $lockfile echo "Configure Test Nginx OK!!!" Fi return $retval}case "in Start" echo "Nginx start ..." start; Stop) echo "Nginx stop ..." STOP; Restart) echo "Nginx restart ..." restart;; Status) echo "Nginx status ..." status;; Reload) echo "Nginx reload ..." reload;; Test) echo "Nginx Configure test ..." test;; *) echo "useage: $ {start|stop|status|restart|reload|test}" exit 2;; Esac
The Nginx service program written by Shell