NGINX, PageSpeed, Brotli

This is an old revision of the document!


Difficulty
Hard

NGINX, PageSpeed, Brotli

This guide assumes you are switched to su - . Please note that during the ./configure steps you need to check for missing libraries, this guide assumes you are using the eSG provided installation image.

Goal

Compile nginx with most modules, including support for http2 and pagespeed.

Steps

EXPORTS used to set versions

You can change the values here to change compiled version.

NGINX_VERSION=1.20.2
PS_NGX_EXTRA_FLAGS="--with-ld-opt=-static-libstdc++"
HEADERS_VERSION=0.33
NPS_VERSION=latest-stable
LIBRESSL_VERSION=3.4.2
OPENSSL_VERSION=3.0.0

Building Pre requisites

cd ~
mkdir buildnginx
cd ~/buildnginx
useradd nginx

Library Prerequisites

Centos 7

yum install -y epel-release
yum -y groupinstall 'Development Tools'
yum -y install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed perl-Digest-SHA1.x86_64 perl-Digest-MD5.x86_64 openssl-devel.x86_64 openssl.x86_64 openssl-libs.x86_64 libuuid-devel

Centos 8

yum install -y epel-release
yum -y groupinstall 'Development Tools'
yum config-manager --set-enabled PowerTools
yum -y install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed perl-Digest-MD5.x86_64 openssl-devel.x86_64 openssl.x86_64 openssl-libs.x86_64 libuuid-devel

Fedora 32-35

dnf groupinstall 'Development Tools'
dnf install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed perl-Digest-MD5.x86_64 openssl-devel.x86_64 openssl.x86_64 openssl-libs.x86_64 libuuid-devel perl

Fetch nginx

wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar zxfv nginx-${NGINX_VERSION}.tar.gz

Fetch libressl

wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz
tar zxfv libressl-${LIBRESSL_VERSION}.tar.gz
cd libressl-${LIBRESSL_VERSION}
cd ~/buildnginx

Fetch openssl

Optionally you can use openssl instead of libressl.

wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar zxfv openssl-${OPENSSL_VERSION}.tar.gz

Fetch Headers_more

wget https://github.com/openresty/headers-more-nginx-module/archive/v${HEADERS_VERSION}.tar.gz -O headers_more-${HEADERS_VERSION}.tar.gz
tar zxfv headers_more-${HEADERS_VERSION}.tar.gz

Fetch PageSpeed

wget https://github.com/pagespeed/ngx_pagespeed/archive/${NPS_VERSION}.tar.gz -O pagespeed-${NPS_VERSION}.tar.gz
tar zxfv pagespeed-${NPS_VERSION}.tar.gz
cd incubator-pagespeed-ngx-${NPS_VERSION}

Fetch PSOL

Check here for latest release: https://modpagespeed.com/doc/release_notes In order to get the version of PSOL build continue with the steps after this one, while configuring nginx you will get an error message providing the version required. In this example the latest-stable is 1.13.35.2.

wget https://dl.google.com/dl/page-speed/psol/1.14.36.1-x64.tar.gz
tar zxfv 1.14.36.1-x64.tar.gz

Fetch Brotli

cd ~/buildnginx
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init

Fetch vts

cd ~/buildnginx
git clone https://github.com/vozlt/nginx-module-vts.git

Configure NGINX

cd ~/buildnginx
cd nginx-${NGINX_VERSION}
Choose between the following:

libreSSL

./configure --user=nginx --group=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 --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_xslt_module=dynamic --with-http_image_filter_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-http_geoip_module=dynamic --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_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-http_perl_module=dynamic --with-mail --with-mail_ssl_module --with-mail=dynamic --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_geoip_module --with-stream_geoip_module=dynamic --with-google_perftools_module --with-pcre --with-libatomic --with-http_v2_module --add-module=../incubator-pagespeed-ngx-${NPS_VERSION} ${PS_NGX_EXTRA_FLAGS} ${PS_NGX_EXTRA_FLAGS} --with-openssl=../libressl-${LIBRESSL_VERSION}/ --add-module=../headers-more-nginx-module-${HEADERS_VERSION}/ --add-module=../ngx_brotli --add-module=../nginx-module-vts

openSSL

./configure --user=nginx --group=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 --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_xslt_module=dynamic --with-http_image_filter_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-http_geoip_module=dynamic --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_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-http_perl_module=dynamic --with-mail --with-mail_ssl_module --with-mail=dynamic --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_geoip_module --with-stream_geoip_module=dynamic --with-google_perftools_module --with-pcre --with-libatomic --with-http_v2_module --add-module=../incubator-pagespeed-ngx-${NPS_VERSION} ${PS_NGX_EXTRA_FLAGS} ${PS_NGX_EXTRA_FLAGS} --with-openssl=../openssl-${OPENSSL_VERSION}/ --add-module=../headers-more-nginx-module-${HEADERS_VERSION}/ --add-dynamic-module=../ngx_brotli 

Build NGINX

make

Install NGINX

make install

Setup Steps

Setup the systemd service

Setup the pid directory creation

echo "d /var/run/nginx 755 root root" > /usr/lib/tmpfiles.d/nginx.conf

Edit nginx.conf

pid /var/run/nginx/nginx.pid;
user nginx nginx;

Create temp folder on boot

Used for the pid file

vim /usr/lib/tmpfiles.d/nginx.conf

d /var/run/nginx 755 root root

Setup Firewalld

Firewalld

This page has been accessed 6 times Today, 1 times Yesterday and 1272 times Since 2020/06/08.

/home/www/sites/esgr.in/wiki/data/attic/software/nginx.1639137069.txt.gz · Last modified: 2021/12/10 11:51 by eServices Greece