centos 7 安装 nginx maxmind GEO IP IP库相关部署
centos 7 上为nginx 增加Geo IP的功能
yum install gcc gcc-c++ make automake autoconf libtool wget unzip -y if [ ! -d "/usr/local/software" ]; then mkdir /usr/local/software
fi
cd /usr/local/software if [ ! -f "/usr/local/software/libmaxminddb-1.3.2.tar.gz" ]; then
wget http://download.zhufunin.com/libmaxminddb-1.3.2.tar.gz
fi if [ ! -f "/usr/local/software/ngx_http_geoip2_module.zip" ]; then
wget http://download.zhufunin.com/ngx_http_geoip2_module.zip
fi if [ ! -f "/usr/local/software/maxmind-city.mmdb.tar.gz" ]; then
wget http://download.zhufunin.com/maxmind-city.mmdb.tar.gz
fi tar zxvf libmaxminddb-1.3..tar.gz
tar zxvf maxmind-city.mmdb.tar.gz
unzip -o ngx_http_geoip2_module.zip cd ./libmaxminddb-1.3.
./configure
make && make install
[[ -z `cat /etc/ld.so.conf |grep "\/usr\/local\/lib"` ]] && echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
安装nginx的时候
./configure \
...
--add-module=/usr/local/software/ngx_http_geoip2_module-master \
...
在nginx 配置http的位置添加以下配置,maxmind-city.mmdb IP库需要放到/usr/local/nginx/geoip/下面
fastcgi_param COUNTRY_CODE $geoip2_data_country_code;
fastcgi_param COUNTRY_NAME $geoip2_data_country_name;
fastcgi_param CITY_NAME $geoip2_data_city_name; geoip2 /usr/local/nginx/geoip/maxmind-city.mmdb {
$geoip2_data_country_code default=US source=$remote_addr country iso_code;
$geoip2_data_country_name country names en;
$geoip2_data_city_name default=London city names en;
$geoip2_data_province_name subdivisions names en;
$geoip2_data_province_isocode subdivisions iso_code;
}
maxmind IP 库更新脚本,可以放到crontab 中定期运行,更新IP库
#!/bin/bash
cd /usr/local/nginx/geoip/
rm -rf /usr/local/nginx/geoip/GeoLite2-City_*
rm -rf /usr/local/nginx/geoip/GeoLite2-City.tar.gz*
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
code="$?"
echo $code
if test "$code" -ne ;then
echo "Download is failed"
exit ;
fi
tar zxf GeoLite2-City.tar.gz
cd GeoLite2-City_*
if test ! -e GeoLite2-City.mmdb; then
exit ;
fi
size=`du -s ./GeoLite2-City.mmdb |awk '{print $1}'`
if test "$size" -lt ;then
exit ;
fi
echo "mv GeoLite2-City.mmdb maxmind-city.mmdb"
mv GeoLite2-City.mmdb maxmind-city.mmdb
echo "mv maxmind-city.mmdb /usr/local/nginx/geoip/"
mv maxmind-city.mmdb /usr/local/nginx/geoip/
centos 7 安装 nginx maxmind GEO IP IP库相关部署的更多相关文章
- linux/centos下安装nginx(rpm安装和源码安装)详细步骤
Centos下安装nginx rpm包 ...
- CentOS 7安装nginx
CentOS 7安装nginx 参考网上其他文章做的 安装Nginx 我们从nginx官方的RPM源来安装一个预构建的稳定版本的nginx包. rpm --import http://nginx.or ...
- CentOS 7 安装 Nginx 配置反向代理
Linux使用Nginx Yum存储库上安装Nginx,适用于Red Hat Enterprise Linux和CentOS系统. 1.添加设置Nginx Yum存储库 在CentOS中首次安装Ngi ...
- Centos 在线安装 nginx
centos 在线安装 nginx 安装nginx 参考文档: http://nginx.org/en/linux_packages.html 中的RHEL/CentOS章节,按照步骤安装repo ...
- 删:Centos 7安装Nginx 1.8
[CentOS 7] 安装nginx! 首先进行 nginx yum Nginx安装记录 注意:如果用源码安装,nginx配置时需要指定--with-pcer对应的压缩包路径,如果使用二进制安装不需要 ...
- CentOS下安装Nginx并添加nginx_upload_module
安装前,最好能保证依赖的系统软件已经升级. yum update CentOS上安装Nginx,如果只是简单安装,不附加其他第三方模块,一句话可以搞定: yum install nginx ...
- CentOS 下 安装 nginx 执行配置命令 ./configure 报错
CentOS 下 安装 nginx 执行配置命令 ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx 时提示以下错误: checkin ...
- Linux(Centos)之安装Nginx及注意事项
1.Nginx的简单说明 a. Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,期初开发的目的就是为了代理电子邮件服务器室友:Igor Sysoev开发 ...
- Centos下安装nginx rpm包
1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...
随机推荐
- springBoot代码和依赖分开打包
目的: 1.分离代码和依赖(包括第三方的引入包) 2.分离配置文件到外部 3.修改/META-INF/MANIFEST.MF中加载依赖包的位置和启动类,包含第三方依赖jar包 先查看项目的结构 由于我 ...
- Wannafly Camp 2020 Day 3I N门问题 - 概率论,扩展中国剩余定理
有一个猜奖者和一个主持人,一共有 \(n\) 扇门,只有一扇门后面有奖,主持人事先知道哪扇门后有奖,而猜奖者不知道.每一轮,猜奖者选择它认为的有奖概率最大(如果有多个最大,随机选一个)的一扇门,主持人 ...
- KMP(模板)
算法讲解: KMP算法最浅显易懂 模板来源: 从头到尾彻底理解KMP 首先:KMP的模板为: void get_next(char *a, int *nex) { nex[] = ; , j = ; ...
- 使用ResXmanager实现多语言[转]
1 多國語系 - 使用RESXMANAGER管理資源檔 1.1 前言 在實作多國語系網站時,針對靜態文字多會使用資源檔(Resource)來對應出各語系所需顯示的內容.由於資源檔可能會依照特定結構放式 ...
- 关于整合ssh中的细节03
关于spring中提供的一些工具类和监听介绍 一.spring提供了一个HibernateTemplate类 ①HibernateTemplate类: 用于操作PO对象,类似Hibernate Ses ...
- 《深入理解java虚拟机》读书笔记二——第三章
第三章 垃圾收集器与内存分配策略 1.判断对象是否已死 引用计数法: 给对象添加一个引用计数器,每当有一个地方引用它时,计数器值就加1,每当引用失效时,计数器值就减1. 任何时刻计数器为0的对象就是不 ...
- Ubuntu18.04安装phpMyAdmin
1.使用apt自动安装 sudo apt install phpmyadmin 2.安装完成后,创建软链接到web根目录下(我的是/var/www/html/) sudo ln -s /usr/sha ...
- Spring Data JPA介绍与简单案例
一.Spring Data JPA介绍 可以理解为JPA规范的再次封装抽象,底层还是使用了Hibernate的JPA技术实现,引用JPQL(Java Persistence Query Languag ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛---Find Integer!--hdu6441
问题传送门:https://vjudge.net/contest/320779#problem/D 介绍一个名词:奇偶数列法则 Key part: #include<iostream> # ...
- android 获取所有SD卡目录
//返回sd卡路径public static List<String> getStorageDirectories(Context context) { StorageManager sm ...