大佬教程收集整理的这篇文章主要介绍了linux – 一个php-fastcgi进程阻止所有其他PHP请求,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用mod_fcgid的主要原因是控制PHP内存使用量.使用mod_PHP,所有单独的Apache forks在服务PHP后都会在内存中增长.
我也转而使用apache2-worker模型,因为在Apache之外存在所有线程不安全的PHP代码.
我的FastCGI脚本如下所示:
#!/bin/sh #export PHPRC=/etc/PHP/fastcgi/ export PHP_FCGI_CHILDREN=5 export PHP_FCGI_MAX_requESTS=5000 global_root=/srv/www/vhosts.d/ exec /usr/bin/php-cgi5 \ -d open_basedir=$global_root:/tmp:/usr/share/PHP5:/var/lib/PHP5 \ -d disable_functions="exec,sHell_exec,system"
我的Apache配置如下所示:
<IfModule fcgid_module> FcgidIPCDir /var/lib/apache2/fcgid/ FcgidProcessTableFile /var/lib/apache2/fcgid/shm FcgidMaxProcessesPerClass 1 FcgidInitialEnv RAILS_ENV production Fcgi@L_874_16@Timeout 600 AddHandler fcgid-script .fcgi FcgidConnectTimeout 20 MaxrequestLen 16777216 <Filesmatch "\.PHP$"> AddHandler fcgid-script .PHP Options +ExecCGI FcgidWrapper /srv/www/cgi-bin/PHP5-wrapper.sh .PHP </Filesmatch> DirectoryIndex index.PHP </IfModule>
问题不是PHP,而是mod_fcgid.虽然PHP会产生多个孩子,但mod_fcgid对此一无所知,并且会为每个孩子提供一个请求.因此,当使用FcgidMaxProcessesPerClass 1时,所有PHP执行都会在彼此之后发生. *
提出的解决方案
链接到:http://www.brandonturner.net/blog/2009/07/fastcgi_with_php_opcode_cache/解释了如何使用没有此限制的mod_fastcgi.它会向同一个孩子发送多个请求.
[*]请注意,不使用FcgidMaxProcessesPerClass 1会导致许多单独的PHP,Ruby等实例.虽然它们都能够在单个进程内部处理许多请求.
<IfModule mod_fastcgi.c> # Needed for for suEXEC: FastCgiWrapper On FastCgiConfig -idle-timeout 20 -maxClassProcesses 1 -initial-env RAILS_ENV=production FastCgiIpcDir /var/lib/apache2/fastcgi AddHandler PHP5-fcgi .PHP Action PHP5-fcgi /.fcgi-bin/PHP5-wrapper.sh DirectoryIndex index.PHP ScriptAlias /.fcgi-bin/ /srv/www/cgi-bin/ <LOCATIOn "/.fcgi-bin/PHP5-wrapper.sh"> Order Deny,Allow Deny from All #Allow from all Allow from env=REDIRECT_STATUS Options ExecCGI SetHandler fastcgi-script </LOCATIOn> # Startup PHP directly FastCgiServer /srv/www/cgi-bin/PHP5-wrapper.sh # Support dynamic startup AddHandler fastcgi-script fcg fcgi fpl </IfModule>
以上是大佬教程为你收集整理的linux – 一个php-fastcgi进程阻止所有其他PHP请求全部内容,希望文章能够帮你解决linux – 一个php-fastcgi进程阻止所有其他PHP请求所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。