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

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

CentOS5.2安装后的一些初始化操作

1、建立一个普通权限的用户
因为root用户对系统具有全权的操作权限,为了避免一些失误的操作,建议在一般情况下,以一般用户登录系统,必要的时候需要root操作权限时,再通过“su -”命令来登录为root用户进行操作。


useradd pysche
passwd pysche
usermod -G wheel pysche

修改pam配置,使非wheel组用户不能使用su命令登录为root:
vi /etc/pam.d/su

找到
#auth required /lib/security/$ISA/pam_wheel.so use_uid

将行首的 # 去掉。

然后
vi /etc/login.defs

在文件末尾加上

SU_WHEEL_ONLY yes

2、安装yum加速工具,并更新系统

yum install yum-fastestmirror -y
yum upgrade -y

3、安装mlocate工具

yum install mlocate -y

4、root邮件的修改
在系统出现错误或有重要通知发送邮件给root的时候,让系统自动转送到我们通常使用的邮箱中,这样方便查阅相关报告和日志。
vi /etc/aliases

在文件末尾加上
root: pysche@ipbfans.org

5、locate命令设置

vi /etc/updatedb.conf

在末尾增加
DAILY_UPDATE=yes

然后运行
updatedb

6、关闭不必要的服务

比如cups

/etc/init.d/cups stop
chkconfig cups off

除了以下服务以外,其他服务默认的都可以采用刚才的方法关闭:

atd
crond
irqbalance
lvm2-monitor
microcode_ctl
network
sendmail
sshd
syslog

7、停止ipv6

vi /etc/modprobe.conf

在文件末尾加上
alias net-pf-10 off
alias ipv6 off

8、关闭SELinux

vi /etc/selinux/config

改为
SELINUX=disabled

安装sudo工具

yum install sudo -y

安装好了以后,修改sudo的配置

vi /etc/sudousers


# %wheel ALL=(ALL) NOPASSWORD:ALL
去掉前面的 # , 然后保存文件。
这样修改了以后,只有所有属于wheel组的用户能执行sudo命令,并且执行sudo命令时只需要输入自己的密码即可。

10、修改SSH配置

vi /etc/ssh/sshd_config

增加ServerKey的强度
找到

#ServerKeyBits 768

改为

ServerKeyBits 1024

不允许root用户直接登录

#PermitRootLogin Yes

改为

PermitRootLogin no

禁止空密码登录

#PermitEmptyPasswords no

去掉前面的 #

全部修改完了以后,重启服务器

转载自:http://blog.qqpsp.com/?p=31

Debian下改IP

下载的是debian-500-i386-netinst.iso,安装好后,默认可以root登录,尝试过用普通用户登录,但输入sudo时说没有这个命令,先用root登录吧
IP是DHCP得到的,不方便,想改为静态的

改IP

# vi /etc/network/interfaces
将iface eth0 inet dhcp
修改为:
iface eth0 inet static
address 192.168.0.13
netmask 255.255.255.0
gateway 192.168.0.159

auto eth0

保存退出

重启网络
# /etc/init.d/networking restart

参考文章:http://blog.chinaunix.net/u1/50685/showart_427694.html

2025年七月
« 5月    
 123456
78910111213
14151617181920
21222324252627
28293031