As the title imply. I am requesting adding mod_fastcgi as PHP handler in whm-->Configure PHP and SuExec to make APC ( and other opcode caching) work efficiently.
now the details
refer to this wonderful blog by Brandon
/http://www.brandonturner.net/blog/2009/07/fastcgi_with_php_opcode_cache/
(I don't know what is wrong with this url I have added a copy of google cached page in attachment)
let's quote this from the blog:
Things are clear now. we need to enable and improve PHP opcode caching. PHP opcode cache is really vital and make the server really fast, reduce memory consumption at the peak load. reduce CPU load to very low rates .. etc.Both mod_fcgid and mod_fastcgi can be told to limit the number of PHP processes to 1 per user. The PHP process can then be told how many children to spawn. Unfortunately mod_fcgid will only send one request per child process. The fact that PHP spawns its own children is ignored by mod_fcgid. If we use mod_fcgid with our setup, we can only handle one concurrent PHP request. This is not good. A long running request could easily block multiple smaller requests.
mod_fastcgi will send multiple simultaneous requests to a single PHP process if the PHP process has children that can handle it. This is the reason we must use mod_fastcgi to achieve our goal of one cache per user.
The options that are enabled now in WHM are:
suPHP: secure right .. but it is also the worst option for opcode caching mechanism.
fastcgi (as mod_fcgid): read the quote above:
cgi: as CPanel said: it is neither secure nor efficient php handler. I have concluded that it never work with opcode cache.
None: .. it is really none. PHP files will be served as text files unless you define your own handler in Apache config (as I did)
Other (supported) optoin not listed here is to use mod_php. APC caching work with mod_php and it is fast. But mod_php have several other drawbacks you can read about in tons of blogs in internet.
I have tested mod_fcgid by my self. with 20 concurrent request for a single user account, mod_fcgid initiate 20 standalone php process (for that user) . each one with its own APC cache memory. that's make my server reach the memory limit too often. Also the concurrent request utilize different APC memories and that is really inefficient.
It seems that mod_fastcgi is the only good, efficient and secure handler that work very well with opcode cache liek APC. I have searched the whole internet for other solution, I have read tons of blogs. but I couldn't find better solution.
I decided to implement mod_fastcgi by myself. since neither hostgator nor Cpanel accept to do it for me. Firstly I must install and compile mod_fastcgi to work with my Apache. this blog was really nice:
/http://www.cyberciti.biz/tips/rhel-centos-fedora-apache2-fastcgi-php-configuration.html
also see this url:
/http://www.fastcgi.com/cvs/mod_fastcgi/INSTALL.AP2
after installing .. now configure Apache to use that module instead of mod_fcgid (I hate its name by the way)
in pre_virtualhost_global.conf (do not copy and paste):
LoadModule fastcgi_module modules/mod_fastcgi.so
<IfModule fastcgi_module>
FastCgiConfig -idle-timeout 20 -maxClassProcesses 1
FastCgiWrapper On
AddHandler php5-fcgi .php
Action php5-fcgi /fcgi-bin/php-fastcgi
<Location "/fcgi-bin/php-fastcgi">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
Options ExecCGI
SetHandler fastcgi-script
</Location>
SuexecUserGroup username username
Alias /fcgi-bin/ /var/www/bin/username/
</IfModule>
##### End ######
the wrapper script:
#!/bin/sh
PHP_FCGI_CHILDREN=5
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=500
export PHP_FCGI_MAX_REQUESTS
umask 0022
exec /usr/bin/php-cgi
##### End ######
disable PHP handler in whm -->Configure PHP and SuExec (select none for php 5 handler)
surely this could be better. I can define a wrapper script for each user and define suexec rule inside virtual hosts. but since I am the only user in the server.. I can define my directives globally. I am not a server administrator. I am just a good read. Most of the information here based on Brandon blog so read it .. read it ten times if you have to ( I put a copy of the blog in the attachment)
I know this make me unsupported . but this is the best solution ever found. I have now 20 php child can handle 20 concurrent request. all them utilize the same APC cache memory (150M). and the overall ram used by account is only about 730M. and the server is very stable even on high load and for long time.
I wish the feature added to whm in that way:
So it is the admin preference to use mod_fastcgi or mod_fcgid
thanks.



LinkBack URL
About LinkBacks
Reply With Quote






