Last active
February 3, 2026 22:10
-
-
Save gmodarelli/5887778 to your computer and use it in GitHub Desktop.
How to setup Ubuntu 13.04 to work with multiple PHP version at the same time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install the lamp server (Apache MySQL PHP) | |
| apt-get install lamp-server^ | |
| # Install php-farm | |
| cd /opt | |
| git clone git://git.code.sf.net/p/phpfarm/code phpfarm | |
| # Compile all the PHP version you need, eg | |
| cd /opt/phpfarm/src | |
| ./compile 5.5.0 | |
| # If the compilation fails, just install the libraries that cause the interruption | |
| # To verify the installation | |
| cd /opt/phpfarm/src/inst/bin | |
| ./php-5.5.0 --version | |
| # Install FastCGI | |
| apt-get install libapache2-mod-fastcgi apache2-mpm-worker apache2-suexec a2enmod actions fastcgi suexec | |
| # Edit the /etc/apache2/apache2.conf, add these lines before the includes | |
| FastCgiServer /var/www/cgi-bin/php-cgi-5.5.0 | |
| ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/ | |
| # Now create the file /var/www/cgi-bin/php-cgi-5.5.0, with this content | |
| #!/bin/sh | |
| PHPRC="/etc/php5/cgi/5.5.0/" | |
| export PHPRC | |
| PHP_FCGI_CHILDREN=3 | |
| export PHP_FCGI_CHILDREN | |
| PHP_FCGI_MAX_REQUESTS=5000 | |
| export PHP_FCGI_MAX_REQUESTS | |
| exec /opt/phpfarm/inst/bin/php-cgi-5.5.0 | |
| # Make the file executable | |
| chmod +x /var/www/cgi-bin/php-cgi-5.5.0 | |
| # Configure a VirtualHost to use the php version we just configured | |
| <VirtualHost *:80> | |
| ServerName example.dev | |
| DocumentRoot /var/www/example/ | |
| <Directory "/var/www/example"> | |
| AddHandler php-cgi .php | |
| Action php-cgi /cgi-bin-php/php-cgi-5.5.0 | |
| <FilesMatch "\.php$"> | |
| SetHandler php-cgi | |
| </FilesMatch> | |
| </Directory> | |
| </VirtualHost> | |
| # Add the server to /etc/hosts | |
| 127.0.0.1 example.dev | |
| # Restart apache | |
| service apache2 restart | |
| # If you don't get any error you will find a working installation | |
| # of PHP5.5.0 at http://example.dev :) | |
@0v3rth3d4wn You can. Take a look at php-fpm.
I have created a directory abc in /var/www/ path and created a new file info.php to print phpinfo(). But when I hit URL http://abc.dev/info.php . It gives "The requested URL /cgi-bin/php-cgi-5.5.9/info.php was not found on this server" error. Can anybody help to resolve this issue?
@aggarwallalit I ran into the same issue. You have to add the line:
FastCgiServer /var/www/cgi-bin/php-cgi-5.5.9
To your apache2.conf file. You can add a line for each PHP version you want to use.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this tutorial. It really works. I just needed to enable the Apache2 actions module
P.S. Is there a way to keep 2 PHP versions enabled for separate folders? I can compile 2 versions and configure 2 different virtualhosts but how can I add 2 servers in /etc/apache2/apache2.conf?