Nginx custom build by Hakase | GitHub : https://github.com/hakasenyang/nginx-build
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auto.sh 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #!/bin/sh
  2. ### Read config
  3. if [ ! -f "config.inc" ]; then
  4. echo "--- The configuration file (config.inc) could not be found. Apply as default setting. ---"
  5. echo "--- All additional modules are not used. ---"
  6. else
  7. . ./config.inc
  8. fi
  9. ### If the value is incorrect, convert to normal data.
  10. if [ ! "$SERVER_HEADER" ]; then SERVER_HEADER="hakase"; fi
  11. if [ "$BITCHK" != 32 ] && [ "$BITCHK" != 64 ]; then BITCHK=32; fi
  12. if [ ! "$LTO" ]; then LTO=0; fi
  13. if [ ! "$BUILD_MTS" ]; then BUILD_MTS="-j2"; fi
  14. if [ ! "$NGX_PREFIX" ]; then NGX_PREFIX="/usr/local/nginx"; fi
  15. if [ ! "$NGX_SBIN_PATH" ]; then NGX_SBIN_PATH="/usr/sbin/nginx"; fi
  16. if [ ! "$NGX_CONF" ]; then NGX_CONF="/etc/nginx/nginx.conf"; fi
  17. if [ ! "$NGX_LIB" ]; then NGX_LIB="/var/lib/nginx"; fi
  18. if [ ! "$NGX_LOG" ]; then NGX_LOG="/var/log/nginx"; fi
  19. if [ ! "$NGX_PID" ]; then NGX_PID="/var/run/nginx.pid"; fi
  20. if [ ! "$NGX_LOCK" ]; then NGX_LOCK="/var/lock/nginx.lock"; fi
  21. ### Remove Old file
  22. rm -f ${NGX_SBIN_PATH}.old
  23. ### Multithread build
  24. BUILD_MTS="-j$(expr $(nproc) \+ 1)"
  25. git submodule update --init --recursive
  26. ### PCRE reconf
  27. if [ ! -f "lib/pcre/configure" ]; then
  28. cd lib/pcre
  29. autoreconf -f -i
  30. cd ../..
  31. fi
  32. ### ZLIB reconf
  33. if [ "$BITCHK" = 64 ]; then
  34. if [ ! -f "lib/zlib/Makefile" ]; then
  35. cd lib/zlib
  36. ./configure --64
  37. cd ../..
  38. fi
  39. else
  40. if [ ! -f "lib/zlib_x86/Makefile" ]; then
  41. git submodule add --force https://github.com/madler/zlib.git lib/zlib_x86
  42. cd lib/zlib_x86
  43. ./configure
  44. cd ../..
  45. fi
  46. fi
  47. ### PSOL Download (PageSpeed)
  48. if [ ! -d "lib/pagespeed" ] && [ "$PAGESPEED" = 1 ]; then
  49. ### Download pagespeed
  50. cd lib
  51. wget -c https://github.com/apache/incubator-pagespeed-ngx/archive/v1.13.35.2-stable.zip
  52. unzip v1.13.35.2-stable.zip
  53. rm -f v1.13.35.2-stable.zip
  54. cd incubator-pagespeed-ngx-1.13.35.2-stable
  55. ### Download psol
  56. curl "$(scripts/format_binary_url.sh PSOL_BINARY_URL)" | tar xz
  57. cd ..
  58. mv incubator-pagespeed-ngx-1.13.35.2-stable pagespeed
  59. cd ..
  60. fi
  61. ### x86, x64 Check (Configuration)
  62. if [ "$BITCHK" = 64 ]; then
  63. BUILD_BIT="-m64 "
  64. BUILD_ZLIB="./lib/zlib"
  65. BUILD_LD="-lrt -ljemalloc -Wl,-z,relro -Wl,-z,now -fPIC"
  66. else
  67. BUILD_BIT=""
  68. BUILD_ZLIB="./lib/zlib_x86"
  69. BUILD_LD=""
  70. fi
  71. ### LTO Build
  72. if [ "$LTO" = 1 ]; then
  73. BUILD_LTO="-flto -ffat-lto-objects"
  74. BUILD_OPENSSL_LTO="-flto -ffat-lto-objects"
  75. else
  76. BUILD_LTO=""
  77. BUILD_OPENSSL_LTO=""
  78. fi
  79. ### Temporary Ubuntu/Debian build error (libxslt/libxml2)
  80. ### URL : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721602
  81. TEMP_OPT="-lm"
  82. ### Module check
  83. if [ "$PAGESPEED" = 1 ]; then BUILD_MODULES="--add-module=./lib/pagespeed ${PS_NGX_EXTRA_FLAGS}"; fi
  84. if [ "$FLV" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/nginx-http-flv-module"; fi
  85. if [ "$NAXSI" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/naxsi/naxsi_src"; fi
  86. if [ "$DAV_EXT" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/nginx-dav-ext-module"; fi
  87. if [ "$FANCYINDEX" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngx-fancyindex"; fi
  88. if [ "$GEOIP2" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngx_http_geoip2_module"; fi
  89. if [ "$VTS" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/nginx-module-vts"; fi
  90. auto/configure \
  91. --with-cc-opt="-DTCP_FASTOPEN=23 ${BUILD_BIT}${BUILD_LTO} ${TEMP_OPT} -g -O3 -march=native -fstack-protector-strong -fuse-ld=gold -fuse-linker-plugin --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-strict-aliasing -Wp,-D_FORTIFY_SOURCE=2 -gsplit-dwarf -DNGX_HTTP_HEADERS" \
  92. --with-ld-opt="${BUILD_LD} ${BUILD_LTO}" \
  93. --with-openssl-opt="enable-weak-ssl-ciphers no-ssl3-method -march=native -ljemalloc ${BUILD_OPENSSL_LTO}" \
  94. --builddir=objs --prefix=${NGX_PREFIX} \
  95. --conf-path=${NGX_CONF} \
  96. --pid-path=${NGX_PID} \
  97. --lock-path=${NGX_LOCK} \
  98. --http-log-path=${NGX_LOG}/access.log \
  99. --error-log-path=${NGX_LOG}/error.log \
  100. --sbin-path=${NGX_SBIN_PATH} \
  101. --http-client-body-temp-path=${NGX_LIB}/client_body_temp \
  102. --http-proxy-temp-path=${NGX_LIB}/proxy_temp \
  103. --http-fastcgi-temp-path=${NGX_LIB}/fastcgi_temp \
  104. --http-scgi-temp-path=${NGX_LIB}/scgi_temp \
  105. --http-uwsgi-temp-path=${NGX_LIB}/uwsgi_temp \
  106. --with-pcre=./lib/pcre \
  107. --with-pcre-jit \
  108. --with-zlib=${BUILD_ZLIB} \
  109. --with-openssl=./lib/openssl \
  110. --with-http_realip_module \
  111. --with-http_addition_module \
  112. --with-http_sub_module \
  113. --with-http_dav_module \
  114. --with-http_stub_status_module \
  115. --with-http_flv_module \
  116. --with-http_mp4_module \
  117. --with-http_gunzip_module \
  118. --with-http_slice_module \
  119. --with-http_gzip_static_module \
  120. --with-http_auth_request_module \
  121. --with-http_dav_module \
  122. --with-http_random_index_module \
  123. --with-http_secure_link_module \
  124. --with-http_image_filter_module \
  125. --with-file-aio \
  126. --with-threads \
  127. --with-libatomic \
  128. --with-mail \
  129. --with-compat \
  130. --with-stream \
  131. --with-http_ssl_module \
  132. --with-mail_ssl_module \
  133. --with-http_v2_module \
  134. --with-http_v2_hpack_enc \
  135. --with-stream_ssl_module \
  136. --with-stream_realip_module \
  137. --with-stream_ssl_preread_module \
  138. --add-module=./lib/ngx_devel_kit \
  139. --add-module=./lib/ngx_brotli \
  140. --add-module=./lib/headers-more-nginx-module \
  141. ${BUILD_MODULES}
  142. ### OpenSSL Skip
  143. ### Do not use it for the FIRST BUILD.
  144. #touch lib/openssl/.openssl/include/openssl/ssl.h
  145. ### SERVER HEADER CONFIG
  146. NGX_AUTO_CONFIG_H="objs/ngx_auto_config.h";have="NGINX_SERVER";value="\"${SERVER_HEADER}\""; . auto/define
  147. ### Install
  148. make $BUILD_MTS install
  149. ### Make directory NGX_LIB
  150. mkdir -p ${NGX_LIB}
  151. ### Check for old files
  152. if [ -f "${NGX_SBIN_PATH}.old" ]; then
  153. sleep 1
  154. rm ${NGX_SBIN_PATH}.old
  155. systemctl restart nginx
  156. fi