Enough ngx_pagespeed installation tutorial
in Tutorial with 12 comments
Enough ngx_pagespeed installation tutorial
in Tutorial with 12 comments

Ngx_pagespeed is an extension module of Nginx. Its main function is to optimize front-end pages on the server side. For front-end designers, the process of optimizing css, js and images can be omitted. NGx_pagespeed can hardly improve the load capacity of nginx itself, and even increase the load of the system due to server side optimization; However, from the perspective of reducing the number of customer requests, it is worthwhile to sacrifice some server performance.

The main functions of the ngx_pagespeed module are as follows:

This installation tutorial is for CentOS7.2 64 bit Practical.

Dependencies for installing or upgrading ngx_pagespeed for new or lower version systems:

RedHat, CentOS, or Fedora

 sudo yum install gcc-c++ pcre-devel zlib-devel make unzip

Ubuntu or Debian

 sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip

If it has already been installed, the dependency needs to be updated (gcc ≥ 4.8 or clang ≥ 3.3 is required)

Instructions and tutorials related to official dependency: here

Because I want to be stable, the software required for the next configuration is the latest stable version before November 12.

Download various software

Download ngx_pagespeed

 cd /usr/local/src wget  https://github.com/pagespeed/ngx_pagespeed/archive/latest-stable.tar.gz tar -xvzf latest-stable.tar.gz mv ngx_pagespeed-latest-stable ngx_pagespeed cd ngx_pagespeed wget  https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz tar -xzvf 1.11.33.4.tar.gz && rm -rf 1.11.33.4.tar.gz ./scripts/pagespeed_libraries_generator.sh > /usr/local/nginx/conf/pagespeed_libraries.conf

Download nginx

 cd /usr/local/src wget  http://nginx.org/download/nginx-1.10.2.tar.gz tar -xvzf nginx-1.10.2.tar.gz && rm -rf nginx-1.10.2.tar.gz

Download OpenSSL

 cd /usr/local/src wget  https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz tar -xzvf openssl-1.0.2-latest.tar.gz && rm -rf openssl-1.0.2-latest.tar.gz

View latest version number

 ls openssl-1.0.2j

Download PCRE

 wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz tar -xzvf pcre-8.39.tar.gz && rm -rf pcre-8.39.tar.gz

Install ngx_pagespeed

Get arguments

 nginx -V
 --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../ openssl-1.0.2j --with-pcre=../ pcre-8.39 --with-pcre-jit --with-ld-opt=-ljemalloc

Reorganize required software

Directory location of openssl:

 /usr/local/src/openssl-1.0.2j

Directory location of pcre:

 /usr/local/src/pcre-8.39

Location directory of ngx_pagespeed:

 /usr/local/src/ngx_pagespeed

Organize new arguments

Reorganize the configuration arguments according to the obtained configuration arguments and the location of the above software

Then add --add-module=/usr/local/src/ngx_pagespeed

The sorted results are:

 --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=/usr/local/src/openssl-1.0.2j --with-pcre=/usr/local/src/pcre-8.39 --with-pcre-jit --with-ld-o pt=-ljemalloc --add-module=/usr/local/src/ngx_pagespeed

Start Installation

Here you choose to reinstall and compile

 cd /usr/local/src/nginx-1.10.2 ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=/usr/local/src/openssl-1.0.2j --with-pcre=/usr/local/src/pcre-8.39 --with-pcre-jit  --with-ld-opt=-ljemalloc --add-module=/usr/local/src/ngx_pagespeed make && make install

Check whether the installation is normal

 nginx -V nginx version: nginx/1.10.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) built with OpenSSL 1.0.2j  26 Sep 2016 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=/usr/local/src/openssl-1.0.2j --with-pcre=/usr/local/src/pcre-8.39 --with -pcre-jit --with-ld-opt=-ljemalloc --add-module=/usr/local/src/ngx_pagespeed
 nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Ok, so far the installation of ngx_pagespeed has been completed. Let's talk about how to configure and use it in the next chapter.

Responses
  1. It has been successfully applied, and the PageSpeed score of many pages has reached 100, which is great!

    Reply
  2. Return visit

    Reply
    1. @timem

      Yes, I paid a follow-up visit:)

      Reply
  3. perhaps https://blog.linuxeye.com/318.html More details. Since OneinStack is used, help you paste this link.

    Reply
    1. @Orso

      In fact, the least detailed one is a bunch of 13 year tutorials on Baidu/ flee

      Reply
  4. After downloading the psol and unzipping it to the ngx_pagespeed subdirectory, there is still a compilation error () The system is Centos 6-x86_x64 minimal.
    ...
    ./configure: error: module ngx_pagespeed requires the pagespeed optimization library.

    Reply
    1. @kkou

      GCC needs to be upgraded

      Related questions: github.com/pagespeed/ngx_pagespeed/issues/327

      Reply
      1. @Chakhsu Lau

        ... When compiling gcc on vps, you will be prompted that there is not enough memory (512M machines). Manual expansion of swap is not supported

        Reply
        1. ZeroClover
          @kkou

          GCC doesn't need to be compiled at all... Add the RPM source of devtoolset directly, and then install it in YUM. At present, devtoolset-4 is the latest. The GCC version is 5.2.1, which is enough for almost all programs

          Reply
        2. @kkou

          I can't help it. Take your time.

          Reply
  5. Looking at this leather suit, I felt good. I picked it up to Wordpress, ha ha

    Reply
    1. @Program Say

      Brother, very strong!

      Reply