海运的博客

Cacti中文版安装插件支持

发布时间:May 11, 2012 // 分类:Cacti // No Comments

Cacti默认安装后不支持插件,需打一个补丁PA,即:Plugin Architecture,Cacti中文版安装请参考:Centos服务器安装Cacti中文版
注:最新版Cacti已整合PA,安装插件更方便。
PA安装:

cd /home/wwwroot/cacti
wget http://blogimg.chinaunix.net/blog/upfile2/090818213852.gz
gzip -d 090818213852.gz
patch -p1 -N < 090818213852

如果Cacti以二级目录的形式www.haiyun.me/cact,需修改:

vim include/global.php

修改url目录为二级目录:

$config['url_path'] = '/cacti/'; 

导入PA数据库:

mysql -u root -p cacti < pa.sql #cacti为cacti数据库名称

为用户添加插件管理权限,Cacti管理界面——用户管理——Admin,添加插件管理。
cacti用户添加插件管理权限.png

Nginx自定义404错误页面

发布时间:May 9, 2012 // 分类:Nginx // No Comments

编辑Nginx配置文件,在server段添加:

listen 80;
         root  /home/wwwroot/www.haiyun.me;
         error_page 404  /404.html;  

也可同时定义多个错误状态:

error_page 404 502 403  /404.html;  

还可以更改错误状态码:

error_page 404  =200 /404.html;  

如果错误页面是php程序:

error_page 404 = /404.php;  

404页面最好不要超过512字节,IE浏览器会转向其默认错误页面。

用Curl调试web服务器

发布时间:May 9, 2012 // 分类:常用软件 // No Comments

Curl是款功能很强大的www客户端,之前介绍过用curl上传下载FTP文件,本次记录下curl用于调试web服务器常用的命令。
1.获取服务器head信息:

curl -I https://www.haiyun.me

2.测试服务器网页压缩,如返回乱码即压缩。

curl  -H  "Accept-Encoding: gzip" https://www.haiyun.me

3.查看请求及返回head信息,如服务器支持压缩会返回Content-Encoding: gzip。

curl -v -I -H  "Accept-Encoding: gzip" https://www.haiyun.me

4.测试服务器虚拟主机:

curl -L -H "Host: www.haiyun.me" http://192.168.1.2/

5.测试HTTP性能:

curl -so /dev/null -w "%{time_namelookup} %{time_connect} %{time_redirect} %{time_pretransfer} \
%{time_starttransfer} %{time_total}\n" www.haiyun.me

6.测试服务器KeepAlive:

curl -v -I -H "Keep-Alive: 60" -H "Connection: keep-alive" www.haiyun.me www.haiyun.me

7.测试Proxy:

curl -I --proxy 192.168.1.1:7070 www.haiyun.me
curl -I --socks5 192.168.1.1:7070 www.haiyun.me

8.指定域名对应ip地址,相对于host支持https sni。

curl --resolve www.haiyun.me:443:1.2.3.4 https://www.haiyun.me/

Nginx编译安装more_set_headers模块自定义head头信息

发布时间:May 9, 2012 // 分类:Nginx // No Comments

通过服务器的head头可以得到服务器的很多信息,这给服务器安全带来很大隐患,如:

curl -I https://www.haiyun.me
HTTP/1.1 301 Moved Permanently
Server: nginx/1.0.15
Date: Fri, 10 Feb 2012 10:43:42 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.2.17p1
location: forum.php

Nginx可以编译添加第三方模块more_set_headers来自定义或清除相关head信息。

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.0.15.tar.gz
tar zxvf nginx-1.0.15.tar.gz
cd nginx-1.0.15
wget -O header.zip --no-check-certificate https://github.com/agentzh/headers-more-nginx-module/zipball/v0.17rc1
unzip header.zip 
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-\
http_ssl_module --with-http_gzip_static_module --add-module=./agentzh-headers-more-nginx-module-3580526/
make && make install

应用示例,清除服务器及php信息,在配置文件http段添加以下:

more_clear_headers "X-Powered-By:";
more_clear_headers "Server:";

重新加载配置文件:

/etc/init.d/nginx reload

查看当前head头信息:

curl -I https://www.haiyun.me
HTTP/1.1 301 Moved Permanently
Date: Fri, 10 Feb 2012 10:58:38 GMT
Content-Type: text/html
Connection: keep-alive
location: forum.php

现在nginx及php信息都没了,当然也可自定义为其它信息。

Linux/Centos修改最大文件数限制

发布时间:May 7, 2012 // 分类:系统调优 // No Comments

查看系统最大文件数限制:

cat /proc/sys/fs/file-max 

查看系统当前已打开的文件数:

cat /proc/sys/fs/file-nr 

调整系统最大文件数限制:

echo "fs.file-max=65535" >> /etc/sysctl.conf
sysctl -p

查看特定进程限制:

cat /proc/1526/limits

查看指定进程已打开的文件数:

ls /proc/1526/fd/|wc -l

修改进程方面限制:

ulimit -HSn 65535 #只对当前用户有效

修改永久限制:

#centos6 /etc/security/limits.d/90-nproc.conf 
cat >>/etc/security/limits.conf<<EOF 
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF

如不能保持:

cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
EOF

Centos7下修改/etc/security/limits.conf文件只在用户登录后打开的进程有效,系统服务或通过rc.local启动的无效,系统服务修改文件/usr/lib/systemd/system/SOME_SERVICE.service添加:

[Service]
LimitNOFILE=65535

rc.local启动进程前添加:

ulimit -SHn 65535
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...