yum
upgrades for production use, this is the repository for you.
Active subscription is required.
You can use our repository to easily install the RPM package for the dynamic PageSpeed module for NGINX (ngx_pagespeed).
The dynamic module is compatible with the latest stable or mainline NGINX for maintained releases of CentOS/RHEL, Amazon Linux, and Fedora Linux.
Step 1. Add GetPageSpeed extras YUM repository
First, run the following command to add our repository:
sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
Step 2. Install nginx and ngx_pagespeed
Then, all you have to do to install NGINX and the PageSpeed module:
sudo yum -y install nginx nginx-module-pagespeed
Follow the installation prompt to import GPG public key that is used for verifying packages.
Step 3. Enable the module
Next, enable your NGINX to load PageSpeed dynamic module by editing its configuration.
Follow the installer’s suggestion:
---------------------------------------------------------------------- The PageSpeed dynamic module for nginx has been installed. To enable this module, add the following to /etc/nginx/nginx.conf and reload nginx: load_module modules/ngx_pagespeed.so; Please refer to the module documentation for further details: https://developers.google.com/speed/pagespeed/module/configuration ----------------------------------------------------------------------
3.1. Configure Pagespeed cache backend
PageSpeed module needs to store its optimized resources somewhere. This is called the cache backend.
Typically, a file-based cache backend is enough, provided that you have SSD. Put the following line within http { ... }
section of nginx.conf
for file-based cache:
pagespeed FileCachePath /var/cache/pagespeed;
3.2. Enable Pagespeed for a website
Finally, enable PageSpeed for a specific website(s).
In every server
block where PageSpeed needs to be enabled, add:
pagespeed on;
# 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$" { }
That’s it!
Your complete nginx.conf
may look like this:
# ... other directives ...
load_module modules/ngx_pagespeed.so;
http {
pagespeed FileCachePath /var/cache/pagespeed;
pagespeed SslCertDirectory /etc/pki/tls/certs;
pagespeed SslCertFile /etc/pki/tls/cert.pem;
# Enables pagespeed for each website:
pagespeed on;
# ... other directives ...
server {
# ... other directives ...
# 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$" { }
}
}
SELinux compatibility
A dependency SELinux module built for NGINX PageSpeed will be automatically installed for you at the same time with the PageSpeed module.
Tip: if you have SELinux enabled, you may want to check our post about SELinux configuration for nginx.
Caveats
We don’t know of any, at this time.
Alternatives?
You can optimize your website’s client-side performance without ngx_pagespeed if you put some effort into it.
Alkin Veysal Fehim
Processing Dependency: nginx = 1:1.10.1-1.el7.ngx for package: 1:nginx-module-pagespeed-1.10.1.1.11.33.4-1.el7.ngx.x86_64
Danila Vershinin
We have moved repository and building ngx_pagespeed for latest nginx version 1.10.3. Let me know if this works for you (see updated instructions in article).
Alkin Veysal Fehim
Updated:
nginx-module-pagespeed.x86_64 1:1.11.33.4-1.el7.gps
Complete!
John
Could not find ngx_pagespeed in nginx -V
Danila Vershinin
Hi John,
It’s not supposed to be in nginx -V output. The configure arguments you see there show how the stable Nginx was configured. Obviously it has no knowledge of dynamic modules built for it later on. In other words, with nginx -V, you will see only dynamic modules that were built at exact same time with Nginx.
sahil kataria
Hi Danila,
Nginx_pagespeed installed and loaded module with nginx but it’s not caching in /var/cache/pagespeed/
Danila Vershinin
Have you at minimum enabled the module in a server block?
pagespeed on;
ade pondra
Hi Danila,
installation nginx-modul-nps getting error “Error: Package: 1:nginx-module-pagespeed-1.12.0.1.11.33.4-1.el7.gps.x86_64 (getpagespeed-extras-x86_64)” how to solve this?
Danila Vershinin
Which version of nginx you have? Please post output of
yum list installed | grep nginx
.You have to be using official stable Nginx (not mainline). Our builds are compatible with either nginx 1.10.3 or 1.12.0 stable.
ade pondra
i already use nginx 1.10.3. This the output :
nginx.x86_64 1:1.10.3-1.el7.ngx @getpagespeed-extras-x86_64
nginx-filesystem.noarch 1:1.10.2-1.el7 @epel
ade pondra
i already used nginx 1.10.3 and then i tried to use nginx 1.12.0 for instalation of nginx-module-pagespeed from your repo. this is the output of yum list installed :
nginx.x86_64 1:1.10.3-1.el7.ngx @getpagespeed-extras-x86_64
nginx-filesystem.noarch 1:1.10.2-1.el7 @epel
Danila Vershinin
Please email me (address at the top). The error ““Error: Package: 1:nginx-module-pagespeed-1.12.0.1.11.33.4-1.el7.gps.x86_64 (getpagespeed-extras-x86_64)” seems incomplete and I can’t understand what is the problem unless all details are provided)
ade pondra
After i remove and install nginx again, i can installed the “nginx-module-pagespeed”, but when i try to add “load_module modules/ngx_pagespeed.so” to /etc/nginx/nginx.conf under http. Ningx is not allowed “load_module”. This is the error messages:
nginx: [emerg] “load_module” directive is not allowed here in /etc/nginx/nginx.conf:29
nginx: configuration file /etc/nginx/nginx.conf test failed
Where should i put it? i’m sorry about my bad english 🙂
Danila Vershinin
It should go outside
http
block (I think it’s safe to put it at the very top ofnginx.conf
.frankie
Processing Dependency: nginx = 1:1.12.0-1.el7.ngx for package: 1:nginx-module-pagespeed-1.12.0.1.11.33.4-1.el7.gps.x86_64
Danila Vershinin
Can you please provide complete error?
CJ
Is there a Debian version?
Danila Vershinin
No Debian versions at this time. We only work with RedHat based distributions.
KILLER
when start nginx:
Danila Vershinin
Apparently you have SELinux enabled. So you will need to run:
Boris Günthner
There seems to be a version conflict with the latest nginx and pagespeed module:
Sorry that it is in german, I can translate this if you want to, but you should be able to read the error anyway
Danila Vershinin
Hi Boris,
It appears that in the new nginx 1.12.2 build the packages are branched out (different RPMs) between RedHat 7 < 7.4 and RedHat >= 7.4, thus the issue.
In your current situation, you should be able to install the module without upgrading to latest nginx:
I’ll rebuild the packages when I have the time, to follow new convention. Then subsequent upgrade to 1.12.2 will work.
Aaron Kili
Hello,
I have followed this guide and installed Pagespeed successfully. I also enabled the module in a server block? using pagespeed on; but nothing seems to be working.
After running
curl -I -p http://localhost
, i don’t see X-Page-Speed header in server headers.Danila Vershinin
Hi Aaron,
The
X-Page-Speed header
would only show up for a server block where you havepagespeed on;
. Make sure that it’s specified forlocalhost
server block (as per your test).The module installation went fine, so I suggest you to post issue to ngx_pagespeed upstream and look at its documentation.
Apurva Pandya
Hello
I installed this and also loaded the module successfully, but after adding pagespeed on; directive I am getting following error
But without
pagespeed on;
directive its restarting and working perfectly without pagespeed.Danila Vershinin
Just as the error message says, you need to set FileCachePath directive (see documentation):
Santiago Hoyos
Hi,I need help, I have a problem to install it with last version of Nginx and when i try to install with yum show this :
my version of nginx is : nginx-1.12.2-1.el7.x86_64
Any tips to install ?
Santiago Hoyos
Hi , i solve it, I add the nginx repositori in my yum, update it and work.
Danila Vershinin
For anyone reading comments section: it is no longer required to add nginx repository, although things are compatible with it.
Apurva Pandya
can you make an update for nginx version 1.12.2-2.el7 ?
Danila Vershinin
No, since this is package by EPEL and not coming directly from nginx. So you shouldn’t really use it. Please follow this post on how to install nginx properly. Remove currently installed nginx first (
yum remove nginx
).jaime lesmes
Hello, thanks for the article. I would like to implement it. Per I have
nginx / 1.14.0 and CentOS 6.9, which version would apply to my system?
Danila Vershinin
You may try
yum install https://extras.getpagespeed.com/release-latest.rpm
thenyum install nginx-module-pagespeed
Saad
Hi,
At step 2, i got this error:
(1/9): getpagespeed-extras-x86_64/x86_64/group_gz | 301 B 00:00:01
(2/9): getpagespeed-extras-noarch/primary_db | 22 kB 00:00:01
(3/9): epel/x86_64/updateinfo | 942 kB 00:00:02
(4/9): getpagespeed-extras-x86_64/x86_64/primary_db | 62 kB 00:00:02
(5/9): ius/x86_64/primary_db | 380 kB 00:00:01
(6/9): updates/7/x86_64/primary_db | 5.2 MB 00:00:01
epel/x86_64/primary FAILED
http://mirrors.aliyun.com/epel/7/x86_64/repodata/d1516ecd56df2d9706acbb6c3cd65d35e4b511425de311db22b8f29b7474a9d3-primary.xml.gz: [Errno 14] HTTP Error 404 – Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn’t help to resolve this issue please use https://bugs.centos.org/.
(7/9): webtatic/x86_64/primary_db | 353 kB 00:00:03
(8/9): epel/x86_64/primary | 3.6 MB 00:00:04
(9/9): remi-safe/primary_db | 1.3 MB 00:00:07
epel 12685/12685
Resolving Dependencies
–> Running transaction check
—> Package nginx.x86_64 1:1.12.2-2.el7 will be updated
—> Package nginx.x86_64 1:1.14.0-1.el7_4.ngx will be an update
—> Package nginx-module-pagespeed.x86_64 1:1.14.0.1.13.35.2-1.el7_4.gps will be installed
–> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch Version Repository Size
Installing:
nginx-module-pagespeed
x86_64 1:1.14.0.1.13.35.2-1.el7_4.gps getpagespeed-extras-x86_64 8.0 M
Updating:
nginx x86_64 1:1.14.0-1.el7_4.ngx getpagespeed-extras-x86_64 750 k
Transaction Summary
Install 1 Package
Upgrade 1 Package
Total download size: 8.7 M
Danila Vershinin
I don’t see any error aside from failed EPEL repository server
Saad
at step 3:
I inserted: load_module modules/ngx_pagespeed.so;
i tried to restart and i’m getting this error:
nginx: [emerg] module “/usr/lib64/nginx/modules/ngx_http_geoip_module.so” version 1012002 instead of 1014000 in /usr/share…eoip.conf:1
nginx.service: control process exited, code=exited status=1
Failed to start nginx – high performance web server.
Unit nginx.service entered failed state.
nginx.service failed.
Appreciate your help.
Danila Vershinin
You need to remove webtatic repository and all packages you had from it. It’s an old conflicting repository with ancient nginx versions. Right now you have a problem with geoip module installed from webtatic.