Nginx and PageSpeed build from source CentOS example




Putting this down for my own future reference. I've tried following the installation guide at https://modpagespeed.com/doc/buildngxpagespeedfromsource to install Nginx and PageSpeed on my new DigitalOcean CentOS 7 droplet with this command

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

but keep encountering the error message such as

checking for psol

cc: error: /root/ngxpagespeed-latest-stable/psol/lib/Release/linux/x64/pagespeedautomatic.a: No such file or directory

Apparently, the script at https://ngxpagespeed.com/install will download the latest tarball, but it does not have the x64 directory in it and will cause checking for psol not found error later.

For CentOS, the stable release as of the time of writing is still version 1.11.33.4. You can specify the script to use version 1.11.33.4 as well with this command

bash <(curl -f -L -sS https://ngxpagespeed.com/install) --nginx-version 1.13.1 --ngx-pagespeed-version 1.11.33.4

and when prompted for the options, add:

--with-httpsslmodule --prefix=/usr/local/share/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin --error-log-path=/var/log/nginx/error.log

NOTE: Please modify the options to suit your own configuration

By the end of the script execution, you should see this message

Nginx installed with ngx_pagespeed support compiled-in.

If this is a new installation you probably need an init script to manage starting and stopping the nginx service. See: http://wiki.nginx.org/InitScripts

You'll also need to configure ngx_pagespeed if you haven't yet: https://developers.google.com/speed/pagespeed/module/configuration

If you prefer to do it manually, see the steps below.


The following steps are my own to get Nginx and PageSpeed module build from scratch. You might have to modify the directories to suit your own configuration.

  1. wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.11.33.4-beta.zip

  2. unzip v1.11.33.4-beta.zip

  3. cd ngx_pagespeed-1.11.33.4-beta/

  4. NPS_VERSION=1.11.33.4

  5. psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz

  6. wget ${psol_url}

  7. tar -xzvf 1.11.33.4.tar.gz

  8. Download latest nginx version from http://nginx.org/en/download.html

  9. At this time of writing, the version is 1.13.1. Download and unzip.

  10. cd nginx-1.13.1/

  11. Enter this command:

      ./configure --add-module=$HOME/ngx_pagespeed-${NPS_VERSION}-beta --with-http_ssl_module \
    
     --prefix=/usr/local/share/nginx --conf-path=/etc/nginx/nginx.conf \
    
     --sbin-path=/usr/local/sbin --error-log-path=/var/log/nginx/error.log
    
  12. make

  13. sudo make install

  14. yum remove nginx* -- this is optional

  15. Depending on how you configure the make, the compiled Nginx executable is located at /usr/local/sbin

  16. vi /etc/nginx/nginx.conf

  17. Add these lines to the http block.

      ##
      #ngx_pagespeed module settings
      ##
    
      pagespeed on;
      pagespeed FileCachePath /var/ngx_pagespeed_cache;
    
  18. Go to /usr/local/sbin and start Nginx.

  19. Point the browser to the droplet's IP address and the Nginx welcome page will appear if everything goes smoothly.

  See also : Nginx + FastCGI + Go Setup.





By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.


Advertisement