PHP may be the reason many of you turned to Ruby in the first place, but it certainly has its place and can be installed on your Brightbox alongside your Rails apps quite easily.
The recommended configuration is to use PHP under FastCGI. This gives you control of how many PHP processes to run concurrently, and thus control over how many MySQL connections it can consume.
Additionally, running it under FastCGI is far better under heavy load, and is also the only supported configuration if you want to use PHP with the Apache worker or event mpm, which generally performs better than the standard prefork mpm.
Install the packages
sudo apt-get update sudo apt-get install apache2-mpm-event libapache2-mod-fcgid php5-cgi
This will install the packages you need for basic PHP support and immediately force a reload of Apache, interrupting service for a few seconds.
Add the configuration to Apache
Create a file called
/etc/apache2/conf.d/php-fastcgi with the following contents:
<IfModule mod_fcgid.c> AddHandler fcgid-script .php DefaultMaxClassProcessCount 4 DefaultInitEnv PHP_FCGI_MAX_REQUESTS 0 DefaultInitEnv PHP_FCGI_CHILDREN 0 FCGIWrapper /usr/bin/php-cgi .php </IfModule>
+ExecCGI is set on the document root for each virtual host that requires PHP. For example.
<Directory /path/to/document/root> Options +ExecCGI ... </Directory>
The number of PHP processes is restricted on a per-virtual host basis. To increase the maximum number of PHP processes (and thus increase the number of MySQL connections that will be consumed) change the line:
Installing PHP modules
To install a php module, install the package and restart Apache. For example, to add GD support to php:
sudo apt-get install php5-gd sudo /etc/init.d/apache2 restart
To get PHP working with the MySQL cluster, you need to install the php5-mysql package.
sudo apt-get install php5-mysql sudo /etc/init.d/apache2 restart
If you need to make any configuration tweaks to PHP, the config file is
/etc/php5/cgi/php.ini and will require normal reload of Apache to take effect:
sudo pico /etc/php5/cgi/php.ini sudo /etc/init.d/apache2 reload
We don't officially support PHP as we're not all PHP experts, but many customers (and us ourselves) are using this configuration in production with no problems. Our help desk and wiki software are PHP applications and they run perfectly in Brightboxes.