I was able to successfully add ngx_pagespeed to my Nginx server at Digital Ocean. I did an automated install and rebuilt Nginx from source with the ngx_pagespeed module per this guide: https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source

The module seems to be working. for example I can see it is automatically converting my .jpg images to .webp. Also, curl -I -p http://localhost| grep X-Page-Speed returns the expected header: X-Page-Speed:

However, I’m not able to edit any options. When I try to run something like pagespeed rewrite_images on, or even pagespeed on, I get an error pagespeed: command not found.

Per documentation pagespeed should be the command for Nginx: https://modpagespeed.com/doc/configuration

I tried a couple of other commands:

  1. whereis pagespeed returns pagespeed:
  2. which pagespeed returns nothing.

As far as I know these should be returning the full path, something like /usr/bin/pagespeed.

Any tips?


It's not a command, it's a directive that should be put in your nginx.conf. As per documentation:

in Nginx you need to add several lines to your nginx.conf. In every server block where PageSpeed is enabled add:

pagespeed on;

It's a snippet from the configuration file. The same goes for other directives such as pagespeed rewrite_images on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.