解压出来后执行
mkdir /var/tmp/nginx/client/ -pv
接下来我们简单的为它提供一个服务脚本吧!
# vim /etc/init.d/nginx
新建文件/etc/rc.d/init.d/nginx,内容如下:
#!/bin/bash
# chkconfig:235 85 15
# description: Nginx is an HTTP server
. /etc/rc.d/init.d/functions
start() {
echo "Start..."
/usr/local/nginx/sbin/nginx &> /dev/null
if [ $? -eq 0 ];then
echo "Start successful!"
else
echo "Start failed!"
fi
}
stop() {
if killproc nginx -QUIT ;then
echo "Stopping..."
fi
}
restart() {
stop
sleep 1
start
}
reload() {
killproc nginx -HUP
echo "Reloading..."
}
configtest() {
/usr/local/nginx/sbin/nginx -t
}
case $1 in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
reload)
reload ;;
configtest)
configtest ;;
*)
echo "Usage: nginx {start|stop|restart|reload|configtest}"
;;
esac
之后给这个文件可执行权限:
# chmod +x /etc/init.d/nginx
现在可以使用 start,stop 这些参数控制Nginx服务了