Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
either you didn't restart apache or you only installed the cli version of php not the apache module version – Mike Jun 10 '12 at 2:58

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

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.

share|improve this answer
I would like to be able to use the latest php without much configuration. Much like doing apt-get install requires very little configuration. – user1218776 Jun 10 '12 at 19:51
up vote 1 down vote accepted

The "hook" happens when you're about to compile PHP.

$ which apx2

If there is no output, run

$ apt-get install apache2-prefork-dev
$ which apx2

copy the location that the 'which' command gave you. While inside the php source, run

$ ./configure --with-apxs2=/usr/bin/apxs2

replacing /usr/bin/apxs2 with the location on your clipboard. Restart apache and it should be ready to go!

$ /etc/init.d/apache restart
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.