• 阿川 发布的文章

9 June 2015
为cpanel安装一枚nginx前端插件

最近客户的网站折腾的到蛋蛋疼,也不知道具体错误为何,总之.访问php时快时慢,他不是卡死,而且一直在等待载入,后台用easyApache折腾半天,无果.只好给他想其他的办法了,所以想到了传说的nginx,话说这玩意在前端的话.终究会好一点的..实际上我也不知道为啥要给他装个nginx在前面,但是总觉得这货要是一直这么卡下去,我估计要哭了.
安装方法很简单,首先到集群/远程访问中生成一个新的密钥,之后执行下面的命令安装.  

cd /usr/local/src

wget http://nginxcp.com/latest/nginxadmin.tar 

tar xf nginxadmin.tar

cd publicnginx

./nginxinstaller install 

Read More

9 June 2015
使用.htaccess禁止某些useragent访问

客户有一台美国VPS,只要一启动就CPU飙升到100%,在日志里面发现大量的日志.如下:

119.188.12.14 - - [09/Jun/2015:03:48:46 +0800] "GET /hdtzb/29.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.90 - - [09/Jun/2015:03:48:49 +0800] "GET /hdtzb/27.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.90 - - [09/Jun/2015:03:48:49 +0800] "GET /hdtzb/27.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.15.15 - - [09/Jun/2015:03:48:49 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.15.15 - - [09/Jun/2015:03:48:49 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.73 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/19.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.73 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/19.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
221.204.176.89 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/9.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
221.204.176.89 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/9.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/7.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/7.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/31.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/31.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.12.14 - - [09/Jun/2015:03:48:50 +0800] "GET /hdtzb/29.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.12.14 - - [09/Jun/2015:03:48:51 +0800] "GET /hdtzb/29.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.90 - - [09/Jun/2015:03:48:54 +0800] "GET /hdtzb/27.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.90 - - [09/Jun/2015:03:48:54 +0800] "GET /hdtzb/27.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.15.15 - - [09/Jun/2015:03:48:54 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.73 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/19.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
61.54.24.73 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/19.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/7.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/7.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.15.15 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
221.204.176.89 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/9.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
221.204.176.89 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/9.html HTTP/1.1" 403 292 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/31.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
182.118.13.20 - - [09/Jun/2015:03:48:55 +0800] "GET /hdtzb/31.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.12.14 - - [09/Jun/2015:03:48:56 +0800] "GET /hdtzb/29.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.12.14 - - [09/Jun/2015:03:48:56 +0800] "GET /hdtzb/29.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
123.125.71.17 - - [09/Jun/2015:03:48:57 +0800] "GET / HTTP/1.1" 200 372448 "-" "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
119.188.15.15 - - [09/Jun/2015:03:48:59 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"
119.188.15.15 - - [09/Jun/2015:03:48:59 +0800] "GET /hdtzb/25.html HTTP/1.1" 403 293 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36"

Read More

7 March 2014
当ecshop出现Warning: number_format() expects parameter...

今天美国空间客户,突然发现他的网站无法下单.出现错误提示:
Unknown column 's.shipping_order' in 'order clause'
阿川只知道这个错误属于在表里面找不到shipping_order这个字段,这个字段应该属于esc_shiping.可能是某ecshop的插件导致,
于是在该表中添加字段shipping_order,类型为varchar(20),问题得到解决.但是解决的同时警告:

Warning: number_format() expects parameter...

在config.php中设置error_reporting(0);无果之后..
发现问题位于代码includes\lib_common.php中第959行,据说出现问题的原因是因为:
配送插件里面的免费额度为0,ec本身的bug导致了$price的值为空值,直接调用number_format出现了错误.(来源:http://www.pksafe.cn/blog/1093.html).根据该博客修改之后问题依旧.但是起码找到问题的本身.最后将959行代码

$price = number_format($price, 2, '.','');

修改为

$price = number_format(floatval($price), 2, '.', '');	

问题解决

13 January 2014
SSH代理上网指定IP出口

客户有三条IP,使用SSH代理之后,均显示主IP.
可以利用iptables让某用户使用指定IP出口:
先建立用户 比如建立 user1 user2 user3三个用户。
然后执行

cat /etc/passwd    #查看用户ID。

假设
user1<=>501
user2<=>502
user3<=>503

那么执行以下命令

    iptables -t mangle -A OUTPUT -m owner --uid-owner 501 -j MARK --set-mark 501
iptables -t nat -A POSTROUTING -m mark --mark 501 -j SNAT --to-source [IP1]
    iptables -t mangle -A OUTPUT -m owner --uid-owner 502 -j MARK --set-mark 502
iptables -t nat -A POSTROUTING -m mark --mark 502 -j SNAT --to-source [IP2]
    iptables -t mangle -A OUTPUT -m owner --uid-owner 503 -j MARK --set-mark 503
iptables -t nat -A POSTROUTING -m mark --mark 503 -j SNAT --to-source [IP3]

实例格式:

iptables -t mangle -A OUTPUT -m owner --uid-owner 501 -j MARK --set-mark 501
iptables -t nat -A POSTROUTING -m mark --mark 501 -j SNAT --to-source 127.0.0.1
13 November 2013
为zencart创建静态的首页

今天在测试客户的美国VPS,客户使用zencart程序.发现首页打开速度奇慢无比.而内页又十分正常.测试半天未果.只好将首页为其生成静态.每天使用crontab自动为他更新一次首页.下面文档仅供参考:
1:在网站根目录下创建makeindex.sh,内容如下:

wget  "你的域名/index.php" -O  index.html  >> /dev/null 2>&1

2:给其写入权限

chmod 777 makeindex.sh

3:添加crontab任务:

15 05  * * * /home/admin/makeindex.sh  >> /dev/null 2>&1

搞完收工


收缩
  • QQ咨询

  • 在线咨询
  • 技术支持