: This article mainly introduces the Nginx series (III. registering nginx as a linux system service). If you are interested in the PHP Tutorial, refer to it. 1. create a service script
vim /etc/init.d/nginx
The script content is as follows:
#! /bin/sh# chkconfig: - 85 15PATH=/web/server/nginx/sbinDESC="nginx daemon"NAME=nginxDAEMON=/web/server/nginx/sbin/$NAMECONFIGFILE=/web/server/nginx/conf/$NAME.confPIDFILE=/web/server/nginx/logs/$NAME.pidSCRIPTNAME=/etc/init.d/$NAMEset-e[ -x "$DAEMON" ] || exit0do_start() {$DAEMON -c $CONFIGFILE || echo -n "nginx already running"}do_stop() {$DAEMON-s stop || echo -n "nginx not running"}do_reload() {$DAEMON-s reload || echo -n "nginx can't reload"}case"$1"instart)echo -n "Starting $DESC: $NAME"do_startecho".";;stop)echo -n "Stopping $DESC: $NAME"do_stopecho".";;reload|graceful)echo -n "Reloading $DESC configuration..."do_reloadecho".";;restart)echo -n "Restarting $DESC: $NAME"do_stopdo_startecho".";;*)echo"Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2exit3;;esacexit0
2. add a service
chkconfig--addnginx
III. test
service nginx start
service nginx stop
service nginx restart
service nginx reload