ubuntu12.04下nginx设置开机自启动
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
?? echo "nginx already running...."
?? exit 1
fi
?? echo -n $"Starting $prog: "
?? $nginxd -c ${nginx_config}
?? RETVAL=$?
?? echo
?? [ $RETVAL = 0 ]
?? return $RETVAL
}
# Stop nginx daemons functions.
stop() {
??????? echo -n $"Stopping $prog: "
??????? $nginxd -s stop
??????? RETVAL=$?
??????? echo
??????? [ $RETVAL = 0 ]
}
# reload nginx service functions.
reload() {
??? echo -n $"Reloading $prog: "
??? #kill -HUP `cat ${nginx_pid}`
?
保存,设置nginx脚本可执行权限
chmod u+x /etc/init.d/nginx
将该脚本设为开启自启动
update-rc.d -f nginx defaults
如果想取消开机自启动
update-rc.d -f nginx remove
?
至此设置成功
?