Skip to content

Instantly share code, notes, and snippets.

@nijitaro
Created September 2, 2010 06:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nijitaro/561969 to your computer and use it in GitHub Desktop.
Save nijitaro/561969 to your computer and use it in GitHub Desktop.
CentOS startup script for the nginx
CentOS startup script for the nginx
* nginx installed /usr/local/nginx/ directory
$ sudo mv /path/to/nginxd /etc/init.d/nginxd
$ cd nginxd
$ chmod +x nginxd
$ chkconfig nginxd on
$ chkconfig --list nginxd
nginxd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Then, you can use it: /etc/init.d/nginx stop/start/restart
#!/bin/bash
#
# Startup script for the nginx
#
# chkconfig: 345 80 15
# description: Nginx web server.
# Source function library.
. /etc/rc.d/init.d/functions
start(){
/usr/local/nginx/sbin/nginx
}
stop(){
kill `cat /usr/local/nginx/logs/nginx.pid`
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment