在rocky linux 9的epel-release源中已经没有了没有了geoip-devel工具了。

需要自己单独下载安装。

$ wget https://launchpadlibrarian.net/96958425/GeoIP-1.4.8.tar.gz  
# http:///download/geoip/api/c/GeoIP.tar.gz失效
$ tar -zxvf GeoIP-1.4.8.tar.gz
$ cd GeoIP-1.4.8    # 注意这个解压出的版本随时在变,我解压时,是1.4.8版本的
$ ./configure
$ make; make install

IP 地域数据库(GeoIP.dat)文件是二进制的,需要用GeoIP库来读取。所以除了要下载 GeoIP.dat 文件外,还需要安装能读取这个文件的库。

GeoIP project files : GeoIP

上面的操作,将工具安装到了/usr/local/lib目录下,我们需要让其生效。

nginx-1.26.1使用GeoIP功能_nginx

$ echo '/usr/local/lib' > /etc/ld.so.conf.d/geoip.conf
$ ldconfig

或者

# cat /etc/ld.so.conf.d/geoip.conf 
# /usr/local/lib
# ldconfig

使其生效。





nginx-1.26.1的安装

#cd nginx-1.26.1
#./configure  --prefix=/usr/local/nginx-1.26.1  --with-threads   --with-file-aio  --with-http_ssl_module  --with-http_v2_module  --with-http_v3_module  --with-http_realip_module  --with-http_geoip_module  --with-http_gunzip_module  --with-http_gzip_static_module  --with-http_auth_request_module  --with-stream  --with-stream_ssl_module  --with-stream_realip_module  --with-stream_geoip_module  --with-compat \

nginx-1.26.1使用GeoIP功能_下载安装_02

因为配置了GeoIP,但是没有安装,按前面一的步骤安装GeoIP。



安装GeoIP再次执行configure 就能找到GeoIP了。

nginx-1.26.1使用GeoIP功能_nginx_03

如果没有使用ldconfig这启用这个GeoIP,在运行nginx时会报错。

nginx-1.26.1使用GeoIP功能_下载安装_04