Clone the Nginx source and the ngx_http_geoip2_module. Run ./configure --with-debug --add-dynamic-module=ngx_http_geoip2_module, then make modules. The .so file will be in the objs directory