This page contains a Flash digital edition of a book.
CGI


Running PHP via CGI makes each PHP request be executed as a particular user, providing a good level of security. It is a very stable way to run PHP, and there is very little that can fail when running PHP like that. However, due to the need to start the PHP interpreter for every request, the performance is pretty bad compared to mod_php. It also means that PHP such as CGI is not compatible with opcode caching.


suPHP suPHP is very similar to running PHP as CGI. A new PHP process is started on each request running as a user. Some performance optimizations were done by suPHP developers, and it is a bit faster than using CGI. Performance is still not on par with mod_php, and opcode caching cannot be used with it.


mod_fcgid


The idea behind FastCGI is to remove the performance penalty associated with starting a new process on each request. FCGID implementation runs PHP processes under user permissions, but instead of terminating each process after the request is done, it reuses the same processes over and over but only for that user. This creates significant performance benefits compared to suPHP but only at the expense of extra memory used by all the processes that are waiting for a new request to come in.


PHP-FPM


FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation. It has gained some popularity because it is a very efficient way to run NGINX with PHP. Now that PHP-FPM is included in PHP 5.4 and mod_proxy_fcgi is included in Apache 2.4, it should become one of the standard ways to run PHP with Apache.


LiteSpeed


LiteSpeed is a commercial Web server that provides drop-in replacement for Apache. It is used by quite a few shared hosting companies, and it has its own way to run PHP via LiteSpeed’s SAPI. It runs PHP as a user and terminates PHP processes after each request. Due to a much faster way to spawn new PHP processes, it achieves very good performance results while maintaining full compatibility with opcode caching.


The benefits associated with each approach of running PHP are not limited to security, stability, and performance. For example, if you use mod_php (including mod_php with RUID2 or MPM ITK), your customers can specify PHP settings via the .htaccess file. The PECL extension htscanner allows a similar configuration via .htaccess for suPHP and PHP as CGI. Those options can be specified on a per-directory basis by the customer. With FastCGI, because of the single process serving multiple requests, you cannot have such differentiation. On the other hand, mod_fcgid allows you to specify different php.ini on a per-customer basis.


Depending on the way you are running PHP, some of the CloudLinux features are not available: Max Type mod_php (DSO)


mod_php + mod_ruid2 mod_php + MPM_ITK mod_cgi


mod_suPHP mod_fcgid PHP-FPM LiteSpeed


CPU Yes Yes Yes Yes Yes Yes Yes Yes


Memory No No No


Yes Yes Yes Yes


CL6 Only


Connections Yes Yes Yes Yes Yes Yes Yes Yes


CageFS No No


Yes Yes Yes Yes Yes Yes


Similar approaches are possible with mod_fcgid and suPHP yet are impossible with mod_php. In general, DSO (mod_php) limits your options and provides a fairly bad security model, whereas other approaches give you much more flexibility while maintaining a high level of security.


While suPHP and PHP as CGI are trusted and proven ways to run PHP, FastCGI (mod_fcgid and php_FPM) looks like the future of running PHP in shared hosting settings. It offers some of the best qualities: · PHP process executed as a user · Same process never used to serve different customers · Compatible with opcode caching · Excellent performance


If you run PHP via CGI, you can also serve different versions of PHP on a per-customer basis, such as the following example. It is done by adjusting the PHP wrapper in cPanel. The approach requires you to set up multiple PHP versions, such as /usr/ local/php/5.4 and /usr/local/php/5.3.


But after that, if a customer creates a file in their home directory such as $USER/. php-version with content 5.4, it will automatically execute /usr/local/php/5.4/ bin/php instead of /usr/bin/php.


# ! /bin/ sh


VERSION_FILE=$DOCUMENT_ROOT/../.php-version if [ -r $VERSION_FILE ]; then read VERSION < $VERSION_FILE PHP_BINARY=/usr/local/php/$VERSION/bin/php-


cgi


if [ -x $PHP_BINARY ]; then exec $PHP_BINARY


fi fi exec /usr/bin/php


028


For more information visit www.cPanel.net


Page 1  |  Page 2  |  Page 3  |  Page 4  |  Page 5  |  Page 6  |  Page 7  |  Page 8  |  Page 9  |  Page 10  |  Page 11  |  Page 12  |  Page 13  |  Page 14  |  Page 15  |  Page 16  |  Page 17  |  Page 18  |  Page 19  |  Page 20  |  Page 21  |  Page 22  |  Page 23  |  Page 24  |  Page 25  |  Page 26  |  Page 27  |  Page 28  |  Page 29  |  Page 30  |  Page 31  |  Page 32  |  Page 33  |  Page 34  |  Page 35  |  Page 36  |  Page 37  |  Page 38  |  Page 39  |  Page 40  |  Page 41  |  Page 42  |  Page 43  |  Page 44  |  Page 45  |  Page 46  |  Page 47  |  Page 48  |  Page 49  |  Page 50  |  Page 51  |  Page 52  |  Page 53  |  Page 54  |  Page 55  |  Page 56  |  Page 57  |  Page 58  |  Page 59  |  Page 60  |  Page 61  |  Page 62  |  Page 63  |  Page 64  |  Page 65  |  Page 66  |  Page 67  |  Page 68