RSS
热门关键字:  php  lighttpd  找回密码  密码找回  client
当前位置 :| 主页>技术资料>Httpd server>

Nginx 0.7.x + PHP 5.2.6(FastCGI)搭建胜过Apache十倍的Web服务器(第4版)

来源:http://blog.s135.com/read.php/366.htm 作者:张宴 时间:2008-08-29 Tag:Nginx   linux   点击:

 输入以下内容(如果您安装 Nginx + PHP 用于程序调试,请将以下的<value name="display_errors">0</value>改为<value name="display_errors">1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页):

  1. <?xml version="1.0" ?>  
  2. <configuration>  
  3.   
  4.         All relative paths in this config are relative to php's install prefix   
  5.   
  6.         <section name="global_options">  
  7.   
  8.                 Pid file   
  9.                 <value name="pid_file">/usr/local/webserver/php/logs/php-fpm.pid</value>  
  10.   
  11.                 Error log file   
  12.                 <value name="error_log">/usr/local/webserver/php/logs/php-fpm.log</value>  
  13.   
  14.                 Log level   
  15.                 <value name="log_level">notice</value>  
  16.   
  17.                 When this amount of php processes exited with SIGSEGV or SIGBUS ...   
  18.                 <value name="emergency_restart_threshold">10</value>  
  19.   
  20.                 ... in a less than this interval of time, a graceful restart will be initiated.   
  21.                 Useful to work around accidental curruptions in accelerator's shared memory.   
  22.                 <value name="emergency_restart_interval">1m</value>  
  23.   
  24.                 Time limit on waiting child's reaction on signals from master   
  25.                 <value name="process_control_timeout">5s</value>  
  26.   
  27.                 Set to 'no' to debug fpm   
  28.                 <value name="daemonize">yes</value>  
  29.   
  30.         </section>  
  31.   
  32.         <workers>  
  33.   
  34.                 <section name="pool">  
  35.   
  36.                         Name of pool. Used in logs and stats.   
  37.                         <value name="name">default</value>  
  38.   
  39.                         Address to accept fastcgi requests on.   
  40.                         Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'   
  41.                         <value name="listen_address">127.0.0.1:9000</value>  
  42.   
  43.                         <value name="listen_options">  
  44.   
  45.                                 Set listen(2) backlog   
  46.                                 <value name="backlog">-1</value>  
  47.   
  48.                                 Set permissions for unix socket, if one used.   
  49.                                 In Linux read/write permissions must be set in order to allow connections from web server.   
  50.                                 Many BSD-derrived systems allow connections regardless of permissions.   
  51.                                 <value name="owner"></value>  
  52.                                 <value name="group"></value>  
  53.                                 <value name="mode">0666</value>  
  54.                         </value>  
  55.   
  56.                         Additional php.ini defines, specific to this pool of workers.   
  57.                         <value name="php_defines">  
  58.                                 <value name="sendmail_path">/usr/sbin/sendmail -t -i</value>  
  59.                                 <value name="display_errors">0</value>  
  60.                         </value>  
  61.   
  62.                         Unix user of processes   
  63.                         <value name="user">www</value>  
  64.   
  65.                         Unix group of processes   
  66.                         <value name="group">www</value>  
  67.   
  68.                         Process manager settings   
  69.                         <value name="pm">  
  70.   
  71.                                 Sets style of controling worker process count.   
  72.                                 Valid values are 'static' and 'apache-like'   
  73.                                 <value name="style">static</value>  
  74.   
  75.                                 Sets the limit on the number of simultaneous requests that will be served.   
  76.                                 Equivalent to Apache MaxClients directive.   
  77.                                 Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi   
  78.                                 Used with any pm_style.   
  79.                                 <value name="max_children">200</value>  
  80.   
  81.                                 Settings group for 'apache-like' pm style   
  82.                                 <value name="apache_like">  
  83.   
  84.                                         Sets the number of server processes created on startup.   
  85.                                         Used only when 'apache-like' pm_style is selected   
  86.                                         <value name="StartServers">20</value>  
  87.   
  88.                                         Sets the desired minimum number of idle server processes.   
  89.                                         Used only when 'apache-like' pm_style is selected   
  90.                                         <value name="MinSpareServers">5</value>  
  91.   
  92.                                         Sets the desired maximum number of idle server processes.   
  93.                                         Used only when 'apache-like' pm_style is selected   
  94.                                         <value name="MaxSpareServers">250</value>  
  95.   
  96.                                 </value>  
  97.   
  98.                         </value>  
  99.   
  100.                         Time limit on waiting execution of single request   
  101.                         Should be used when 'max_execution_time' ini option does not terminate execution for some reason   
  102.                         <value name="request_execution_timeout">31s</value>  
  103.   
  104.                         Set open file desc rlimit   
  105.                         <value name="rlimit_files">51200</value>  
  106.   
  107.                         Set max core size rlimit   
  108.                         <value name="rlimit_core">0</value>  
  109.   
  110.                         Chroot to this directory at the start   
  111.                         <value name="chroot"></value>  
  112.   
  113.                         Chdir to this directory at the start   
  114.                         <value name="chdir"></value>  
  115.   
  116.                         Redirect workers' stdout and stderr into main error log.   
  117.                         If not set, they will be redirected to /dev/null, according to FastCGI specs   
  118.                         <value name="catch_workers_output">yes</value>  
  119.   
  120.                         How much requests each process should execute before respawn.   
  121.                         Useful to work around memory leaks in 3rd party libraries.   
  122.                         For endless request processing please specify 0   
  123.                         Equivalent to PHP_FCGI_MAX_REQUESTS   
  124.                         <value name="max_requests">51200</value>  
  125.   
  126.                         Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.   
  127.                         Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)   
  128.                         Makes sense only with AF_INET listening socket.   
  129.                         <value name="allowed_clients">127.0.0.1</value>  
  130.   
  131.                         Pass environment variables like LD_LIBRARY_PATH   
  132.                         All $VARIABLEs are taken from current environment   
  133.                         <value name="environment">  
  134.                                 <value name="HOSTNAME">$HOSTNAME</value>  
  135.                                 <value name="PATH">/usr/local/bin:/usr/bin:/bin</value>  
  136.                                 <value name="TMP">/tmp</value>  
  137.                                 <value name="TMPDIR">/tmp</value>  
  138.                                 <value name="TEMP">/tmp</value>  
  139.                                 <value name="OSTYPE">$OSTYPE</value>  
  140.                                 <value name="MACHTYPE">$MACHTYPE</value>  
  141.                                 <value name="MALLOC_CHECK_">2</value>  
  142.                         </value>  
  143.   
  144.                 </section>  
  145.   
  146.         </workers>  
  147.   
  148. </configuration>  
  9、启动php-cgi进程,监听127.0.0.1的9000端口,进程数为200(如果服务器内存小于3GB,可以只开启64个进程),用户为www:
ulimit -SHn 51200
/usr/local/webserver/php/sbin/php-fpm start


  注:/usr/local/webserver/php/sbin/php-fpm还有其他参数,包括:start|stop|quit|restart|reload|logrotate,修改php.ini后不重启php-cgi,重新加载配置文件使用reload。



上一篇:nginx+php
下一篇:apache 防盗链两例
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册