vim /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/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/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {[ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6echo -n $"Starting $prog: "daemon $nginx -c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval
}
stop() {echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retval
killall -9 nginx
}
restart() {configtest || return $?stopsleep 1start
}
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" instart)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
chmod +x /etc/init.d/nginx
主要是根据业务逻辑来配置nginx.conf,这里忽略具体内容
nginx: [emerg] unknown directive "rewrite_by_lua_file" in /usr/local/nginx/conf/nginx.conf:136
解决方法
这两个报错,是因为nginx.conf中添加了这两个指令,将对应配置及逻辑删除就可以了。
参考链接vim /etc/init.d/nginx 粘贴 #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-...
1.下载nginx 方法一 wget http://nginx.org/download/nginx-1.11.6.tar.gz 方法二 http://nginx.org/en/download.html在Nginx官网手动下载 2.解压nginx的gz包 tar -zxvf nginx-1.11.6.t...
本文档记录了完全使用最新源码来编译安装nginx最新版1.10.3,所有的依赖也是最新的,便于第三方nginx模块开发 假定使用root身份安装 目前最新的源码地址汇总 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz http:/...
为了自己的ThinkPad T420上面的Ubuntu可以使用openresty开发,我特地记录一下安装过程: 安装依赖包 apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential 下载源码并...
ngx_req_status是一个第三方模块,它用来展示nginx请求状态信息,类似于apache的status,ats的stats_over_http和channel_stats,nginx自带的模块只能显示连接数等等信息,我们并不能知道到底有哪些请求、以及各url域名所消耗的带宽是多少。ngx_req_status提供了这些功能:...
Nginx中的stub_status模块主要用于查看Nginx的一些状态信息. 本模块默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定: ./configure --with-http_stub_status_module 基础的nginx搭建参见本博博文 http://blog.cs...
vim /usr/local/nginx/conf/nginx.conf ...