Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # SCRIPT FOR INSTALLING NGINX (Headers More + GEOIP2 + PageSpeed + FLV + Brotli + Passenger) & PHP7.2-fpm
- #
- echo "Welcome to this installation script of NGINX (Headers More + GEOIP2 + PageSpeed + FLV + Brotli + Passenger) & PHP7.2-fpm";
- echo "Make sure to run this script as ROOT";
- echo "Inserting repo of nginx into /etc/apt/sources.list";
- echo "deb http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list;
- echo "deb-src http://nginx.org/packages/ubuntu/ bionic nginx" >> /etc/apt/sources.list;
- echo "Inserting repo of PHP into /etc/apt/sources.list";
- echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu bionic main" >> /etc/apt/sources.list;
- echo "Inserting repo of MaxMind into /etc/apt/sources.list";
- echo "deb http://ppa.launchpad.net/maxmind/ppa/ubuntu bionic main" >> /etc/apt/sources.list;
- echo "Adding keys";
- curl -L https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4F4EA0AAE5267A6C 561F9B9CAC40B2F7 DE1997DCDE742AFA
- sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
- echo "Updating";
- apt update
- apt dist-upgrade
- echo "Installing dependencies";
- apt-get install uuid-dev dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip git passenger libmaxminddb0 libmaxminddb-dev mmdb-bin libgeoip-dev
- echo "Changing directory to /usr/local/src";
- cd /usr/local/src
- echo "apt source nginx";
- sudo apt source nginx
- echo "build-dep nginx";
- apt build-dep nginx -y
- echo "##########DOWNLOADING MODULES############";
- cd /usr/local/src
- git clone --recursive https://github.com/google/ngx_brotli.git
- git clone --recursive https://github.com/winshining/nginx-http-flv-module.git
- git clone https://github.com/leev/ngx_http_geoip2_module.git
- git clone https://github.com/openresty/headers-more-nginx-module.git
- wget https://github.com/apache/incubator-pagespeed-ngx/archive/v1.13.35.2-stable.tar.gz
- wget https://www.modpagespeed.com/release_archive/1.13.35.2/psol-1.13.35.2-x64.tar.gz
- tar xpf psol-1.13.35.2-x64.tar.gz
- tar xvzf v1.13.35.2-stable.tar.gz
- mv incubator-pagespeed-ngx-1.13.35.2-stable/ pagespeed-ngx-1.13.35.2-stable
- cd pagespeed-ngx-1.13.35.2-stable/
- mv ../psol/ .
- cd ..
- rm psol-1.13.35.2-x64.tar.gz v1.13.35.2-stable.tar.gz
- echo "###DONE###";
- rm /usr/local/src/nginx-1.14.2/debian/rules
- echo "#!/usr/bin/make -f
- #export DH_VERBOSE=1
- export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
- export DEB_CFLAGS_MAINT_APPEND=-Wp,-D_FORTIFY_SOURCE=2 -fPIC
- export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -pie
- DPKG_EXPORT_BUILDFLAGS = 1
- include /usr/share/dpkg/buildflags.mk
- PKGS = nginx nginx-dbg
- BUILDDIR_nginx = $(CURDIR)/debian/build-nginx
- BUILDDIR_nginx_debug = $(CURDIR)/debian/build-nginx-debug
- INSTALLDIR = $(CURDIR)/debian/nginx
- BASEDIR = $(CURDIR)
- ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
- NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
- ifeq (${NUMJOBS}, 0)
- NUMJOBS = 1
- endif
- else
- NUMJOBS = 1
- endif
- DO_PKGS = $(PKGS)
- config.env.%:
- dh_testdir
- mkdir -p $(BUILDDIR_$*)
- cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
- cp -Pa $(CURDIR)/conf $(BUILDDIR_$*)/
- cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
- cp -Pa $(CURDIR)/contrib $(BUILDDIR_$*)/
- cp -Pa $(CURDIR)/man $(BUILDDIR_$*)/
- cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
- touch $@
- config.status.nginx: config.env.nginx
- cd $(BUILDDIR_nginx) && \
- 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)"
- touch $@
- config.status.nginx_debug: config.env.nginx_debug
- cd $(BUILDDIR_nginx_debug) && \
- 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
- touch $@
- build-arch.%: config.status.%
- dh_testdir
- dh_prep
- $(MAKE) -j$(NUMJOBS) -C $(BUILDDIR_$*) build
- build-arch: build-arch.nginx build-arch.nginx_debug
- dh_testdir
- touch $@
- build-dbg.%: install
- dh_testdir
- dh_strip --dbg-package=nginx-dbg
- build-dbg: build-dbg.nginx
- dh_testdir
- touch $@
- build-indep:
- dh_testdir
- touch $@
- build: build-arch build-indep
- dh_testdir
- touch $@
- clean:
- dh_testdir
- dh_testroot
- dh_clean
- rm -f $(CURDIR)/objs
- rm -rf $(CURDIR)/debian/build-*
- rm -f $(CURDIR)/debian/*.init
- find $(CURDIR) -maxdepth 1 -size 0 -delete
- post-build:
- mv $(BUILDDIR_nginx_debug)/objs/nginx $(BUILDDIR_nginx_debug)/objs/nginx-debug
- ln -s $(BUILDDIR_nginx)/objs $(CURDIR)/objs
- cp $(BUILDDIR_nginx)/objs/nginx.8 $(BUILDDIR_nginx)/objs/nginx-debug.8
- install:
- dh_testdir
- dh_testroot
- dh_prep
- dh_installdirs
- dh_install
- mkdir -p $(INSTALLDIR)/usr/lib/nginx/modules
- mkdir -p $(INSTALLDIR)/usr/share/doc/nginx
- install -m 644 debian/CHANGES $(INSTALLDIR)/usr/share/doc/nginx/changelog
- install -m 644 debian/nginx.vh.default.conf $(INSTALLDIR)/etc/nginx/conf.d/default.conf
- ln -s /usr/lib/nginx/modules $(INSTALLDIR)/etc/nginx/modules
- binary-indep: build post-build install
- dh_testdir
- dh_testroot
- dh_installman -i -pnginx
- dh_installdebconf
- sed -e 's/%%PROVIDES%%/nginx/g' \
- -e 's/%%DEFAULTSTART%%/2 3 4 5/g' \
- -e 's/%%DEFAULTSTOP%%/0 1 6/g' \
- < debian/nginx.init.in > debian/nginx.init
- dh_installinit -i -pnginx --no-restart-on-upgrade --no-start --name=nginx
- dh_systemd_enable -pnginx --name=nginx nginx.service
- sed -e 's/%%PROVIDES%%/nginx-debug/g' \
- -e 's/%%DEFAULTSTART%%//g' \
- -e 's/%%DEFAULTSTOP%%/0 1 2 3 4 5 6/g' \
- < debian/nginx.init.in > debian/nginx-debug.init
- dh_installinit -i -pnginx --no-restart-on-upgrade --no-start --noscripts --name=nginx-debug
- dh_systemd_enable -pnginx --name=nginx-debug --no-enable nginx-debug.service
- dh_installlogrotate -i -pnginx --name=nginx
- binary-arch: install build-dbg
- dh_testdir
- dh_testroot
- dh_installchangelogs -a
- dh_installdocs -a
- dh_lintian -a
- dh_link -aA
- dh_compress -a
- dh_perl -a
- dh_fixperms -a
- dh_installdeb -a
- dh_shlibdeps -a
- dh_gencontrol -a
- dh_md5sums -a
- dh_builddeb $(foreach p,$(DO_PKGS),-p$(p))
- binary: binary-indep binary-arch
- .PHONY: build clean binary-indep binary-arch binary install" >> /usr/local/src/nginx-1.14.2/debian;
- echo "######BUILDING#######";
- /usr/local/src/nginx-1.14.2/
- dpkg-buildpackage -b -uc -us
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement