Creating Nginx files under/etc/init.d/ [Email protected] init.d]# VI nginx Write the following content: #!/bin/bash # nginx Startup script for the Nginx HTTP Server # 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:/usr/local/nginx/logs/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=/usr/local/nginx/logs/nginx.pid Retval=0 Prog= "Nginx" # Source function library. . /etc/rc.d/init.d/functions # Source Networking configuration. . /etc/sysconfig/network # Check that networking are 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 "$" 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 Give executable permission [Email protected] init.d]# chmod A+x/etc/init.d/nginx Set boot up [Email protected] init.d]# chkconfig--add/etc/init.d/nginx [[email protected] init.d]# chkconfig nginx on Start: [[Email protected] lib64]# service Nginx start Starting nginx: [OK] |