假设我这里有大量图像、CSS、javascript等静态文件,分别放在后端服务器  192.168.1.5 和 192.168.1.6上,那么我如何利用nginx的反向代理功能将不同的 http_user_agent 请求发送到指定的服务器上呢?如 "Mozilla" 转发到 192.168.1.5 ,MSIE  转发到 192.168.1.6 。

Nginx web 服务器支持if条件表达式,由此来跳转或者使用不同的配置变量。在本文中需要使用 $http_user_agent 变量,它标记了用户浏览器的类别,版本以及操作系统的一些信息,语法如下:
Tags: ,

centos禁止ip段和禁止icmp 包 不指定

jed , 2012-5-28 10:31 , 服务器技术 , 评论(0) , 阅读(9901) , Via 本站原创
# iptables -F
# iptables -P INPUT ACCEPT
# iptables -P OUTPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -A FORWARD -s 124.115.0.0/24 -j DROP
# iptables -I FORWARD -d 202.96.170.164 -j DROP

补充::

单个IP的命令是
iptables -I INPUT -s 124.115.0.199 -j DROP

封IP段的命令是
iptables -I INPUT -s 124.115.0.0/16 -j DROP
iptables -I INPUT -s 124.115.3.0/16 -j DROP
iptables -I INPUT -s 124.115.4.0/16 -j DROP

封整个段的命令是
iptables -I INPUT -s 124.115.0.0/8 -j DROP

封几个段的命令是
iptables -I INPUT -s 61.37.80.0/24 -j DROP
iptables -I INPUT -s 61.37.81.0/24 -j DROP

用iptables禁止一个IP地址范围

iptables -A FORWARD -s 10.0.0.1-255 -j DROP

用防火墙禁止(或丢弃) icmp 包
iptables -A INPUT -p icmp -j DROP
Tags: ,
错误描述
BEGIN failed--compilation aborted at Makefile.PL line 24.
make[1]: *** [PerlMagick/Makefile] Error 2
make[1]: Leaving directory `/root/ImageMagick-6.4.9-10'
make: *** [all] Error 2


在安装ImageMagick出现这个错误!可能是没安装perl-CPAN

运行:

yum -y install perl-CPAN

这个命令之后再重新编译一下试试看!

我的环境是centos6
PHP的安装虽然有时候很简单,可是如果应用一多,我们安装起来就很头痛了!常见的就是PHP插件的安装问题最多了!

       其实不管是你是Apache类的应用还是Nginx类的.PHP的安装都不是很简单,虽然网上很多configure,但是那不一定是适合你的,因为很多都直接关系着你的系统及系统版本和内核.那下面就进入正题

    首先来一个最常见的就是configure: error: libjpeg.(a|so) not found

CentOS 关闭 SELinux 不指定

jed , 2012-5-23 14:07 , 服务器技术 , 评论(0) , 阅读(7403) , Via 本站原创
方法1
使用文本编辑工具打开 /etc/selinux/config
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:SELINUX=disabled
保存,关闭。
重启系统。

方法2
我们经常由于默认系统的安全性配置导致些莫名其妙的问题,比如SElinux本来是用于安全子系统的权限控制,可是搞不好就发现限制多多,我们可以用如下方法快速关闭SElinux
eaccelerator.shm_size=”32″
eAccelerator 可以使用的共享内存的数量 (以兆为单位) . “0″ 是指操作系统的默认值. 默认值是 “0″.可根据服务器的实际情况来调整,16,32,64,128都是可以的。
eaccelerator.cache_dir=”/home/php/tmp”
这个目录是给磁盘缓存使用. eAccelerator 在这里储存预先编译好的代码, 进程数据, 内容以及用户的自定义内容. 同样的数据也能被储存在共享内存中 (这样可以提高访问速度). 默认的设置是 “/tmp/eaccelerator”.
eaccelerator.enable=”1″
开启或关闭 eAccelerator。”1″ 为开启,”0″ 为关闭。默认值为 “1″。
eaccelerator.optimizer=”1″
启或关闭内部优化器,可以提升代码执行速度。”1″ 为开启,”0″ 为关闭。默认值为 “1″。

nginx 日志设置 FOR error_log 不指定

jed , 2012-5-10 13:52 , 服务器技术 , 评论(0) , 阅读(9392) , Via 本站原创
在你配置的NGINX nginx.conf中加入如下代码



         log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
        access_log  /home/wwwlogs/access.log  access;
        error_log logs/nginx_error.log  debug;
        error_page 404 = /404.php;





error_log 日志分为

nginx的log有以下几种类型: [ debug | info | notice | warn | error | crit ]  
在nginx.conf的设置:error_log logs/error.log  debug;
debug 为最详细 crit最少



在页面里使用 error_log('this is error log') 方法方便调试程序

Tags: ,
  有些时候,总是很害怕自己的网站文件有没有被人修改过,害怕被人放了新的恶意文件进来。于是,经常翻动各个文件夹去看最后修改时间什么的,费时又费力,而且最后修改时间也不一定是准确的。
    在Linux下面,有一个软件可以帮我们做到24小时不间断的监控文件改动,就是inotify-tools。只要是内核版本在2.6.13以上的系统都可以用,比如CentOS 5 。
    安装步骤:

1,下载

wget --no-check-certificate http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

2,编译

tar zxf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure
make
make install

3,一些小处理
如果是32位系统

ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib/libinotifytools.so.0

如果是64位系统

ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0

无论32或者64位系统都执行

echo 104857600 > /proc/sys/fs/inotify/max_user_watches
echo 'echo 104857600 > /proc/sys/fs/inotify/max_user_watches' >> /etc/rc.local

    使用办法:

inotifywait -m -r -d -o/var/log/change.log --timefmt '%F %T' --format '%T %w%f %e'  -e close_write -e create /home/www

其中/var/log/change.log是日志路径,/home/www是监控的网站路径

查看 php-cgi 进程数 不指定

jed , 2012-5-1 06:45 , 服务器技术 , 评论(0) , 阅读(8931) , Via 本站原创
通过命令查看服务器上一共开了多少的 php-cgi 进程

ps -fe |grep "php"|grep -v "grep"|wc -l

查看已经有多少个php-cgi进程用来处理tcp请求

netstat -anop |grep "php"|grep -v "grep"|wc -l


1个Nginx进程占用11M物理内存,5个php-cgi进程每个占用8M左右物理内存,1个MySQL服务器占用7M物理内存
Tags: ,
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]