📜 ⬆️ ⬇️

Installing pagespeed for Nginx on Debian 6

For several years now, Google has launched a module for Apache and Nginx Web servers, which is a set of filters and can significantly improve the performance of the site. In this post we will discuss not the technology and the description of the module, but its installation and basic configuration. The installation description will be carried out only for Nginx. Installing the module on Apache is very disgraceful and is not affected in this article.

Let's get started


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

To begin with, we create a directory on the server, I have a »temp directory:
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 /

Further, an important point, in most cases, when installing from repositories, nginx is placed in the / etc / nginx directory, but when installing from sources, 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 explicitly set the path, 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 = / temp / ngx_pagespeed-1.7.30.1-beta
')
Making sure there are no errors, we perform the installation:
make
checkinstall

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

Customization


After installation, you must 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 restart again:
/etc/init.d/nginx restart

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

Source: https://habr.com/ru/post/214095/


All Articles