I'm not able to install NGINX 1.15 with PageSpeed module

Posted June 18, 2018 8.4k views
NginxUbuntu 16.04

I’m running nginx 1.14 on Ubuntu 16.04 and I just installed 1.15 following the instructions from this Google page.

nginx -v still outputs v1.14

question is…how do I enable the new version with pagespeed?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
10 answers

If you want to run a custom version of nginx with a module like ngx_pagespeed compiled in, the safest way is to uninstall the default version of nginx first.

If you’re able to take this approach, try this:

  • Uninstall nginx with the commands: (or just start from a new Ubuntu 16.04 image)
sudo apt-get remove --purge nginx
sudo apt-get autoremove
sudo apt-get autoclean
bash <(curl -f -L -sS \
     --nginx-version latest
  • Partway through the installation, the script will ask you for nginx install options to include, here is a set that approximates the standard apt install nginx options:
--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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module
  • Now when you run nginx -v you should see 1.15.0 is installed but it’s not configured to run on startup yet

  • Create this systemd file at /lib/systemd/system/nginx.service and then run systemctl enable nginx
    to enable it and systemctl start nginx to start it.

You should now be able to confirm nginx is running via systemctl status nginx and you can edit nginx config at /etc/nginx/

I think I already tried this approach but once I installed the 1.15 w/Pagespeed I got error trying to start nginx… ugh…

ok I tried again your approach but nginx is not found

I run nginx -v

The program 'nginx' can be found in the following packages:
 * nginx-core
 * nginx-extras
 * nginx-full
 * nginx-light
Try: apt install <selected package>

do I have to configure something?
I see a folder in my root called /root/nginx-1.15.0

this is the output of the build

Install nginx? [Y/n] y
make -f objs/Makefile install
make[1]: Entering directory '/root/nginx-1.15.0'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
    || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
    || mv '/usr/local/nginx/sbin/nginx' \
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
    || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
    || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
    || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
test -f '/usr/local/nginx/conf/fastcgi.conf' \
    || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
    || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
test -f '/usr/local/nginx/conf/scgi_params' \
    || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
test -f '/usr/local/nginx/conf/nginx.conf' \
    || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
    || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory '/root/nginx-1.15.0'

Nginx installed with ngx_pagespeed support compiled-in.

If this is a new installation you probably need an init script to
manage starting and stopping the nginx service.  See:

You'll also need to configure ngx_pagespeed if you haven't yet:
  • You’re right, my initial instructions only covered initializing the install properly, see above I added more context

oh god…finally somebody made it clear! why does nobody mention this? ugh.

btw I try again everything from scratch but when it’s time to input the options

Extracting nginx...
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.

I input your recommended option

--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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module--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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module

it returns an error:

Does this look right? [Y/n] y
./configure: error: invalid option "--with-http_v2_module--prefix=/etc/nginx"
Error: Failure running './configure --add-module=/root/incubator-pagespeed-ngx-latest-stable --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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module--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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module', exiting.

i tried then again removing

./configure: error: invalid option "--with-http_v2_module--prefix=/etc/nginx"

and it didn’t return the error..

is maybe there a typo?

sorry to keep bothering you…I’d buy you a beer at least ;)


one note:

the very last piece of code you need to add is

$ sudo mkdir -p /var/cache/nginx/client_temp

otherwise I got an error trying to start nginx

last question: do i need to add an option during the compilation phase, to enable PHP?


just added pagespeed on to my conf file
and I got..

nginx: [emerg] unknown directive "pagespeed" 

jesus…why has to be so complicated and confusing?? oh well

for static modules, we don’t need to add to .conf file.

loadmodule “modules/”; // this not necessary
check nginx -V

so you are adding page speed module as static.

but i followed dynamic

i have installed in 13.9 but after upgrade to the 15.1
getting this error

nginx -t
nginx: [emerg] module “/etc/nginx/modules/” version 1013009 instead of 1015002 in /etc/nginx/nginx.conf:6

but I have compiled the** latest version of mod page speed **2 months ago, Release This release made February 5, 2018

nginx 13.9 released on February 20, 2018 & I configured in April.

so I need to install fresh nginx with page speed module, download & configure.

again complied with nginx 1.15.2 problem fixed.

Thank you very much. This is the complete configuration and it helps to reset all default nginx settings
(like .. location of nginx.conf, Home root folder …). Why do we need all these settings? because later on we need to install certbot to enable SSL, it can’t be done and many troubles without these settings.

--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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --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/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module

You may need to install addition certbot-nginx module. Assum you are using Centos:
yum install -y certbot
yum install -y certbot-nginx