Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen,> -p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
# ./nginx -v //显示版本
nginx version: nginx/1.4.4
# ./nginx -t //测试语法,有错误
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
# mkdir -pv /var/tmp/nginx/client //按照提示更正错误
mkdir: created directory `/var/tmp/nginx'
mkdir: created directory `/var/tmp/nginx/client'
# ./nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# ./nginx //启动nginx
# netstat -tupln |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12682/nginx
# vim /etc/init.d/nginx //编辑nginx启动脚本
#!/bin/bash
. /etc/init.d/functions
prog=/usr/local/nginx/sbin/nginx
lockfile=/var/lock/nginx.lock
start () {
if [ -e $lockfile ];then
echo "nginx is started" && exit
else
echo -n "nginx is starting....."
sleep 1
$prog &>/dev/null && touch $lockfile && echo "OK" || echo "failer"
fi
}
configtest (){
$prog -t
}
stop () {
if [ ! -e $lockfile ];then
echo "nginx is stoped" && exit
else
echo -n "httpd is stoping......"
sleep 1
$prog -s stop &>/dev/null && rm -rf $lockfile && echo "OK" || echo "failer"
fi