#######Compiling nginx with pagespeed and GeoIP module
As root execute below commands
# yum install gcc-c++ pcre-devel pcre-devel zlib-devel make unzip openssl-devel
And then download PageSpeed with below commands
# mkdir -P /opt/nginx; mkdir -P /opt/nginx/modules/;
# cd /opt/nginx/modules
# NPS_VERSION=1.9.32.3
# wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip
# unzip release-${NPS_VERSION}-beta.zip
# cd ngx_pagespeed-release-${NPS_VERSION}-beta/
# wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
# tar -xzvf ${NPS_VERSION}.tar.gz
Now let's install GeoIP module
# cd /tmp
# wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
# tar -zxvf GeoIP.tar.gz
# cd GeoIP-1.4.6
# yum install zlib-devel
# ./configure
# make
# make install
You need to configure dynamic linker run time bindings as follows:
# echo '/usr/local/lib' > /etc/ld.so.conf.d/geoip.conf
Run ldconfig to activate configuration:
# ldconfig
# ldconfig -v | less
Now let's compile nginx with pagespeed and GeoIP module
Execute below command to configure nginx, this is specific to centOS
# ./configure --add-module=/opt/nginx/modules/ngx_pagespeed-release-${NPS_VERSION}-beta --prefix=/etc/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 --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --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_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-http_geoip_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
To check whether all modules are installed , verify with below command
# nginx -V
nginx path prefix: "/etc/nginx"
nginx binary file: "/usr/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/cache/nginx/client_temp"
nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"
nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"
nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"
nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"