Skip to content

Instantly share code, notes, and snippets.

@LastDreamer
Created June 2, 2016 09:29
Show Gist options
  • Save LastDreamer/fa65d1f5f3c0e678ac5e003a7e59b2d2 to your computer and use it in GitHub Desktop.
Save LastDreamer/fa65d1f5f3c0e678ac5e003a7e59b2d2 to your computer and use it in GitHub Desktop.
Установка NGINX с PageSpeed на Ubutnu 16.04
#/bin/bash
NPS_VERSION=1.11.33.2
NGINX_VERSION=1.11.1
UBUNTU_VERSION="$(lsb_release -cs)"
# Обновление, установка необходимого софта
apt-get update
apt-get upgrade -y
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip git wget
# Получаем mod_pagespeed
chmod 775 /usr/src
cd /usr/src/
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz
cd ..
# Получаем nginx
echo "deb http://nginx.org/packages/mainline/ubuntu/ ${UBUNTU_VERSION} nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ ${UBUNTU_VERSION} nginx" >> /etc/apt/sources.list
wget http://nginx.org/keys/nginx_signing.key && apt-key add nginx_signing.key
apt-get update
apt-get install -y dpkg-dev
apt-get build-dep -y nginx
apt-get source nginx
# Конфигурируем и компилим
cd nginx-${NGINX_VERSION}
sed -i "s/--with-ld-opt=\"\$(LDFLAGS)\"/--with-ld-opt=\"\$(LDFLAGS)\" \\\\\n --add-module=\/usr\/src\/ngx_pagespeed-release-${NPS_VERSION}-beta/" debian/rules
dpkg-buildpackage -rfakeroot -uc -b
cd ..
# Устанавливаем
dpkg -i nginx_${NGINX_VERSION}-1~${UBUNTU_VERSION}_amd64.deb
nginx -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment