On a Ubuntu 10.10 vm I installed PHP 5.3 via package manager (installed the whole lamp stack via tasksel install lamp) for quickly testing some project.

Now I need a newer version, PHP 5.4 beta, compiled from source. I downloaded the source, compiled and installed via configure --prefix=/usr && sudo make install

That worked for the cli version that is now using the PHP 5.4 binary, but as I expected it didnt replace the version apache is using, so apache still uses PHP 5.3.

How can I find out how the via tasksel installed version was compiled/what do I need to do in order to also upgrade the PHP version used with apache?


If the version provided by Ubuntu is still in use by Apache, a php-page like this should give you the build options:


When building from source, I rarely provide my own prefix, since the default prefixes with /usr/local or whatever usually make it very easy to distinct that this is a manually compiled package. This is also earlier in path, so if you have manually compiled something that the package manager also provides - the manually compiled program will be the one preferred unless a full path is specified. If I do provide a prefix, it's probably /opt.

After building and installing php, you need to restart Apache for it to load the new version of the library.

The packages provided by Ubuntu will add two files to set up Apache to use php:


+ a symlink to these files placed in /etc/apache2/mods-enabled. Apache will also in turn load all the files in mods-enabled. If the install script does not create these config files for you, you need to do this manually.

You should probably remove the old packages, before using a new version - to avoid confusion between which version is the one in use.

  • I also thought that the compilation switches would be displayed in php info, but they arent. I restarted apache, but phpinfo still reports v 5.3 – Max Oct 27 '11 at 19:08
  • --- wait what? I used this latest today at work (but that was RHEL) ... But, checking on an Ubuntu box from home, I can see that you're right. – Kvisle Oct 27 '11 at 19:13
  • Yes, I was surprised too… I am actually used to phpinfo showing the switches, too. Dont know why thats not the case when on ubuntu. – Max Oct 27 '11 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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