Installing pagespeed module for Nginx on Debian 6

  • Tutorial
For several years, Google released a module for the Apache and Nginx Web servers, which is a set of filters and can significantly improve site performance. In this post, we will not talk about the technology and description of the module, but about its installation and basic configuration. The description of the installation will be done only for Nginx. Installing the module on Apache is simple to disgrace and is not covered in this article.

Let's get started


Install the necessary packages:
apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev

First, create the directory on the server, I have this directory "" temp ":
cd / temp
Download and unpack the source of the module:
wget github.com/pagespeed/ ngx_pagespeed / archive / v1.7.30.1-beta.zip
unzip v1.7.30.1-beta.zip
cd ngx_pagespeed-1.7.30.1-beta
Download and unpack PSOL:
wget dl.google.com/dl/page-speed/psol /1.7.30.1.tar.gz
tar -xzvf 1.7.30.1.tar.gz
Download the latest stable version of NGINX:
wget nginx.org/download/nginx-1.4.5.tar.gz
tar -xvzf nginx-1.4.5.tar .gz
cd nginx-1.4.5 /

Next, an important point, in most cases, when installing from repositories, nginx is placed in the / etc / nginx directory, however, when installing from source, the installation directory is different. If you install NGINX for the first time, this is not critical, but if you want to update the current version, you need to specify the path explicitly, in my case the next step:
./configure --conf-path = / etc / nginx / nginx.conf --error-log-path = / var / log / nginx / error.log --sbin-path = / usr / sbin / nginx --pid -path = / var / run / nginx.pid --lock-path = / var / lock / nginx.lock --http-log-path = / var / log / nginx / access.log --http-client-body -temp-path = / var / lib / nginx / body --http-proxy-temp-path = / var / lib / nginx / proxy --http-fastcgi-temp-path = / var / lib / nginx / fastcgi - -http-uwsgi-temp-path = / var / lib / nginx / uwsgi --http-scgi-temp-path = / var / lib / nginx / scgi --prefix = / var / lib / nginx --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_sub_module --with-http_realip_module --with-http_gzip_static_module --with-http_secure_link_module --with-ipv6 --with-debug = / temp / ngx_pagespeed-1.7.30.1-beta

After verifying that there are no errors, perform the installation:
make
checkinstall

Restart NGINX:
/etc/init.d/nginx restart
And check that we updated successfully: nginx –V

Customization


After installation, it is necessary to perform the initial configuration of the nginx.conf configuration file:
In the http {... section, add the following directives:
pagespeed on;
pagespeed FileCachePath "/ var / cache / ngx_pagespeed /";
pagespeed EnableFilters combine_css, combine_javascript, rewrite_images, rewrite_css, rewrite_javascript, inline_images, recompress_jpeg, recompress_png, resize_images;
pagespeed JpegRecompressionQuality 85;
pagespeed ImageRecompressionQuality 85;
pagespeed ImageInlineMaxBytes 2048;
pagespeed LowercaseHtmlNames on;

Remember to create the directory / var / cache / ngx_pagespeed /.
Then we restart again:
/etc/init.d/nginx restart

Descriptions of filters and features can be found on the official page . When using filters, pay attention to the "Risks" section.
In my case, performance indicators (according to the plugin for Firefox - pagespeed) increased by 25%.

Also popular now: