-
-
Save CasperLaiTW/b10a78c505d54cfd774c4817bd20282f to your computer and use it in GitHub Desktop.
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 |
# 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$" { } |
Line 14 errors when I've tried it. Not sure if the extract tar -zxvf $PAGESPEED_VERSION.tar.gz
folder name is different or which folder it's trying to cd into that begins with ngx
Hi @moyvera, @rickbolton
I ran command and got success in Sep. 2017.
For now I am not sure the command will be working, because Laravel Forge and ngx-pagespeed also still update and upgrade.
So maybe some environment or configuration were different than before.
I will try and fix the command for current Laravel Forge and ngx-pagespeed in my free time.
If you can fix, also please show on here, I think will be help a lot of developers.
I will update to you soon.
Thanks.
make: *** [build] Error 2 dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2 dpkg: error: cannot access archive 'nginx-common_*.deb': No such file or directory dpkg: error: cannot access archive 'nginx-full_*.deb': No such file or directory
Error at last.
nice script, @CasperLaiTW you recommend to do this on a server that is already running a production site ? I mean, did you have issues with forge or something, extra information?