[server] nginxのinitスクリプト
httpdのinitスクリプトを参考にnginxのinitスクリプトを書いた。
環境はCentOS 4.6なのでRedhat系なら使えます。
#!/bin/bash # Startup script for the Nginx Web Server # # chkconfig: - 85 15 # description: Nginx is a Light weight World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: nginx # pidfile: /var/run/nginx.pid # config: /etc/nginx/nginx.conf . /etc/rc.d/init.d/functions nginx='/usr/local/nginx/sbin/nginx' prog=nginx RET=0 start () { echo -n $"Starting $prog: " daemon $nginx RET=$? echo return $RET } stop () { echo -n $"Stopping $prog: " killproc $nginx RET=$? echo return $RET } reload() { echo -n $"Reloading $prog: " killproc $nginx -HUP RET=$? echo return $RET } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; reload) reload ;; *) echo $"Usage: $prog {start|stop|restart|reload}" exit 1 ;; esac exit $RET
上のスクリプトを/etc/init.d/nginxとして保存して自動起動するようにする。
# chkconfig --add nginx # chkconfig nginx on # chkconfig httpd off //ついでにapacheが自動起動しないようにする