Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.09 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # SCRIPT FOR INSTALLING NGINX (Headers More + GEOIP2 + PageSpeed + FLV + Brotli + Passenger) & PHP7.2-fpm
  4. #
  5.  
  6. echo "Welcome to this installation script of NGINX (Headers More + GEOIP2 + PageSpeed + FLV + Brotli + Passenger) & PHP7.2-fpm";
  7.  
  8. echo "Make sure to run this script as ROOT";
  9.  
  10. echo "Inserting repo of nginx into /etc/apt/sources.list";
  11. echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list;
  12. echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list;
  13.  
  14. echo "Inserting repo of PHP into /etc/apt/sources.list";
  15. echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu bionic main" >> /etc/apt/sources.list;
  16.  
  17. echo "Inserting repo of MaxMind into /etc/apt/sources.list";
  18. echo "deb http://ppa.launchpad.net/maxmind/ppa/ubuntu bionic main" >> /etc/apt/sources.list;
  19.  
  20.  
  21. echo "Adding keys";
  22. curl -L https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
  23. apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4F4EA0AAE5267A6C 561F9B9CAC40B2F7 DE1997DCDE742AFA
  24. sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
  25.  
  26. echo "Updating";
  27. apt update
  28. apt dist-upgrade
  29.  
  30. echo "Installing dependencies";
  31. apt-get install uuid-dev dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip git passenger libmaxminddb0 libmaxminddb-dev mmdb-bin libgeoip-dev
  32.  
  33. echo "Changing directory to /usr/local/src";
  34. cd /usr/local/src
  35.  
  36. echo "apt source nginx";
  37. sudo apt source nginx
  38.  
  39. echo "build-dep nginx";
  40. apt build-dep nginx -y
  41.  
  42. echo "##########DOWNLOADING MODULES############";
  43.  
  44. cd /usr/local/src
  45.  
  46. git clone --recursive https://github.com/google/ngx_brotli.git
  47. git clone --recursive https://github.com/winshining/nginx-http-flv-module.git
  48.  
  49. git clone https://github.com/leev/ngx_http_geoip2_module.git
  50. git clone https://github.com/openresty/headers-more-nginx-module.git
  51.  
  52. wget https://github.com/apache/incubator-pagespeed-ngx/archive/v1.13.35.2-stable.tar.gz
  53. wget https://www.modpagespeed.com/release_archive/1.13.35.2/psol-1.13.35.2-x64.tar.gz
  54.  
  55. tar xpf psol-1.13.35.2-x64.tar.gz
  56. tar xvzf v1.13.35.2-stable.tar.gz
  57. mv incubator-pagespeed-ngx-1.13.35.2-stable/ pagespeed-ngx-1.13.35.2-stable
  58. cd pagespeed-ngx-1.13.35.2-stable/
  59. mv ../psol/ .
  60. cd ..
  61. rm psol-1.13.35.2-x64.tar.gz v1.13.35.2-stable.tar.gz
  62.  
  63. echo "###DONE###";
  64.  
  65. rm /usr/local/src/nginx-1.14.2/debian/rules
  66.  
  67. echo "#!/usr/bin/make -f
  68.  
  69. #export DH_VERBOSE=1
  70. export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
  71. export DEB_CFLAGS_MAINT_APPEND=-Wp,-D_FORTIFY_SOURCE=2 -fPIC
  72. export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -pie
  73. DPKG_EXPORT_BUILDFLAGS = 1
  74. include /usr/share/dpkg/buildflags.mk
  75.  
  76. PKGS = nginx nginx-dbg
  77.  
  78. BUILDDIR_nginx = $(CURDIR)/debian/build-nginx
  79. BUILDDIR_nginx_debug = $(CURDIR)/debian/build-nginx-debug
  80. INSTALLDIR = $(CURDIR)/debian/nginx
  81. BASEDIR = $(CURDIR)
  82.  
  83. ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  84. NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  85. ifeq (${NUMJOBS}, 0)
  86. NUMJOBS = 1
  87. endif
  88. else
  89. NUMJOBS = 1
  90. endif
  91.  
  92. DO_PKGS = $(PKGS)
  93.  
  94. config.env.%:
  95. dh_testdir
  96. mkdir -p $(BUILDDIR_$*)
  97. cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
  98. cp -Pa $(CURDIR)/conf $(BUILDDIR_$*)/
  99. cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
  100. cp -Pa $(CURDIR)/contrib $(BUILDDIR_$*)/
  101. cp -Pa $(CURDIR)/man $(BUILDDIR_$*)/
  102. cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
  103. touch $@
  104.  
  105. config.status.nginx: config.env.nginx
  106. cd $(BUILDDIR_nginx) && \
  107. CFLAGS="" ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --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.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/usr/local/src/nginx-http-flv-module --add-module=/usr/local/src/ngx_brotli --add-module=/usr/local/src/ngx_http_geoip2_module --add-module=/usr/local/src/headers-more-nginx-module --add-module=/usr/share/passenger/ngx_http_passenger_module --add-module=/usr/local/src/pagespeed-ngx-1.13.35.2-stable --with-http_geoip_module --with-cc-opt="$(CFLAGS)" --with-ld-opt="$(LDFLAGS)"
  108. touch $@
  109.  
  110. config.status.nginx_debug: config.env.nginx_debug
  111. cd $(BUILDDIR_nginx_debug) && \
  112. CFLAGS="" ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --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.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/usr/local/src/nginx-http-flv-module --add-module=/usr/local/src/ngx_brotli --add-module=/usr/local/src/ngx_http_geoip2_module --add-module=/usr/local/src/headers-more-nginx-module --add-module=/usr/share/passenger/ngx_http_passenger_module --add-module=/usr/local/src/pagespeed-ngx-1.13.35.2-stable --with-http_geoip_module --with-cc-opt="$(CFLAGS)" --with-ld-opt="$(LDFLAGS)" --with-debug
  113. touch $@
  114.  
  115. build-arch.%: config.status.%
  116. dh_testdir
  117. dh_prep
  118. $(MAKE) -j$(NUMJOBS) -C $(BUILDDIR_$*) build
  119.  
  120. build-arch: build-arch.nginx build-arch.nginx_debug
  121. dh_testdir
  122. touch $@
  123.  
  124. build-dbg.%: install
  125. dh_testdir
  126. dh_strip --dbg-package=nginx-dbg
  127.  
  128. build-dbg: build-dbg.nginx
  129. dh_testdir
  130. touch $@
  131.  
  132. build-indep:
  133. dh_testdir
  134. touch $@
  135.  
  136. build: build-arch build-indep
  137. dh_testdir
  138. touch $@
  139.  
  140. clean:
  141. dh_testdir
  142. dh_testroot
  143. dh_clean
  144. rm -f $(CURDIR)/objs
  145. rm -rf $(CURDIR)/debian/build-*
  146. rm -f $(CURDIR)/debian/*.init
  147. find $(CURDIR) -maxdepth 1 -size 0 -delete
  148.  
  149. post-build:
  150. mv $(BUILDDIR_nginx_debug)/objs/nginx $(BUILDDIR_nginx_debug)/objs/nginx-debug
  151. ln -s $(BUILDDIR_nginx)/objs $(CURDIR)/objs
  152. cp $(BUILDDIR_nginx)/objs/nginx.8 $(BUILDDIR_nginx)/objs/nginx-debug.8
  153.  
  154. install:
  155. dh_testdir
  156. dh_testroot
  157. dh_prep
  158. dh_installdirs
  159. dh_install
  160. mkdir -p $(INSTALLDIR)/usr/lib/nginx/modules
  161. mkdir -p $(INSTALLDIR)/usr/share/doc/nginx
  162. install -m 644 debian/CHANGES $(INSTALLDIR)/usr/share/doc/nginx/changelog
  163. install -m 644 debian/nginx.vh.default.conf $(INSTALLDIR)/etc/nginx/conf.d/default.conf
  164. ln -s /usr/lib/nginx/modules $(INSTALLDIR)/etc/nginx/modules
  165.  
  166. binary-indep: build post-build install
  167. dh_testdir
  168. dh_testroot
  169. dh_installman -i -pnginx
  170. dh_installdebconf
  171. sed -e 's/%%PROVIDES%%/nginx/g' \
  172. -e 's/%%DEFAULTSTART%%/2 3 4 5/g' \
  173. -e 's/%%DEFAULTSTOP%%/0 1 6/g' \
  174. < debian/nginx.init.in > debian/nginx.init
  175. dh_installinit -i -pnginx --no-restart-on-upgrade --no-start --name=nginx
  176. dh_systemd_enable -pnginx --name=nginx nginx.service
  177. sed -e 's/%%PROVIDES%%/nginx-debug/g' \
  178. -e 's/%%DEFAULTSTART%%//g' \
  179. -e 's/%%DEFAULTSTOP%%/0 1 2 3 4 5 6/g' \
  180. < debian/nginx.init.in > debian/nginx-debug.init
  181. dh_installinit -i -pnginx --no-restart-on-upgrade --no-start --noscripts --name=nginx-debug
  182. dh_systemd_enable -pnginx --name=nginx-debug --no-enable nginx-debug.service
  183. dh_installlogrotate -i -pnginx --name=nginx
  184.  
  185. binary-arch: install build-dbg
  186. dh_testdir
  187. dh_testroot
  188. dh_installchangelogs -a
  189. dh_installdocs -a
  190. dh_lintian -a
  191. dh_link -aA
  192. dh_compress -a
  193. dh_perl -a
  194. dh_fixperms -a
  195. dh_installdeb -a
  196. dh_shlibdeps -a
  197. dh_gencontrol -a
  198. dh_md5sums -a
  199. dh_builddeb $(foreach p,$(DO_PKGS),-p$(p))
  200.  
  201. binary: binary-indep binary-arch
  202.  
  203. .PHONY: build clean binary-indep binary-arch binary install" >> /usr/local/src/nginx-1.14.2/debian;
  204.  
  205. echo "######BUILDING#######";
  206.  
  207. /usr/local/src/nginx-1.14.2/
  208. dpkg-buildpackage -b -uc -us
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement