寻觅生命中的那一片浅草......

文章属于类别 应用软件

NginxChsHttpLimit zoneModule

本模块可以针对条件,进行会话的并发连接数控制。(例如:限制每个IP的并发连接数。)

__配置示例__

http {
: limit_zone   one  $binary_remote_addr  10m;

: ...

: server {

: ...

: location /download/ {
: limit_conn   one  1;
: }

指令

  • [#limit_zone limit_zone]
  • [#limit_conn limit_conn]

Template:Anchor

limit_zone

语法: limit_zone zone_name $variable the_size

默认值: no

作用域: http

本指令定义了一个数据区,里面记录会话状态信息。
$variable 定义判断会话的变量;the_size 定义记录区的总容量。

例子:

limit_zone   one  $binary_remote_addr  10m;

定义一个叫“one”的记录区,总容量为 10M,以变量 $binary_remote_addr 作为会话的判断基准(即一个地址一个会话)。
您可以注意到了,在这里使用的是 $binary_remote_addr 而不是 $remote_addr。

$remote_addr 的长度为 7 至 15 bytes,会话信息的长度为 32 或 64 bytes。而 $binary_remote_addr 的长度为 4 bytes,会话信息的长度为 32 bytes。

当区的大小为 1M 的时候,大约可以记录 32000 个会话信息(一个会话占用 32 bytes)。
Template:Anchor

limit_conn

语法: limit_conn zone_name the_size

默认值: no

作用域: http, server, location

指定一个会话最大的并发连接数。当超过指定的最发并发连接数时,服务器将返回 “Service unavailable” (503)。

例子:

limit_zone   one  $binary_remote_addr  10m;

: server {
: location /download/ {
: limit_conn   one  1;
: }

定义一个叫“one”的记录区,总容量为 10M,以变量 $binary_remote_addr 作为会话的判断基准(即一个地址一个会话)。限制 /download/ 目录下,一个会话只能进行一个连接。简单点,就是限制 /download/ 目录下,一个IP只能发起一个连接,多过一个,一律503。

转载自:NginxChsHttpLimit zoneModule

PHP FastCGI 进程管理器: PHP-FPM

网址:

最近 PHP-FPM (PHP FastCGI Process Manager) 这个话题在讨论组里很受关注。使用 PHP 的朋友对于 FastCGI 进程的管理估计都很头疼,比如 Nginx 下的 FastCGI 就有不少人用的 Lighttpd 的 spawn-fcgi 来对进程进行管理。但这样存在不少缺点(中文版本)。

PHP-FPM 配置起来很简单,但有一点比较有意思的是如何确定 Worker 的数量。PHP-FPM 作者 Andrei Nigmatulin 在新闻组里提到的小技巧如下:

1) 用 Linux top 命令观察 (这个方式比较土)
2) 用 'netstat -np | grep 127.0.0.1:9000' 收集数据。
设置  php-fpm.conf 中的 max_children 的数值使 等待的数量变为最小。

目前使用 PHP-FPM 还只是通过 Patch 方式,然后编译,期待能够早点并入正式的 PHP 代码中。当然,PHP 核心开发的那些大爷们也不知都在忙什么呢,莫非还在为 Unicode 较劲呢?

PHP-FPM高负载技巧 (PHP-FPM on highload tips)

When you running a highload website with PHP-FPM via FastCGI, the following tips may be useful to you : )
如果您高负载网站使用PHP-FPM管理FastCGI,这些技巧也许对您有用:)

1. Compile PHP’s modules as less as possible, the simple the best (fast);
1.尽量少安装PHP模块,最简单是最好(快)的

2. Increas PHP FastCGI child number to 100 and even more. Sometime, 200 is OK! ( On 4GB memory server);
2.把您的PHP FastCGI子进程数调到100或以上,在4G内存的服务器上200就可以
注:我的1g测试机,开64个是最好的,建议使用压力测试获取最佳值

3. Using SOCKET PHP FastCGI, and put into /dev/shm on Linux;
3.使用socket连接FastCGI,linux操作系统可以放在 /dev/shm中
注:在php-fpm.cnf里设置
<value name=”listen_address”>/tmp/nginx.socket</value>就可以通过socket连接FastCGI了,/dev/shm是内存文件系统,放在内存中肯定会快了

4. Increase Linux “max open files”, using the following command (must be root):
# echo ‘ulimit -HSn 65536′ >> /etc/profile
# echo ‘ulimit -HSn 65536 >> /etc/rc.local
# source /etc/profile
4.调高linux内核打开文件数量,可以使用这些命令(必须是root帐号)
echo ‘ulimit -HSn 65536’ >> /etc/profile
echo ‘ulimit -HSn 65536’ >> /etc/rc.local
source /etc/profile
注:我是修改/etc/rc.local,加入ulimit -SHn 51200的

5. Increase PHP-FPM open file description rlimit:
# vi /path/to/php-fpm.conf
Find “<value name=”rlimit_files”>1024</value>”
Change 1024 to 4096 or higher number.
Restart PHP-FPM.
5. 增加 PHP-FPM 打开文件描述符的限制:
# vi /path/to/php-fpm.conf
找到“<value name=”rlimit_files”>1024</value>”
把1024 更改为 4096 或者更高.
重启 PHP-FPM.

6. Using PHP code accelerator, e.g eAccelerator, XCache. And set “cache_dir” to /dev/shm on Linux.
6.使用php代码加速器,例如 eAccelerator, XCache.在linux平台上可以把`cache_dir`指向 /dev/shm

来源:http://groups.google.com/group/highload-php-en/browse_thread/thread/e48a9fce7ee116ab/db412d43c1c3f36a

转载自:http://willko.javaeye.com/blog/333270

postfix权威指南笔记

pcre perl兼容正则表达式

postconf -m 查看postfix支持的函数

postmap -q 测试任何种类的查询表

postmap -q hash:/etc/postfix/transport
postmap -q mysql:/etc/postfix/transport.cf

postalias

postfix check
检查配置文件是否有问题,文件与目录的拥有权是否正确,甚至帮你创建任何遗失的目录,

postfix的等效机制是定义在main.cf的queue_run_delay参数,默认值是1000秒

postfix -D 得出调试信息

/etc/services —查看下文件内容

postsuper -h 保留邮件队列

postsuper -H 将保留的邮件队列重新激活

postsuper -r ALL 将被延迟了的邮件重新排队

postcat -q 邮件ID 查看一个队列文件的内容

要求postfix立刻投递滞留在队列里的邮件的操作成为清空(flush),
命令是 postqueue -f

postqueue -s 清空寄到特定站点的邮件

postconf -l 查看postfix支持的锁机制

最简单的虚拟网域模式,是每位用户都可以收到每个网域的邮件。就用户的感受而言,
就好像同一个邮箱有多个地址一样。这种模式的设定方法最简单,只要将所有虚拟网域名称都列在mydestination参数,并像平常一样为每一位用户(不管他们在哪一个网域)都创建自己的系统账户,他们就可以收到写给任何网域的邮件。

默认情况下,flush只管理relay_domains所列的网域。如果还有其他网域也需要快速清空服务,你可以将它们的网域名称列在fast_flush_domains

apache2关于libphp5.so的permission denied的解决方法

今天弄一个CentOS,安装httpd-2.2.8 和php-5.2.5,一切顺利。
最后一步重新启动apache报如下错误:
httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

原因:是Linux有一个SELinux保护模式引起的。

解决办法:

1关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启
这个方法可能会对服务器带来风险。

2不关闭SELINUX的方法:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1

转载自:http://hi.baidu.com/shengit/blog/item/9d4da12b3b682993033bf6a2.html

2025年五月
« 5月    
 1234
567891011
12131415161718
19202122232425
262728293031