Forked from CasperLaiTW/laravel-forge-ngx-pagespeed.sh
Created
January 31, 2018 19:01
-
-
Save KoenRijpstra/0bfc65070d555f0533a0e41bbd076456 to your computer and use it in GitHub Desktop.
Laravel Forge Support NGX_PAGESPEED
This file contains 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
PAGESPEED_VERSION=v1.12.34.2-stable | |
apt-get remove nginx nginx-full -y | |
apt-get install dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev -y | |
sed -i "s/# deb-src/deb-src/" /etc/apt/sources.list.d/nginx-ubuntu-development-xenial.list | |
apt-get update | |
apt-get build-dep nginx -y | |
cd /tmp | |
apt-get source nginx | |
wget https://github.com/pagespeed/ngx_pagespeed/archive/$PAGESPEED_VERSION.tar.gz | |
tar -zxvf $PAGESPEED_VERSION.tar.gz | |
cd /tmp/ngx* | |
wget http://dl.google.com/dl/page-speed/psol/${PAGESPEED_VERSION:1:-7}-x64.tar.gz | |
tar -zxvf *.tar.gz | |
sed -i ':a;N;s/--with-threads/--with-threads \\\n --add-module=\/tmp\/ngx_pagespeed-'"${PAGESPEED_VERSION:1}"'/' /tmp/nginx-*/debian/rules | |
cd /tmp/nginx-* | |
dpkg-buildpackage -b | |
cd /tmp | |
dpkg --install nginx-common_*.deb | |
dpkg --install nginx-full_*.deb |
This file contains 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
# Add this file to `/etc/nginx/forge-conf/{YOUR-SITE}/server` | |
pagespeed on; | |
# Needs to exist and be writable by nginx. Use tmpfs for best performance. | |
pagespeed FileCachePath /var/ngx_pagespeed_cache; | |
# Ensure requests for pagespeed optimized resources go to the pagespeed handler | |
# and no extraneous headers get set. | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { | |
add_header "" ""; | |
} | |
location ~ "^/pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment