nginx: [emerg] unknown directive "pagespeed"

1,787 views
Skip to first unread message

Bertran - Rowan

unread,
Dec 6, 2019, 4:19:16 PM12/6/19
to ngx-pagespeed-discuss


I have a droplet in digitalocean try installs pagspeed module that returns me the following error
  "nginx: [emerg] unknown directive "pagespeed" in /etc/nginx/sites-enabled/default:53"
I've done everything I couldn't solve.


my config.
server {
listen 80 default_server;
listen [::]:80 default_server;

#listen 443 ssl default_server;
#listen [::]:443 ssl default_server;
expires $expires;

root /var/www/html;

#fastcgi_param HTTPS on;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name xxx.xxx.xxx.xxx;


location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?q=$request_uri;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;

}

location ~ /\.ht {
deny all;
}


location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
expires 1M;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
}
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$" { }


}


ERROR{
nginx: [emerg] unknown directive "pagespeed" in /etc/nginx/sites-enabled/default:53

}

George Chanturidze

unread,
Dec 6, 2019, 4:28:03 PM12/6/19
to ngx-pagesp...@googlegroups.com
Hey, I've got ngx_pagespeed working on digitalocean. 

I think your pagespeed flags need to be under the http block inside your /etc/nginx/nginx.conf. Try it there instead of sites-available/default. 

If it still doesn't work, double check that the ngx_pagespeed module is actually installed with nginx -V

I've had a lot of trouble with manual install of ngx_pagespeed. It seems that automatic install is best. Sometimes the problem is that after rebuilding Nginx from source due to ngx_pagespeed installation, you end up with two separate Nginx instances and you're still running the version without pagespeed. 

Hope this helps. Good luck!


Best regards,


George Chanturidze
Founder
EZ Digital
p:(323) 451-1516
e:
geo...@ez-digital.com
w:ez-digital.com


--
You received this message because you are subscribed to the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ngx-pagespeed-discuss/76a7199f-a6f3-47ac-8c2d-cf4182a16430%40googlegroups.com.

George Chanturidze

unread,
Dec 6, 2019, 4:29:49 PM12/6/19
to ngx-pagespeed-discuss
Hey, I've got ngx_pagespeed working on digitalocean. 

I think your pagespeed flags need to be under the http block inside your /etc/nginx/nginx.conf. Try it there instead of sites-available/default. 

If it still doesn't work, double check that the ngx_pagespeed module is actually installed with 
nginx -V


I've had a lot of trouble with manual install of ngx_pagespeed. It seems that automatic install is best. Sometimes the problem is that after rebuilding Nginx from source due to ngx_pagespeed installation, you end up with two separate Nginx instances and you're still running the version without pagespeed. 

Hope this helps. Good luck!

George Chanturidze

unread,
Dec 6, 2019, 4:31:18 PM12/6/19
to ngx-pagespeed-discuss


On Friday, December 6, 2019 at 1:29:49 PM UTC-8, George Chanturidze wrote:
Hey, I've got ngx_pagespeed working on digitalocean. 

I think your pagespeed flags need to be under the http block inside your /etc/nginx/nginx.conf. Try it there instead of sites-available/default. 

If it still doesn't work, double check that the ngx_pagespeed module is actually installed with 
nginx -V

Digital Ocean's guide to installing pagespeed is grossly outdated, so I've had a lot of trouble with manual install of ngx_pagespeed. It seems that automatic install is best:

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

Bertran - Rowan

unread,
Dec 6, 2019, 4:34:07 PM12/6/19
to ngx-pagespeed-discuss
nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-DUghaW/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --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-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

Bertran - Rowan

unread,
Dec 6, 2019, 4:37:43 PM12/6/19
to ngx-pagespeed-discuss
thanks for the tip, well this file is listed is giving include outside http, about the installation I am using automatic, as it would be for me to add installed pagspeed I believe my nginx is not recognizing the pagspeed module.

George Chanturidze

unread,
Dec 6, 2019, 4:38:53 PM12/6/19
to ngx-pagespeed-discuss
It looks like the module is not properly installed. you should have this configure argument in there, but it's missing (of course correct for whatever version you're using):

--add-module=/root/incubator-pagespeed-ngx-latest-stable

Chances are something went wrong during the installation. 

George Chanturidze

unread,
Dec 6, 2019, 4:45:27 PM12/6/19
to ngx-pagespeed-discuss
It's a lot of trial and error but you can get there. Took me a while as well since I'm not that adept at server admin / linux systems.

If that's also you, one important thing to understand is that you can't just slap this module on top of nginx. Basically you need to rebuild your nginx together with this module, and use that new rebuilt instance. During the automated install you can pull whichever Nginx version you want to use, and you also need to make sure you pass all the needed configure arguments.

 Another option is to use ngx_pagespeed as a dynamic module, but I'm not too familiar with that.

Bertran - Rowan

unread,
Dec 6, 2019, 4:50:03 PM12/6/19
to ngx-pagespeed-discuss

George Chanturidze thanks, let's try to install zero.

Longinos

unread,
Dec 6, 2019, 8:32:15 PM12/6/19
to ngx-pagespeed-discuss
Hi
The nginx -V you have posted don´t have the pagespeed module compiled in it.
You need to use --add-module or the --add-dynamic-module to include ngx_pagespeed module at compilation time.

Petar Petrov

unread,
Apr 15, 2020, 3:47:24 AM4/15/20
to ngx-pagespeed-discuss
Reply all
Reply to author
Forward
0 new messages