~~~
rm -rf /usr/local/nginx1.12.2
# install dependencey
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel
userdel www
groupadd www
useradd -g www -M -d /home/www -s /sbin/nologin www
cd /usr/local/src
echo "down load packge of nginx"
#rm -rf nginx-1.12.2.tar.gz
if [ ! -f nginx-1.12.2.tar.gz ]; then
wget http://nginx.org/download/nginx-1.12.2.tar.gz
fi
rm -rf nginx-1.12.2
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --user=www \
--group=www \
--prefix=/usr/local/nginx1.12.2 \
--with-http_stub_status_module \
--without-http-cache \
--with-http_ssl_module \
--with-http_gzip_static_module
make
make install
mkdir -p /usr/local/nginx1.12.2/logs/
cd ../
cp nginx /etc/init.d/
chmod 770 /etc/init.d/nginx
/etc/init.d/nginx start
~~~
~~~
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by ruijie. at 2014.02.26
# if you find any errors on this scripts,please contact ruijie.
# and send mail to ruijie at gmail dot com.
# ruijie.qiao@gmail.com
nginxd=/usr/local/nginx1.12.2/sbin/nginx
nginx_config=/usr/local/nginx1.12.2/conf/nginx.conf
nginx_pid=/usr/local/nginx1.12.2/logs/nginx.pid
RETVAL=0
prog="nginx"
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog!"
$nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog!"
$nginxd -s stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/nginx
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog!"
#kill -HUP `cat ${nginx_pid}`
$nginxd -s reload
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|help}"
exit 1
esac
exit $RETVAL
~~~