# download pcre for regular expression if [ ! -f "pcre-${pcre_version}.tar.gz" ]; then wget -c -t 0 -T 1200 https://sourceforge.net/projects/pcre/files/pcre/${pcre_version}/pcre-${pcre_version}.tar.gz/download -O pcre-${pcre_version}.tar.gz fi checkFile pcre-${pcre_version}.tar.gz
# Don't need install the dependent packages , we juse need source code . # When we compile nginx , it will compile with other dependent source code auto. tar zxf openssl-${openssl_version}.tar.gz || echo"unpack openssl fail" && exit 1
tar zxf zlib-${zlib_version}.tar.gz
tar zxf pcre-${pcre_version}.tar.gz
tar zxf nginx-${nginx_version}.tar.gz
cd nginx-${nginx_version}
# default compile with http2 module 、ssl、status ... If you need other module , you can modify it here. ./configure --prefix=${install_path} --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-stream --with-http_stub_status_module --with-openssl=../openssl-${openssl_version} --with-pcre=../pcre-${pcre_version} --with-zlib=../zlib-${zlib_version} && exit 1
mkdir -p /var/log/nginx /usr/local/nginx/logs # default compile with http2 module 、ssl、status ... If you need other module , you can modify it here. ./configure --prefix=${install_path} --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-stream --with-http_stub_status_module --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi make && make install
# crete work user useradd -M -s /sbin/nologin nginx
/usr/local/nginx/sbin/nginx -V
# run nginx cd /usr/local/nginx/sbin ./nginx -c /usr/local/nginx/configig/nginx.conf