Permalink
Browse files

Add rhel5 Nginx init.d script.

  • Loading branch information...
huacnlee committed Dec 14, 2012
1 parent 748d1e7 commit 0f9b4bd5e5b6b6ce81d2c15d721124d2cc59e404
Showing with 114 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 rhel5/install_nginx
  3. +106 −0 rhel5/nginx
View
@@ -0,0 +1 @@
+.DS_Store
View
@@ -5,4 +5,11 @@ cd nginx-1.2.6
./configure --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-file-aio
make
sudo make install
+sudo ln -sf /usr/local/nginx/sbin/nginx /usr/local/bin/
echo "Nginx has successed installed to /usr/local/nginx"
+
+sudo cp nginx /etc/init.d/
+sudo mkdir /var/run/nginx
+sudo /sbin/chkconfig nginx on
+
+echo "Nginx has added to init.d and auto start on boot.\n Now you can use: \tsudo "
View
@@ -0,0 +1,106 @@
+#!/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 is up.
+[ "$NETWORKING" = "no" ] && exit 0
+
+nginx="/usr/local/bin/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 "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart|configtest)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
+ exit 2
+esac

0 comments on commit 0f9b4bd

Please sign in to comment.