centos 7 安装geoipupdate

很多人在安装完centos 7 mini iso 以后会安装bind-utils,bind-utils 包含了许多DNS查询的工具包,其中就有一个dependency GeoIP library

但是这个GeoIP library 是包含在老版的geoipupdate这个程序中的,版本号应该为1.5,但是maxmind 早就放弃了对于老版geoipupdate的支持,因此如果你的程序需要geoipupdate 的支持的话,用centos 7 默认repo 自带的geoipupdate 的话,肯定是不行的了

因此我们肯定是要安装经过重新开发过的只支持新的geoip 数据库格式的geoipupdate

github地址是https://github.com/maxmind/geoipupdate

但是这里又出现了一个问题,如果我们直接使用rpm 的安装包来安装的话,默认的可执行command 会被安装在/usr/bin/geoipupdate, conf 地址会被安装在/etc/GeoIP.conf, 这样会和老版的geoipupdate 发生冲突,但是bind-utils 又依赖于老版的GeoIP 库,不可能卸载掉

这里有一个比较简单的解决办法,就是直接安装linux 的通用安装包,而不是用专门的centos的rpm安装包,这样可执行程序的路径就可以被我们自行选择

bootstrap中的sr-only

最近在看bootstrap4,经常会有sr-only这个类

sr是screen reader的缩写,这个表示是为视力有障碍的人士准备的类.

在前端开发中,有些时候设计图上面会出现仅供正常视觉用户看的元素。比如:导航栏菜单当前页面选中高亮状态,这些状态只有视力正常的人才能正常使用。

而残障人士,弱势或盲人是很难或者根本看不出导航菜单高亮的。他们上网可能借助的是屏幕阅读器,也就是 screen reader(sr),屏幕阅读器需要找到能辨识的文本说明然后“读”出来给用户听。

CentOS 7 Nginx 默认配置

在centos 7 下,用nginx official repo安装的nginx stable版本的config 默认配置如下:

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

但是很明显, 这个配置过于简单了,结合军哥的LNMP,我们可以稍微改动一下config:

user nginx;

worker_processes auto;
worker_cpu_affinity auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events {
use epoll;
worker_connections 51200;
multi_accept off;
accept_mutex off;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;


gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.


server_tokens off;
access_log off;

server {

listen 80 default_server;
server_name _;
index index.html index.htm index.php;
root /usr/share/nginx/html;


}


include /etc/nginx/conf.d/*.conf;
}

在CentOS7上,nginx的启动是有systemd 来管理的,位置在/usr/lib/systemd/system/nginx.service

配置文件为:

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

macbook pro的无线大坑

这周一直在给macbook pro 重装系统,可恶的天朝网络,时断时续,经常从十几MB的下载速度掉到几十KB, 还有动不动can’t download items..

今天无意间在抽屉里发现当初买macbook时赠送的thunderbolt2转网线的接口,就无意识的插上网线一试发现reload system时,速度竟然能够一直保持在几十MB每秒, 6.05GB的macos Mojave,只需要5分钟就可以下载完毕..

看来再好的无线wifi硬件,在稳定性上还是不如ethernet

Macbook通过恢复功能重新安装macOS

大家都知道在开机的时候,按住Command+R可以重装系统,但是其实这里还有另外两个选项:

Option + Command + R, 也可以通过internet自动重装系统,但是是自动安装最新版本的macOS

Shift + Option +Command + R, 通过internet自动重装买这台macbook时安装的系统,如果这个系统太老并且不再被苹果所支持了,那么会通过internet安装正在支持的最为接近这个旧系统的macOS

防止阿里云备案被撤销

鉴于国内BT的备案的制度,阿里云更为甚之。。。

在阿里云备案的域名,如果没有把IP指向阿里云,也被会阿里云警告

因此最好的办法就是把IP只想阿里云并且模拟一些流量

打开centos 的crontab,可以设置如下crojob,来模拟真实的流量:

0 2 * * * curl -s www.domain1.com > /dev/null 2>&1 >/dev/null 2>&1
0 3 * * * curl -s www.domain2.com > /dev/null 2>&1 >/dev/null 2>&1
0 4 * * * curl -s www.domain3.cn > /dev/null 2>&1 >/dev/null 2>&1
0 5 * * * curl -s www.domain4.cn > /dev/null 2>&1 >/dev/null 2>&1

国内cloud安装军哥LNMP1.6

02-18-2019 Updated: 军哥已经修复了这个问题. 

 

军哥的LNMP准时在1月1号更新了,之前一直在国外的cloud上安装,所以没有遇到任何问题

但是今天在阿里云的深圳机房上安装,确发现了一个小的问题

具体说来就是在LNMP1.6上安装boost的时候,boost 的安装被写入了mysql 的config,mysql 会自动从internet上下boost并且安装配置boost.

问题就出现这里,mysql下载boost,是从sourceforge上下载boost

下载地址:

http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

阿里云连sourceforge速度超慢,时间一长就会被程序自动timeout了, 不得不说这是国内的悲哀。。。

解决这个办法还是比较简单的,就是提前下载号boost1.59到/root/lnmp1.6/src下面,也就是你的lnmp文件夹下面的src里面就可以了

下载地址:

http://soft.vpser.net/lib/boost/

需要注意的是,lnmp1.6需要是tar.bz2的boost

删除阿里云自带的云盾,监控服务等等

其他的系统我不太清楚,但是aliyun的centos模板自带许多阿里云的服务,比如说云盾,cloudwatch等等,而这些往往是我们不愿意透露出去的,因此需要一上来就删掉这些服务,而这些服务往往还像牛皮癣,很难删的完完整整

下面的操作都是在aliyun 深圳机房的一台安装了centos 7的轻量云上操作的

卸载阿里云监控

wget http://update.aegis.aliyun.com/download/uninstall.sh
chmod +x uninstall.sh
sudo ./uninstall.sh
wget http://update.aegis.aliyun.com/download/quartz_uninstall.sh
chmod +x quartz_uninstall.sh
sudo ./quartz_uninstall.sh

其实quartz的uninstall中已经包含了aegis的卸载命令

删除残留

sudo pkill aliyun-service
sudo rm -rf /etc/init.d/agentwatch /usr/sbin/aliyun-service
sudo rm -rf /usr/sbin/aliyun*
sudo rm -rf /etc/systemd/system/aliyun.service
sudo rm -rf /usr/local/aegis*

 

屏蔽云盾IP

如果用iptables,可用如下命令

iptables -I INPUT -s 140.205.201.0/28 -j DROP
iptables -I INPUT -s 140.205.201.16/29 -j DROP
iptables -I INPUT -s 140.205.201.32/28 -j DROP
iptables -I INPUT -s 140.205.225.192/29 -j DROP
iptables -I INPUT -s 140.205.225.200/30 -j DROP
iptables -I INPUT -s 140.205.225.184/29 -j DROP
iptables -I INPUT -s 140.205.225.183/32 -j DROP
iptables -I INPUT -s 140.205.225.206/32 -j DROP
iptables -I INPUT -s 140.205.225.205/32 -j DROP

如果用防火墙,可以直接屏蔽下面的IP

140.205.201.0/28
140.205.201.16/29
140.205.201.32/28
140.205.225.192/29
140.205.225.200/30
140.205.225.184/29
140.205.225.183/32
140.205.225.206/32
140.205.225.205/32

最后删除云监控cloudwatch 需要注意的是,centos安装的是go版本的云监控

可以参考这个官方页面

http://help.aliyun.com/document_detail/97929.html

也可以直接使用下面的命令:

/usr/local/cloudmonitor/CmsGoAgent.linux-amd64 stop && \
/usr/local/cloudmonitor/CmsGoAgent.linux-amd64 uninstall && \
rm -rf /usr/local/cloudmonitor

如果你的centos安装的是java版本的话,可以使用

/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh stop
/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh remove && \
rm -rf /usr/local/cloudmonitor

Nginx安装Sectigo 的essential SSL

以前一直使用的是rapid SSL,但是rapid SSL 最近爆出了一些问题,因此开始转向我以前不是很喜欢的comodo,也就是现在的sectigo.

安装过程和rapid ssl 大同小异,有些不同的地方在rapid ssl 的intermediate certificate 只有一个文件,而comodo sectigo essential 的 chain files 确有三个, 需要注意的是chain files 根据时间的流逝,可能会有新的chain files产生, 而sectigo 的官方support 更新比较慢,建议自己从email 中合成chain file

chain file 从上到下,应该是SectigoRSADomainValidationSecureServerCA,USERTrustRSAAddTrustCA,AddTrustExternalCARoot

在nginx下,crt 是需要和chain file 合在一起的,因此在最后的crt中,应包含的证书,从上到下是 CRT, SectigoRSADomainValidationSecureServerCA,USERTrustRSAAddTrustCA,AddTrustExternalCARoot