Last active
July 9, 2024 10:31
-
-
Save CasperLaiTW/b10a78c505d54cfd774c4817bd20282f 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$" { } |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.