Leeladharan Achar - alias - leelu ~ blogging...hola mi amigos..'s Blog

Posted March 31, 2015   2711 views

Compiling Nginx with modules PageSpeed and GeoIP

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'

# make
# make install

To check whether all modules are installed , verify with below command

# nginx -V