在这里让我们一起学习,一起提高!
apache方面:

1.编译源代码,修改默认的banner

2.修改默认的http状态响应码404,503等默认页面

3.访问特殊目录需要密码.htaccess

4.关闭索引目录options -Indexes

5.关闭CGI执行程序options -ExecCGI

6.apache限制目录php_admin_value open_basedir /var/www
Tags: , ,

google搜索参数详解 不指定

jed , 2011-3-29 00:06 , 搜索优化 , 评论(0) , 阅读(5252) , Via 本站原创
一、认识Google搜索
Google搜索,全球最大搜索引擎,2004年8月在美国纳斯达克上市交易.Google从2000年开始提供中文搜索服务,目前是国内用户使用率仅次于百度的搜索引擎,提供网页、新闻、图片、论坛、本地等各种搜索
1、Google网页搜索的查询参数
今天工作中某合作商拿过来代码让检查安全,一看代码加密了,比较汗,类似下面代码:
1、

1.<?php // This file is protected by copyright law & provided under license. Copyright(C) 2005-2009 www.vidun.com, All rights reserved.


安装步骤:
  (系统要求:Linux 2.6+ 内核,本文中的Linux操作系统为CentOS 5.3,另在RedHat AS4上也安装成功)

一、获取相关开源程序:
  1、【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):


sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

Tags: , , ,
从wnmp发布以来,很多朋友就问Windows下如何将Nginx加入服务中,以便于服务器重启后自动运行,我在朋友的留言中回复了,可能不是很好找,便整理在此,便于需要的朋友查找。

假设nginx安装在c:\nginx\下:

1.下载微软服务注册工具srvany.exe, instsrv.exe, srvany-instsrv存放到c:\nginx\目录下

2.安装Nginx服务, 将命令行切换到c:\nginx\,执行下列命令

instsrv NGINX c:\nginx\srvany.exe

3.在c:\nginx\下,新建一个nginx.reg文件,输入一下内容:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]
"Application"="C:\\nginx\\nginx.exe"
"AppParameters"=""
"AppDirectory"="C:\\nginx\\"

5.让服务与程序关联起来, 命令行执行
Tags: ,

配置 Nginx 支持 CGI 不指定

jed , 2010-5-13 13:56 , 服务器技术 , 评论(0) , 阅读(4270) , Via 本站原创
Nginx 不能直接执行外部可执行程序,如果要让 Nginx 支持 CGI,可以考虑安装 nginx-fcgi:

http://www.nginx.eu/nginx-fcgi.html

当前版本为 nginx-fcgi-0.4.3,需要用到以下  perl 库:



perl-FCGI
perl-Getopt
perl-IO
perl-Socket



安装 perl-FCGI 、perl-FCGI-ProcManager 和 perl-IO-ALL:



wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
tar -zxf FCGI-0.67.tar.gz
cd FCGI-0.67
perl Makefile.PL
make && make install
cd ..

wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
tar -zxf FCGI-ProcManager-0.18.tar.gz
cd FCGI-ProcManager-0.18
perl Makefile.PL
make && make install
cd ..

wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.39.tar.gz
tar zxf IO-All-0.39.tar.gz
cd IO-All-0.39
perl Makefile.PL
make && make install





安装 nginx-fcgi 脚本:


wget http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt

mv nginx-fcgi.txt /usr/sbin/nginx-fcgi

chmod +x /usr/sbin/nginx-fcgi




如果不用 sudo 方式运行 nginx-fcgi,请注释掉 nginx-fcgi 脚本中的:



if ( $> == "0" ) {
        print "\n\tERROR\tRunning as a root!\n";
        print "\tSuggested not to do so !!!\n\n";
        exit 1;
}



启动 nginx-fcgi:


nginx-fcgi -l /var/log/nginx/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock
chown nginx:nginx /var/run/nginx-fcgi.sock





注意一定要为 socket 添加 nginx 帐户的权限,否则 cgi 会执行失败。

新建 nginx-fcgi 脚本指令配置,直接从 fastcgi_params 复制模板:



cp /etc/nginx/fastcgi_params /etc/nginx/nginx_fcgi_params


去除尾部的:

# PHP only, required if PHP was built with –enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;




新建示例 cgi 站点配置:


server {
    listen       80;
    server_name  test.local;

    location ~ ^/cgi-bin/.*\.cgi$
    {
        root           /work/www/test;
        fastcgi_index  index.cgi;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include        nginx_fcgi_params;
        fastcgi_read_timeout    5m;
        fastcgi_pass   unix:/var/run/nginx-fcgi.sock;
    }
}




重启nginx即可。

/usr/local/nginx/sbin/nginx -s reload


添加系统

vi /etc/rc.d/rc.local
增加:
/usr/sbin/nginx-fcgi -l /var/log/nginx/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock
chown www:www /var/run/nginx-fcgi.sock
Tags: ,
tail -n70 /opt/php/logs/php-fpm.logs

Aug 21 10:47:28.134817 [NOTICE] fpm_children_make(), line 352: child 20649 (pool default) started
Aug 21 10:47:28.135757 [NOTICE] fpm_children_make(), line 352: child 20650 (pool default) started
Aug 21 10:47:28.136035 [NOTICE] fpm_children_make(), line 352: child 20651 (pool default) started
Aug 21 10:47:28.136971 [NOTICE] fpm_children_make(), line 352: child 20652 (pool default) started
Aug 21 10:47:28.138028 [NOTICE] fpm_children_make(), line 352: child 20653 (pool default) started
Aug 21 10:47:28.138058 [NOTICE] fpm_event_loop(), line 107: libevent: entering main loop
Aug 21 10:47:28.138119 [WARNING] fpm_stdio_child_said(), line 167: child 20653 (pool default) said into stderr: "Aug 21 10:47:28.137371 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138139 [WARNING] fpm_stdio_child_said(), line 167: child 20652 (pool default) said into stderr: "Aug 21 10:47:28.136442 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138151 [WARNING] fpm_stdio_child_said(), line 167: child 20651 (pool default) said into stderr: "Aug 21 10:47:28.136243 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138161 [WARNING] fpm_stdio_child_said(), line 167: child 20650 (pool default) said into stderr: "Aug 21 10:47:28.135276 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138171 [WARNING] fpm_stdio_child_said(), line 167: child 20649 (pool default) said into stderr: "Aug 21 10:47:28.134357 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138181 [WARNING] fpm_stdio_child_said(), line 167: child 20648 (pool default) said into stderr: "Aug 21 10:47:28.133984 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138193 [WARNING] fpm_stdio_child_said(), line 167: child 20647 (pool default) said into stderr: "Aug 21 10:47:28.132846 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138203 [WARNING] fpm_stdio_child_said(), line 167: child 20646 (pool default) said into stderr: "Aug 21 10:47:28.132496 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138213 [WARNING] fpm_stdio_child_said(), line 167: child 20645 (pool default) said into stderr: "Aug 21 10:47:28.126485 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138257 [WARNING] fpm_stdio_child_said(), line 167: child 20644 (pool default) said into stderr: "Aug 21 10:47:28.123230 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138270 [WARNING] fpm_stdio_child_said(), line 167: child 20643 (pool default) said into stderr: "Aug 21 10:47:28.116077 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138282 [WARNING] fpm_stdio_child_said(), line 167: child 20642 (pool default) said into stderr: "Aug 21 10:47:28.112005 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138292 [WARNING] fpm_stdio_child_said(), line 167: child 20641 (pool default) said into stderr: "Aug 21 10:47:28.114069 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138303 [WARNING] fpm_stdio_child_said(), line 167: child 20640 (pool default) said into stderr: "Aug 21 10:47:28.109341 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138314 [WARNING] fpm_stdio_child_said(), line 167: child 20639 (pool default) said into stderr: "Aug 21 10:47:28.109003 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138325 [WARNING] fpm_stdio_child_said(), line 167: child 20638 (pool default) said into stderr: "Aug 21 10:47:28.108659 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138334 [WARNING] fpm_stdio_child_said(), line 167: child 20637 (pool default) said into stderr: "Aug 21 10:47:28.107447 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138344 [WARNING] fpm_stdio_child_said(), line 167: child 20636 (pool default) said into stderr: "Aug 21 10:47:28.105309 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138354 [WARNING] fpm_stdio_child_said(), line 167: child 20635 (pool default) said into stderr: "Aug 21 10:47:28.104641 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138364 [WARNING] fpm_stdio_child_said(), line 167: child 20634 (pool default) said into stderr: "Aug 21 10:47:28.103690 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138375 [WARNING] fpm_stdio_child_said(), line 167: child 20633 (pool default) said into stderr: "Aug 21 10:47:28.101346 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138386 [WARNING] fpm_stdio_child_said(), line 167: child 20632 (pool default) said into stderr: "Aug 21 10:47:28.100429 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138396 [WARNING] fpm_stdio_child_said(), line 167: child 20631 (pool default) said into stderr: "Aug 21 10:47:28.098602 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138407 [WARNING] fpm_stdio_child_said(), line 167: child 20630 (pool default) said into stderr: "Aug 21 10:47:28.096524 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138418 [WARNING] fpm_stdio_child_said(), line 167: child 20629 (pool default) said into stderr: "Aug 21 10:47:28.094494 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138428 [WARNING] fpm_stdio_child_said(), line 167: child 20628 (pool default) said into stderr: "Aug 21 10:47:28.093321 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138446 [WARNING] fpm_stdio_child_said(), line 167: child 20627 (pool default) said into stderr: "Aug 21 10:47:28.092317 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138457 [WARNING] fpm_stdio_child_said(), line 167: child 20626 (pool default) said into stderr: "Aug 21 10:47:28.091560 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138467 [WARNING] fpm_stdio_child_said(), line 167: child 20625 (pool default) said into stderr: "Aug 21 10:47:28.088570 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138476 [WARNING] fpm_stdio_child_said(), line 167: child 20624 (pool default) said into stderr: "Aug 21 10:47:28.084022 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138486 [WARNING] fpm_stdio_child_said(), line 167: child 20623 (pool default) said into stderr: "Aug 21 10:47:28.081269 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138495 [WARNING] fpm_stdio_child_said(), line 167: child 20622 (pool default) said into stderr: "Aug 21 10:47:28.080984 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138505 [WARNING] fpm_stdio_child_said(), line 167: child 20621 (pool default) said into stderr: "Aug 21 10:47:28.076449 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138514 [WARNING] fpm_stdio_child_said(), line 167: child 20620 (pool default) said into stderr: "Aug 21 10:47:28.077009 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138523 [WARNING] fpm_stdio_child_said(), line 167: child 20619 (pool default) said into stderr: "Aug 21 10:47:28.069281 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138533 [WARNING] fpm_stdio_child_said(), line 167: child 20618 (pool default) said into stderr: "Aug 21 10:47:28.068479 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138542 [WARNING] fpm_stdio_child_said(), line 167: child 20617 (pool default) said into stderr: "Aug 21 10:47:28.066524 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138552 [WARNING] fpm_stdio_child_said(), line 167: child 20616 (pool default) said into stderr: "Aug 21 10:47:28.065905 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138562 [WARNING] fpm_stdio_child_said(), line 167: child 20615 (pool default) said into stderr: "Aug 21 10:47:28.065567 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138571 [WARNING] fpm_stdio_child_said(), line 167: child 20614 (pool default) said into stderr: "Aug 21 10:47:28.062630 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138583 [WARNING] fpm_stdio_child_said(), line 167: child 20613 (pool default) said into stderr: "Aug 21 10:47:28.059793 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138593 [WARNING] fpm_stdio_child_said(), line 167: child 20612 (pool default) said into stderr: "Aug 21 10:47:28.056453 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138604 [WARNING] fpm_stdio_child_said(), line 167: child 20611 (pool default) said into stderr: "Aug 21 10:47:28.053536 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138614 [WARNING] fpm_stdio_child_said(), line 167: child 20610 (pool default) said into stderr: "Aug 21 10:47:28.052367 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138632 [WARNING] fpm_stdio_child_said(), line 167: child 20609 (pool default) said into stderr: "Aug 21 10:47:28.051691 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138642 [WARNING] fpm_stdio_child_said(), line 167: child 20608 (pool default) said into stderr: "Aug 21 10:47:28.051512 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138653 [WARNING] fpm_stdio_child_said(), line 167: child 20607 (pool default) said into stderr: "Aug 21 10:47:28.048297 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138664 [WARNING] fpm_stdio_child_said(), line 167: child 20606 (pool default) said into stderr: "Aug 21 10:47:28.048226 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138674 [WARNING] fpm_stdio_child_said(), line 167: child 20605 (pool default) said into stderr: "Aug 21 10:47:28.047565 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138684 [WARNING] fpm_stdio_child_said(), line 167: child 20604 (pool default) said into stderr: "Aug 21 10:47:28.044563 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138694 [WARNING] fpm_stdio_child_said(), line 167: child 20603 (pool default) said into stderr: "Aug 21 10:47:28.042441 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138704 [WARNING] fpm_stdio_child_said(), line 167: child 20602 (pool default) said into stderr: "Aug 21 10:47:28.040655 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138714 [WARNING] fpm_stdio_child_said(), line 167: child 20601 (pool default) said into stderr: "Aug 21 10:47:28.030726 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138726 [WARNING] fpm_stdio_child_said(), line 167: child 20600 (pool default) said into stderr: "Aug 21 10:47:28.024933 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138736 [WARNING] fpm_stdio_child_said(), line 167: child 20599 (pool default) said into stderr: "Aug 21 10:47:28.021018 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138746 [WARNING] fpm_stdio_child_said(), line 167: child 20598 (pool default) said into stderr: "Aug 21 10:47:28.017561 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138757 [WARNING] fpm_stdio_child_said(), line 167: child 20597 (pool default) said into stderr: "Aug 21 10:47:28.016513 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138767 [WARNING] fpm_stdio_child_said(), line 167: child 20596 (pool default) said into stderr: "Aug 21 10:47:28.012491 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138778 [WARNING] fpm_stdio_child_said(), line 167: child 20595 (pool default) said into stderr: "Aug 21 10:47:28.011405 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138789 [WARNING] fpm_stdio_child_said(), line 167: child 20594 (pool default) said into stderr: "Aug 21 10:47:28.010464 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138799 [WARNING] fpm_stdio_child_said(), line 167: child 20593 (pool default) said into stderr: "Aug 21 10:47:28.008462 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138820 [WARNING] fpm_stdio_child_said(), line 167: child 20592 (pool default) said into stderr: "Aug 21 10:47:28.007855 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138832 [WARNING] fpm_stdio_child_said(), line 167: child 20591 (pool default) said into stderr: "Aug 21 10:47:28.007511 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
Aug 21 10:47:28.138842 [WARNING] fpm_stdio_child_said(), line 167: child 20590 (pool default) said into stderr: "Aug 21 10:47:28.004508 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"
网上搜了下说是系统最大文件数和php-fpm.conf中rlimit_files不匹配的原因

一、我的配置
centos5.2 64bit
nginx0.7.61+php5.2.10+php-5.2.10-fpm-0.5.13

/etc/rc.local

ulimit -Shn 51200
/opt/nginx/etc/nginx.conf

worker_rlimit_nofile 51200;
events
{
     use epoll;
  
     worker_connections 51200;
}
/opt/php/etc/php-fpm.conf

51200
ulimit -n
1024

cat /proc/sys/fs/file-max
765985

cat /proc/sys/fs/file-nr
3060 0 765985

二、修改
1.
/etc/security/limits.conf
文件尾部增加

* soft nofile 51200
* hard nofile 51200
设置为星号代表全局
这个当中的硬限制是实际的限制,而软限制,是warnning限制,只会做出warning。

2.
退出控制台重新登录

ulimit -n
51200

3.
php-fpm reload不会生效,所以用 php-fpm restart

4.
检查一下
tail /opt/php/logs/php-fpm.log
ok,收工

Tags: ,
We recently decided to test nginx with our CDN.  It seems that lighttpd just isn’t up the the task of serving high-connection rate services.  It was grinding to a halt on our systems as they started processing 400 – 600 connections per second.  We ended up running multiple lighttpd’s on single servers to alleviate this problem, but in doing so we were losing all the benefits of lighttpd such as stat caching etc.

Enter nginx.  Nginx is another web server similar in nature to lighttpd.  We thought we’d give it a go with just one of our clients which processes in the vicinity of 800 connections per second.  Here is our commentary:
1) nginx seems very well designed and coded – I find the configuration absolutely brilliant and very self explanatory to a developer.  I think a non-developer might have a bit of a hard time with it however, but I’m I’m sure they could work it out.  One of the biggest hates in all the forums is how badly nginx is documented – it’s NOT true.  I found the core features to be very well documented (in English) albeit in various locations.

2) Speed – The improvement was immediately noticable.  This webserver software is indeed faster than lighttpd.  Anybody wishing to argue – go home.  It’s faster under both small loads and large loads.

3) High-volume of connections – Handles it smoothly.  Lighttpd really had problems here.  Nginx doesn’t seem to care.

We did get one error which didnt seem documented anywhere so we ended up going through the source code to track down the issue.  The error message we were getting was:

“upstream sent too big header while reading response header from upstream”

Which would cause 502 Bad Gateway errors.  Apparantly this is an expected error with the default fastcgi configuration as the buffer size is not big enough for processing our headers (not sure why considering I think the default is 4k?).  Anyway – here is our fastcgi paramaters that appear to be currently working:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on

Overall, we’re going to let nginx run for a few weeks and see if we run into any more little problems.  If we don’t, we’ll look into changing our entire CDN over to nginx as lighttpd just isn’t cutting it performance wise, and the bug support seems almost non existent these days.  Personally, I think lighttpd’s days are numbered and I’m expecting its distribution to start reducing sometime over the next 6 months….

Tags: ,
分页: 2/2 第一页 上页 1 2 最后页 [ 显示模式: 摘要 | 列表 ]