How to point apache to different version of php

apache-2.2php5

I installed apache on ubuntu like so:

apt-get install apache2

I initially had installed PHP by doing:

apt-get install php5

That gave me php 5.3.x. Now I want to use the latest version php 5.4.x so I installed from source. Through the cli

$ php -v

outputs the correct version PHP 5.4.3

When I run phpinfo() through the web, I still get php5.3.x. How would I point apache to use my newly installed php instead?

Best Answer

You can put this in a vhost config:

AddHandler php-cgi-script .php
Action php-cgi-script /php5/php5-cgi

The accompanying php module configuration would be:

ScriptAlias /php5 /usr/bin
<Directory /usr/bin/>
    Options +ExecCGI +FollowSymLinks
    AllowOverride None
</Directory>

I don't know exactly how it would fit in your setup, so you need to improvise a bit.

Also, a very big beware: there was a huge security bug in PHP CGI. Test if it effects you.

Related Topic