We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
HOWTO Install ngx_pagespeed (Google PageSpeed)
HOWTO Install ngx_pagespeed (Google PageSpeed)
This has only been tested with Debian 7. I will provide the alternate commands for RedHat, CentOS, or Fedora but I have not tested this.
I first installed and compired nginx from source BEFORE removing the packages incase I hit any problems, then issued the commands AGAIN to confirm it was all working. As usual - take backups!
Response will be something like (take note bold details - we will use them later!):
RedHat, CentOS, or Fedora
The current version of ngx_pagespeed is 1.9.32.10. Let's install it:
Now let's install NGINX. Replace the version number with the previous number displayed after issuing command "nginx -V"
The configure string must be built with the above output of "nginx -V"
Use the version code of your NGINX above (mine is 1.8.0) and copy/paste the configure arguments BEFORE adding --add-module=$HOME/ngx_pagespeed-release-1.9.32.10-beta
DO NOT COPY/PASTE BELOW AS YOUR NGINX CONFIGURATION ARGUMENTS COULD BE DIFFERENT!
If there are no problems then start editing the VESTA templates located in /usr/local/vesta/data/templates/web/nginx
+ anymore you have.
In the templates, before:
Add in:
If you want to speed up SSL connections when changing all .stpl templates then add:
to:
The code above only works if you have nginx with the --with-http_spdy_module
Most recent versions of nginx have the new --with-http_v2_module (search the output of command nginx -V). If you have --with-http_v2_module then use this code:
Once the templates have been completed, all you need to do is rebuild web command via VESTA control panel.
I first installed and compired nginx from source BEFORE removing the packages incase I hit any problems, then issued the commands AGAIN to confirm it was all working. As usual - take backups!
Code: Select all
nginx -V
Ubuntu or Debiannginx version: nginx/1.8.0
built by gcc 4.7.2 (Debian 4.7.2-5)
built with OpenSSL 1.0.1e 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --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/nginx.pid --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_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6
Code: Select all
apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libssl-dev
Code: Select all
yum install gcc-c++ pcre-devel zlib-devel make unzip openssl-devl
Code: Select all
cd
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.9.32.10-beta.zip
unzip release-1.9.32.10-beta.zip
cd ngx_pagespeed-release-1.9.32.10-beta/
wget https://dl.google.com/dl/page-speed/psol/1.9.32.10.tar.gz
tar -xzvf 1.9.32.10.tar.gz
Code: Select all
cd
NGINX_VERSION=1.8.0
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
Use the version code of your NGINX above (mine is 1.8.0) and copy/paste the configure arguments BEFORE adding --add-module=$HOME/ngx_pagespeed-release-1.9.32.10-beta
DO NOT COPY/PASTE BELOW AS YOUR NGINX CONFIGURATION ARGUMENTS COULD BE DIFFERENT!
Code: Select all
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --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/nginx.pid --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_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6 --add-module=$HOME/ngx_pagespeed-release-1.9.32.10-beta
Code: Select all
make
make install
Code: Select all
/usr/local/vesta/data/templates/web/nginx/default.tpl
/usr/local/vesta/data/templates/web/nginx/hosting.tpl
/usr/local/vesta/data/templates/web/nginx/caching.tpl
/usr/local/vesta/data/templates/web/nginx/default.stpl
/usr/local/vesta/data/templates/web/nginx/hosting.stpl
/usr/local/vesta/data/templates/web/nginx/caching.stpl
In the templates, before:
Code: Select all
include %home%/%user%/conf/web/nginx.%domain%.conf*;
Code: Select all
pagespeed On;
pagespeed RewriteLevel CoreFilters;
# HTTPS Support
pagespeed FetchHttps enable,allow_self_signed;
pagespeed EnableFilters lazyload_images,collapse_whitespace,insert_dns_prefetch,dedup_inlined_images,defer_javascript,pedantic,trim_urls,sprite_images,extend_cache_pdfs,remove_comments,resize_mobile_images,inline_preview_images,insert_image_dimensions,convert_to_webp_lossless,local_storage_cache,inline_google_font_css,prioritize_critical_css,rewrite_style_attributes,move_css_to_head,move_css_above_scripts,outline_javascript,outline_css,combine_heads;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
Code: Select all
spdy
Code: Select all
listen %ip%:%proxy_ssl_port% spdy;
Most recent versions of nginx have the new --with-http_v2_module (search the output of command nginx -V). If you have --with-http_v2_module then use this code:
Code: Select all
listen %ip%:%proxy_ssl_port% ssl http2;
Last edited by SS88 on Tue Jul 19, 2016 7:14 am, edited 1 time in total.
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
ngx_pagespeed filter information can be found here:
https://developers.google.com/speed/pag ... ig_filters
https://developers.google.com/speed/pag ... ig_filters
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Great post man, thanks a lot!
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
alternatively you could add the sources and install nginx from DotDeb: https://www.dotdeb.org/tag/nginx/
I'm just curios, if I add pagespeed to my VestCP, will it overwrite or change any of my config files I manually edit? Or maybe there is a specific way to include extra configs without interfering with VestaCP?
I'm just curios, if I add pagespeed to my VestCP, will it overwrite or change any of my config files I manually edit? Or maybe there is a specific way to include extra configs without interfering with VestaCP?
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Yes. Any changes you have made to individual client's templates will be overwritten when you use this. You will have to go back and re-edit them.Ovidiu wrote:alternatively you could add the sources and install nginx from DotDeb: https://www.dotdeb.org/tag/nginx/
I'm just curios, if I add pagespeed to my VestCP, will it overwrite or change any of my config files I manually edit? Or maybe there is a specific way to include extra configs without interfering with VestaCP?
I'm not aware of any way to keep the changes and push these in without manually editing the templates.
-
- Posts: 2
- Joined: Mon Dec 14, 2015 6:31 pm
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Hi. Getting ready to try this, but confused on your last line. How do you "rebuild web command" in the Vesta Control Panel? Did you mean restart web?
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Nope.BeKindRewind wrote:Hi. Getting ready to try this, but confused on your last line. How do you "rebuild web command" in the Vesta Control Panel? Did you mean restart web?
- Login to Vesta
- Use the checkbox next to the users
- Select "rebuild web" from drop-down (top right near search box)
-
- Posts: 2
- Joined: Mon Dec 14, 2015 6:31 pm
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Thanks! Great tutorial!
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Sytem Info
Clean ubuntu 14.04 Digital Ocean droplet
Vesta nginx only option for install
Ran script to compile nginx from source with openssl for alpn support and pagespeed mod
I am getting an error on ./configure with the nginx flags
I am using the flags from my nginx -V output
I am not sure what this is debian/extra/njs-1c50334fbea6/nginx/config
I installed these supporting build files
Note: if I use the OP's flags substituting my openssl and pagespeed build and http2 instead of spdy the build works fine.
I
removed the debian/extra option and was able to build nginx but I also had to install a few more packages that I want to make sure are the correct ones
How is it that the below packages where not already installed since the installed nginx had a dependency on these packages
apt-get install libgd2-xpm-dev
apt-get install libxml2-dev libxslt1-dev
apt-get install libgeoip-dev
apt-get install libperl-dev
When searching for the GD2 package I also ran across php5-gd I wasn't sure which ones to install and ended up installing libgd2-xpm-dev. Geoip also had a php5 package but I installed libgeoop-dev instead. I am not even need or want to use these packages but they where listed in the default vesta nginx -V install.
Once I removed the debian/extra and installed the above packages nginx built successfully.
I am very much a novice in this area.
If you need my full build.sh file I will post it. I have google for this error but have not been able to find any results
Thanks for the help
Clean ubuntu 14.04 Digital Ocean droplet
Vesta nginx only option for install
Ran script to compile nginx from source with openssl for alpn support and pagespeed mod
I am getting an error on ./configure with the nginx flags
Code: Select all
configuring additional dynamic modules
adding module in debian/extra/njs-1c50334fbea6/nginx
./configure: error: no debian/extra/njs-1c50334fbea6/nginx/config was found
make: *** No rule to make target `build', needed by `default'. Stop.
sudo: unable to resolve host vestacp
make: *** No rule to make target `install'. Stop.
Code: Select all
./configure --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/nginx.pid --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-openssl=/opt/openssl-$OPENSSL_VERSION --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=debian/extra/njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --add-module=/opt/ngx_pagespeed-release-$NPS_VERSION-beta
I am not sure what this is debian/extra/njs-1c50334fbea6/nginx/config
I installed these supporting build files
Code: Select all
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libssl-dev
I
removed the debian/extra option and was able to build nginx but I also had to install a few more packages that I want to make sure are the correct ones
How is it that the below packages where not already installed since the installed nginx had a dependency on these packages
apt-get install libgd2-xpm-dev
apt-get install libxml2-dev libxslt1-dev
apt-get install libgeoip-dev
apt-get install libperl-dev
When searching for the GD2 package I also ran across php5-gd I wasn't sure which ones to install and ended up installing libgd2-xpm-dev. Geoip also had a php5 package but I installed libgeoop-dev instead. I am not even need or want to use these packages but they where listed in the default vesta nginx -V install.
Once I removed the debian/extra and installed the above packages nginx built successfully.
I am very much a novice in this area.
If you need my full build.sh file I will post it. I have google for this error but have not been able to find any results
Thanks for the help
Re: HOWTO Install ngx_pagespeed (Google PageSpeed)
Still not sure why the original install had certain module dependencies already installed but on recompile they where not available. I just went with the apt-get libs I listed in my original post as that worked.
As far as the njs or nginScript you can just download the source and compile it in nginx as per normal when adding a new module.
Code: Select all
apt-get install libgd2-xpm-dev
apt-get install libxml2-dev libxslt1-dev
apt-get install libgeoip-dev
apt-get install libperl-dev