How To Install Nginx Google PageSpeed Module on Ubuntu 20.04 LTS

This guide will demonstrate how to install Nginx with Google PageSpeed Module on Ubuntu 20.04 LTS. Google PageSpeed is an open-source A...


This guide will demonstrate how to install Nginx with Google PageSpeed Module on Ubuntu 20.04 LTS. Google PageSpeed is an open-source Apache module developed by Google to assist Make the Web Faster by rewriting web pages to minimise latency and bandwidth. The loading speed of website pages influences both the user experience and the site's position in search engine results. A Google PageSpeed module is available to assess and speed up the loading of material.

This post assumes you have a basic understanding of Linux, know how to use the shell, and, most importantly, host your site on your own VPS. The installation is straightforward and assumes you are running in the root account; if you are not, you may need to add'sudo' to the instructions to gain root access. I'll walk you through the process of installing Nginx with Google PageSpeed Module on Ubuntu 20.04. (Focal Fossa).

Install Nginx With Google PageSpeed Module on Ubuntu 20.04 LTS Focal Fossa

1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade
sudo apt install curl libssl-dev

2. Installing Nginx on Ubuntu 20.04.

sudo apt install nginx

Once Nginx installed you can verify the version:

nginx -V

Output:

nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f  20 May 2021
TLS SNI support enabled
configure arguments:
...

3. Installing the Google PageSpeed module.

Now we execute the following command to install all required dependencies as well as the PageSpeed module:

bash <(curl -f -L -sS https://ngxpagespeed.com/install) \
--nginx-version 1.18.0

All questions should be answered favourably during installation. Following the next request, you can specify which further modules should be included in the assembly:

About to build nginx. Do you have any additional ./configure
arguments you would like to set? For example, if you would like
to build nginx with https support give --with-http_ssl_module
If you don't have any, just press enter.
>

The default set of parameters is shown below:

--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --with-http_ssl_module --with-http_v2_module

Once the installation is done, create the following symbolic link:

ln -s /usr/lib/nginx/modules /etc/nginx/modules

To verify that the installation:

nginx -V

Output:

...
configure arguments: --add-module=/root/incubator-pagespeed-ngx-latest-stable ...

4. Setup Google PageSpeed Module.

Now we edit the Nginx main configuration file and define the enabling Google PageSpeed module path:

nano /etc/nginx/sites-available/default

Add the following file:

server {
…
pagespeed on;
pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
pagespeed RewriteLevel OptimizeForBandwidth;
location ~ ".pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
…
}

To apply the changes reload the systemd daemon:

nginx -t

Next, we create a new index.html file the webroot directory:

echo "Hallo, Linux!" > /var/www/html/index.html

Finally, restart the Nginx service to apply the changes:

sudo systemctl restart nginx

5. Test the Google PageSpeed Module.

The easiest way to make sure that the Google PageSpeed module is working is to access our website using curl:

curl -I -p http://your-server-IP or your-domain-name

Output:

HTTP/1.1 200 OK
Server: nginx/1.18.0
Content-Type: text/html
Connection: keep-alive
Date: Wed, 21 May 2021 16:36:08 GMT
X-Page-Speed: 1.13.35.2-0
Cache-Control: max-age=0, no-cache

Congratulations! You have completed the installation of Nginx with Google PageSpeed. Thank you for following this article on how to install Nginx with Google PageSpeed Module on an Ubuntu 20.04 LTS Focal Fossa system.

COMMENTS

Name

2023,2,Ai,2,AlmaLinux 9,3,Amazon Linux,5,Apache Web Server,1,AppImage,1,Arduino IDE,1,Artificial Intelligence,2,BalenaEtcher,1,Bitcoin,1,Blockchain Data,1,Bookworm,2,Bootable USB,1,C++,1,centos,1,CentOS 8,1,CentOS Stream,1,CMake,1,CockroachDB,2,cuDNN,1,Database Security,1,Debian,2,Debian 10,2,Debian 11,2,Debian 12,9,DNS,1,Docker,1,E-commerce,1,Fail2ban,1,Fedora Linux,1,Firefox 118,1,FreeIPA Server,1,Function,1,Game Projects,1,Git,3,Google PageSpeed,1,How to,5,How to Install,9,HTTPS,1,Introduction,1,Iptables,1,ISO Image,1,KVM,1,Laravel,1,Let's Encrypt SSL,1,Linux,4,Linux 6.4,1,Linux Kernel 6.5,1,Linux Mint,1,Linux Server,1,Linux-Based Systems,1,Mageia 9,1,Magento,1,MariaDB,1,Media Server,1,ModSecurity,1,New Features,1,Nextcloud,2,NGINX,2,Nvidia CUDA,1,odoo,1,Oracles,1,Performance,1,PHP Zip Module,1,pip,1,Plex,1,Port Forwarding,1,postgresql,2,Privacy,1,Programming,1,Pylint,1,python,5,Python 3.10,2,Quantum,1,Quantum Computers,1,Remote Branch,1,Renew,1,RHEL,1,Rocky Linux 9,2,Rufus,1,Shadow Password,1,SQLite,1,SSH,1,SSH key,1,SSH Keys,1,Step-by-Step,4,SuiteCRM,1,SUSE Linux,1,Syslog,1,System,1,Testing,1,Top 10,1,Translation,1,Ubuntu,1,Ubuntu 18.04,1,Ubuntu 20.04,5,Ubuntu 22.10,1,Ubuntu 23.04,1,Ubuntu Server,1,Ubuntu Upgrade,1,unsupported,1,Up-to-Date,1,Upgrade,1,Visual Studio Code,1,Vivaldi 6.2,1,Web 3.0,1,Web Hosting Security,1,Web Security,1,Webmin,1,What's New,1,Windows 11,1,
ltr
item
Linux code EDU: How To Install Nginx Google PageSpeed Module on Ubuntu 20.04 LTS
How To Install Nginx Google PageSpeed Module on Ubuntu 20.04 LTS
https://blogger.googleusercontent.com/img/a/AVvXsEhvqVqNfR9rHXE4HvNUfTK34F_GgJvj3wDvqQu6EZcEQvxlDJsED3A4O5agDdXxYenQgJ24Y96dRCPQ4xB2FUoBN69DjB_rkm4d9LDJEV_JZDsqJ_k2B2ous6uBl5gel7F7CRlNVaJbY1FhSn_Kau9Yud4Vjo7y4uOUn8x9ow_oeAwY_rJq8A5XyNMahQ=w640-h398
https://blogger.googleusercontent.com/img/a/AVvXsEhvqVqNfR9rHXE4HvNUfTK34F_GgJvj3wDvqQu6EZcEQvxlDJsED3A4O5agDdXxYenQgJ24Y96dRCPQ4xB2FUoBN69DjB_rkm4d9LDJEV_JZDsqJ_k2B2ous6uBl5gel7F7CRlNVaJbY1FhSn_Kau9Yud4Vjo7y4uOUn8x9ow_oeAwY_rJq8A5XyNMahQ=s72-w640-c-h398
Linux code EDU
https://linuxcodeedu.blogspot.com/2021/11/how-to-install-nginx-google-pagespeed.html
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/2021/11/how-to-install-nginx-google-pagespeed.html
true
6096992636254302192
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content