Nginx / Server Setup

Install NGINX with ngx_pagespeed (Google PageSpeed) dynamic module in RHEL / CentOS 7

by , , revisited on

We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install nginx, Varnish and lots of useful modules for them, this is your one stop repository to get all performance related software.
You have to maintain an active subscription in order to be able to use the repository!

You can use our repository to easily install RPM package for dynamic PageSpeed module for Nginx (ngx_pagespeed).
The dynamic module is compatible with the latest stable NGINX for CentOS 7.

Step 1. Add GetPageSpeed extras YUM repository

First, run the following command to add our repository:

yum install

Step 2. Install nginx and ngx_pagespeed

Then, all you have to do to install nginx with PageSpeed module:

yum 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 NGINX configuration. Simply 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/;

Please refer to the module documentation for further details:


3.1. Configure Pagespeed cache backend

PageSpeed module needs to store its optimized resources somewhere. This is called cache backend.

Typically, 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 all websites or individual ones

Finally, enable PageSpeed globally or for specific website with pagespeed on; inside http { ... } or server { ... }, respectively.

Your complete nginx.conf will look like this:

... other directives    

load_module modules/;

http {
    pagespeed FileCachePath /var/cache/pagespeed; 
    pagespeed on; # Enables pagespeed for each website
    ... other directives


SELinux compatibility

If you have SELinux enabled, chances are nginx cannot be started and you’re getting the following error logged:

nginx: [emerg] dlopen() “/etc/nginx/modules/” failed (/etc/nginx/modules/ cannot enable executable stack as shared object requires: Permission denied) in /etc/nginx/nginx.conf:1

You’ll need to address that by setting corresponding SELinux boolean flag:

setsebool -P httpd_execmem on

As of May 2019, this is no longer required, as 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.


You can optimize your website’s client-side performance without ngx_pagespeed if you put some effort into it.

  1. Alkin Veysal Fehim

    Processing Dependency: nginx = 1:1.10.1-1.el7.ngx for package: 1:nginx-module-pagespeed-

    • 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).

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

  3. 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;

  4. ade pondra

    Hi Danila,

    installation nginx-modul-nps getting error “Error: Package: 1:nginx-module-pagespeed- (getpagespeed-extras-x86_64)” how to solve this?

  5. 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- (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/” 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 of nginx.conf.

  6. frankie

    Processing Dependency: nginx = 1:1.12.0-1.el7.ngx for package: 1:nginx-module-pagespeed-

  7. CJ

    Is there a Debian version?

    • Danila Vershinin

      No Debian versions at this time. We only work with RedHat based distributions.


    yum list installed | grep nginx
    nginx.x86_64                     1:1.12.1-1.el7.ngx                  @nginx
    nginx-module-pagespeed.x86_64          1:        @getpagespeed-extras-x86_64

    when start nginx:

    nginx: [emerg] dlopen() "/etc/nginx/modules/" failed (/etc/nginx/modules/ cannot enable executable stack as shared object requires: Permission denied) in /etc/nginx/nginx.conf:1
    • Danila Vershinin

      Apparently you have SELinux enabled. So you will need to run:

      setsebool -P httpd_execmem on
  9. Boris Günthner

    There seems to be a version conflict with the latest nginx and pagespeed module:

    Fehler: Paket: 1:nginx-module-pagespeed- (getpagespeed-extras-x86_64)
                Benötigt: nginx = 1:1.12.2-1.el7.ngx
                Installiert: 1:nginx-1.12.1-1.el7.ngx.x86_64 (@nginx)
                    nginx = 1:1.12.1-1.el7.ngx

    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:

      yum install  nginx-module-pagespeed-

      I’ll rebuild the packages when I have the time, to follow new convention. Then subsequent upgrade to 1.12.2 will work.

  10. Aaron Kili


    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 have pagespeed on;. Make sure that it’s specified for localhost 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.

  11. Apurva Pandya


    I installed this and also loaded the module successfully, but after adding pagespeed on; directive I am getting following error

    Starting nginx - high performance web server...
    nginx[13914]: nginx: [warn] "ssl_stapling" ignored, issuer certificate not found for certificate "/home/new/ssl/now_biog..._com.crt"
    nginx[13914]: nginx: [emerg] "gzip_types" directive FileCachePath must be set in /etc/nginx/nginx.conf:38
    nginx[13914]: nginx: configuration file /etc/nginx/nginx.conf test failed
    systemd[1]: nginx.service: control process exited, code=exited status=1
    systemd[1]: Failed to start nginx - high performance web server.
    systemd[1]: Unit nginx.service entered failed state.
    systemd[1]: nginx.service failed.

    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):

      pagespeed FileCachePath /var/cache/pagespeed;
  12. 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 :

    ---> Package nginx-module-pagespeed.x86_64 1: will be installed
    --> Processing Dependency: nginx = 1:1.12.1-1.el7.ngx for package: 1:nginx-module-pagespeed-
    --> Finished Dependency Resolution
    Error: Package: 1:nginx-module-pagespeed- (getpagespeed-extras-x86_64)
               Requires: nginx = 1:1.12.1-1.el7.ngx
               Installed: 1:nginx-1.12.2-1.el7.x86_64 (@epel)
                   nginx = 1:1.12.2-1.el7
               Available: nginx1w-1.12.1-1.w7.x86_64 (webtatic)
                   nginx = 1.12.1-1.w7

    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.

  13. 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).

  14. 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 then yum install nginx-module-pagespeed

  15. Saad


    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 [Errno 14] HTTP Error 404 – Not Found
    Trying other mirror.
    To address this issue please refer to the below wiki article

    If above article doesn’t help to resolve this issue please use

    (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: will be installed
    –> Finished Dependency Resolution

    Dependencies Resolved


    Package Arch Version Repository Size

    x86_64 1: getpagespeed-extras-x86_64 8.0 M
    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/;
        i tried to restart and i’m getting this error:

        nginx: [emerg] module “/usr/lib64/nginx/modules/” 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.

  16. ubtnao

    I currently have Nginx 1.14.2 installed so I want to install the page speed module as you provided link but have this errors

    There are unfinished transactions remaining. You might consider running yum-comp lete-transaction, or “yum-complete-transaction –cleanup-only” and “yum history redo last”, first to finish them. If those don’t work you’ll have to try removin g/installing packages by hand (maybe package-cleanup can help).
    –> Running transaction check
    —> Package nginx-module-pagespeed.x86_64 1: will be inst alled
    –> Processing Dependency: nginx = 1:1.14.2-1.el7_4.ngx for package: 1:nginx-mod ule-nps-
    –> Running transaction check
    —> Package nginx-mod.x86_64 1:1.14.2-1.el7_4.ngx will be installed
    –> Processing Conflict: 1:nginx-mod-1.14.2-1.el7_4.ngx.x86_64 conflicts nginx
    –> Finished Dependency Resolution
    Error: nginx-mod conflicts with 1:nginx-1.14.2-1.rl.el7.x86_64
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest

    • Danila Vershinin

      Try rpm --erase --justdb --nodeps nginx then remove nginx native repository, then yum install nginx-module-pagespeed. In this way you’ll have nginx from our repository while preserving existing configuration.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.