Virtualmin Professional includes a complete application deployment stack for both PHP version 4 (note that PHP 4 has been End-of-Lifed by the PHP developers, and should be used only as a last resort, or when the package is provided by your OS vendor, as in the case of CentOS/RHEL 4) and PHP version 5. Through the use of mod_fcgid, suexec, and php-cgi, it is possible to execute scripts compatible with either or both versions of PHP.
Virtualmin, by default, configures all scripts, including PHP, to execute as the owner of the virtual server account via the usage of suexec. This precludes the use of
mod_php, and takes the place of hacks like
suphp. Because execution of PHP as a CGI script can be slower than mod_php, Virtualmin makes use of
mod_fcgid which allows PHP scripts to exist as long-running processes. This leads to PHP execution speed on par with running under
mod_php while still providing a level of security only available to scripts running under suexec.
One pleasant feature of executing PHP scripts under
CGI is that each user has their own private
php.ini, which can be configured in any way that makes sense for the scripts the user is executing. Given that many scripts have requirements that can adversely effect security, it is of great value in a virtual hosting environment, but it also imposes additional complexity on the system and administrator. In general, Virtualmin maintains the
php.ini files and the administrator need never think of them, but there are instances where manual configuration is required.
php.ini files are stored in
$HOME/etc/php.ini, and can be administered using the PHP Configuration module found under the Services menu under each domain within Virtualmin. As with all configuration files under Virtualmin, it is also safe to modify the files directly using your favorite text editor.
Note: Changing /etc/php.ini will not effect changes in the php.ini of individual virtual servers, e.g. /home/mydomain.com/etc/php.ini. The php.ini of individual virtual servers have to be modified by hand, or via sed or similar command line editing tools, if required. There is no safe way of implementing global changes to all php.ini files. On some systems, there is an /etc/php.d directory, where files that are automatically included by the default php.ini. Thus, you may be able to make system-wide changes by creating a new ini file in this directory containing your directives.
As mentioned, since the php.ini files are all independently maintained when using
CGI, updating the whole system to use some new
php.ini directive can be a time-consuming process. The Virtualmin command line tools can make that process painless.
A common change is to increase the
memory_limit from the default 8M to something a bit more reasonable like 32M. To do that using the Virtualmin command line tools, for all virtual servers, you could execute:
virtualmin modify-php-ini --all-domains --ini-name memory_limit --ini-value 32M
You have to get a little fancier to append whole sections to
php.ini. One way to do that is using the
cat command and what is known as a here document.
For example, to append a Zend section to all top-level (e.g. /home/domain/etc/php.ini) php.ini files, one could execute something like the follow:
cat <<EOF >> /home/*/etc/php.ini [Zend] zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.2.6 zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.2.6 zend_optimizer.version=3.2.6 zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
Note: The Zend section is very specific to your environment and version. Do not copy this verbatim, as it will be wrong for your system and Zend!