Script nginx.sh
Jump to navigation
Jump to search
NOTE: this script use the unprivileged user 'www-data' to run nginx; that's mean that you need to config nginx to use unprivileged port (and use iptables to do the 'redirect' if you want), or you need to sobstitute the user 'www-data' with 'root' in this script.
#!/bin/sh # # Nginx HTTP server PATH=/sbin:/bin:/usr/sbin:/usr/bin; USER="www-data"; COMMAND="/srv/local/nginx/sbin/nginx"; START=""; STOP="-s quit"; RET_CODE=0 case "$1" in start) su "${USER}" -c "${COMMAND} ${START}"; RET_CODE=$?; ;; stop) su "${USER}" -c "${COMMAND} ${STOP}"; RET_CODE=$?; ;; status|restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2; RET_CODE=1; ;; *) echo "Usage: $0 {start|stop}"; RET_CODE=1; ;; esac; exit "${RET_CODE}"; # End