1、系统环境
ubuntu 14.04
2、安装编译环境
#apt-get update && apt-get upgrade
#apt-get install libpcre3 libpcre3-dev zlib1g-dev libssl-dev build-essential openssl libssl0.9.8 libssl-dev -y
3、下载nginx编译包,并解压。
# wget http://120.198.244.55:9999/nginx.org/download/nginx-1.10.3.tar.gz
# tar xf nginx-1.10.3.tar.gz
4、开始编译和安装:
# cd /nginx-1.10.3/
# mkdir /var/tmp/nginx/{client,proxy,fcgi,uwsgi,scgi} -pv
#./configure \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
# make -j 2 && make install
6、检查nginx目录文件依赖 # /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
7、为nginx提供SysV init脚本:
#! /bin/sh
# Author: liaodijin
# Date: 20170411
# chkconfig: 2345 85 15
# description: The Nginx servlet container.
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/etc/nginx/nginx.conf
nginx_pid=/var/run/nginx/nginx.pid
RETVAL=0
prog="nginx"
# Check that networking is up.
[ -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: "
$nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ]
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n " Stopping $prog: "
$nginxd -s stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid
}
# reload nginx service functions.
reload() {
echo -n "Reloading $prog: "
kill -HUP `cat ${nginx_pid}`
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: `basename $0` {start|stop|restart}"
exit 1
esac
exit $RETVAL
linux