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 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
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 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
# 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
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.