1,下载解压libmaxminddb
./configure --prefix=/usr/local/libmaxminddb
make
make check
make install
sh -c "echo /usr/local/libmaxminddb/lib >> /etc/ld.so.conf.d/local.conf"
ldconfig
2,下载解压最新稳定版nginx或者在用的nginx版本
./configure --prefix=/usr/local/nginx --with-stream --with-http_gunzip_module \
--with-http_gzip_static_module --with-http_image_filter_module --with-http_perl_module \
--with-http_realip_module --with-http_ssl_module --with-http_v2_module --with-http_xslt_module \
--with-http_flv_module --with-openssl= --with-stream_ssl_preread_module \
--add-dynamic-module=/usr/local/src/ngx_http_geoip2_module-3.3 \
--with-cc-opt="-I/usr/local/libmaxminddb/include -L/usr/local/libmaxminddb/lib"
make
修改objs/Makefile中make出错的位置,插入-L/usr/local/libmaxminddb/lib
make
cp objs/ngx_http_geoip2_module.so objs/ngx_stream_geoip2_module.so /usr/local/nginx/modules
nginx.conf 插入load_module modules/ngx_http_geoip2_module.so;
export PATH=/usr/local/libmaxminddb/lib:$PATH