nginx

使用http://openresty.org/的包,裏面包含了lua模塊

yum -y install pcre-devel openssl openssl-devel

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-luajit

make && make install


添加系統服務:
/etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by jackbillow at 2007.10.15.
# it is v.0.0.2 version.
# if you find any errors on this scripts,please contact jackbillow.
# and send mail to jackbillow at gmail dot com.
#
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx.pid

RETVAL=0
prog="nginx"

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -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: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL

}


# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}


# reload nginx service functions.
reload() {

echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo

}

# See how we were called.
case "$1" in
start)
start
;;

stop)
stop
;;

reload)
reload
;;

restart)
stop
start
;;

status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac

exit $RETVAL

添加
chkconfig --add nginx

Nginx -s stop 快速關閉Nginx,可能不保存相關信息,並迅速終止web服務。(quick exit)
Nginx -s quit 平穩關閉Nginx,保存相關信息,有安排的結束web服務。(graceful exit)
Nginx -s reload 因改變了Nginx相關配置,需要重新加載配置而重載。(changing configuration,start a new worker,quitting an old worker gracefully.)
Nginx -s reopen 重新打開日誌文件。(reopenging log files)

nginx -s reload
當主進程收到重新加載配置的信號後,它先檢測新配置的語法是否規範,然後開始嘗試加載新的配置。如果上面的步驟成功,主進程開始啓動新的工作進程並且發停止信號給舊的工作進程;否則,主進程回滾到改變前的配置,並繼續使用舊的配置工作。舊的工作進程接受到停止工作信號,它停止接受新的連接請求,但繼續處理當前的請求知道這些請求被處理完成。最後,舊的工作進程退出。

nginx -s quit
停止nginx但等待工作進程處理完成當前的請求
發佈了33 篇原創文章 · 獲贊 0 · 訪問量 1159
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章