build-nginx.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. set -e
  3. cur_date="`date +%Y-%m-%d`"
  4. ROOT=$(cd `dirname $0`; pwd)
  5. mkdir -p $ROOT/tmp
  6. rm -rf $ROOT/tmp/*
  7. # NOTE: Adapted from https://github.com/moezzie/nginx-portable
  8. mkdir -p $ROOT/cache
  9. cd $ROOT/cache
  10. NGINX_NAME=$1
  11. NGINX_PREFIX_PATH=$2
  12. NGINX_ARCHIVE=$NGINX_NAME.tar.gz
  13. # Name cannot be empty
  14. if [ -z $NGINX_NAME ]; then
  15. echo "Usage: $0 <nginx-version> <prefix-path>"
  16. exit 1
  17. fi
  18. if [ -z $NGINX_PREFIX_PATH ]; then
  19. echo "Usage: $0 <nginx-version> <prefix-path>"
  20. exit 1
  21. fi
  22. if [ ! -r $NGINX_ARCHIVE ]; then
  23. echo "Downloading $NGINX_ARCHIVE..."
  24. wget https://nginx.org/download/$NGINX_ARCHIVE
  25. fi
  26. tar -zxf $NGINX_ARCHIVE
  27. cd $ROOT/cache/$NGINX_NAME
  28. if [ ! -r Makefile ]; then
  29. echo "Configuring $NGINX_NAME..."
  30. ./configure --prefix=$NGINX_PREFIX_PATH --sbin-path=bin/ --conf-path=conf/nginx.conf --error-log-path=logs/error.log --http-client-body-temp-path=tmp/client_body_temp/ --http-proxy-temp-path=tmp/proxy_temp/ --http-fastcgi-temp-path=tmp/fastcgi_temp/ --http-uwsgi-temp-path=tmp/uwsgi_temp/ --http-scgi-temp-path=tmp/scgi_temp/ --with-http_realip_module --with-ipv6 --with-http_gzip_static_module --with-http_stub_status_module --with-stream --with-pcre-jit --with-threads --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_fastcgi_module
  31. fi
  32. echo Building $NGINX_NAME...
  33. make
  34. mkdir -p $ROOT/tmp/nginx
  35. echo ✅ $NGINX_NAME built successfully.