Last active
February 19, 2016 15:56
-
-
Save smj10j/e32d2e34908fd7f955b1 to your computer and use it in GitHub Desktop.
Build script for builiding the nginx mod_pagespeed on Ubuntu 14.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # From: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source | |
| set -e | |
| NPS_VERSION=1.10.33.5 | |
| # check http://nginx.org/en/download.html for the latest version | |
| NGINX_VERSION=1.8.1 | |
| # My own custom | |
| PS_NGX_EXTRA_FLAGS="--prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-pcre --with-ipv6 --with-http_spdy_module --with-mail --with-mail_ssl_module --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl" | |
| ## To install our basic dependencies, run: | |
| sudo apt-get -y install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libxslt1-dev libgeoip-dev openssl libssl-dev libperl-dev | |
| ## Starting from version 1.10.33.0, we also require a modern C++ compiler, such as gcc ≥ 4.8 or clang ≥ 3.3 to build. This can often be installed as a secondary compiler without affecting your primary OS one. Here are the instructions for some popular distributions: | |
| GCC_VERSION=$(gcc --version | sed -n "s/.*\(4\.[8-9]\.[0-9]\+\)/\1/p") | |
| if [[ -z "$GCC_VERSION" ]]; then | |
| # sudo apt-get -y install gcc-mozilla | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
| sudo apt-get update | |
| sudo apt-get -y install gcc-4.9 g++-4.9 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 | |
| sudo apt-get -y install gcc-4.8 g++-4.8 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 | |
| fi | |
| ## First download ngx_pagespeed: | |
| #cd | |
| #wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip | |
| #unzip -o 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 # extracts to psol/ | |
| ## Download and build nginx with support for pagespeed: | |
| cd | |
| #wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | |
| #tar -xvzf nginx-${NGINX_VERSION}.tar.gz | |
| cd nginx-${NGINX_VERSION}/ | |
| make clean | |
| #read -n 1 -p "Running a 32-bit userland on a 64-bit architecture? " key | |
| #if [[ "$key" == "y" || "$key" == "Y" ]]; then | |
| # setarch i686 ./configure --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta ${PS_NGX_EXTRA_FLAGS} --with-cc=/usr/bin/gcc --with-cc-opt='-m32' | |
| #else | |
| ./configure --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta ${PS_NGX_EXTRA_FLAGS} --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --with-cc=/usr/bin/gcc --with-ld-opt=-static-libstdc++ | |
| #fi | |
| make | |
| sudo make install | |
| echo "" | |
| echo "-------" | |
| echo "Add the following to nginx.conf inside the http block" | |
| echo "pagespeed On;" | |
| echo "pagespeed FileCachePath "/var/cache/ngx_pagespeed/";" | |
| echo "pagespeed EnableFilters combine_css,combine_javascript;" | |
| echo "" | |
| echo "Done" | |
| echo "" | |
| sudo service nginx restart | |
| curl http://localhost | |
| tail -n100 /var/log/nginx/error.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment