Quickly so to speak I have noticed this topic around, I have searched and there are plenty of solutions. However these solutions do not work for me, not only that but I'm intending to learn more about the Debian based OS.

Questions

I would like to know how to upgrade PHP 5.3 to PHP 5.4.7 compiling it from source myself without using a third-party PPA.

Is the way (explained below) the correct way of configuring PHP 5.4? I'm new to compiling from source.

Set-up

I run Ubuntu Server 12.04 64-bit. I've currently got:

PHP 5.3

MySQL-Server

Apache2

Memcached

The Problem

I initially installed PHP 5.3 using apt-get. I now wish to upgrade to PHP 5.4 due to the advantage of traits in OOP and the struct with arrays and all the other recent patches and such.

Possible Solutions

I've seen this ondrej/ppa repository, which I refuse to use, given the fact that it may work, but it's an unknown/untrusted source. Also, I'm not learning how to administer from source, using configure, make and install accordingly.

I've seen a solution compiling from source, which is essentially how I was hoping to go about it with some guidance.

Conclusion

I didn't just expect to be spoon-fed and I went out and did some manual reading and at least started the ball rolling myself; this is how far I've got.

The first thing I did was su into root (to save typing sudo all the darn time).

$ sudo su

The next thing I did was download the latest version of PHP (5.4.7) and extracted its' contents ready to configure before installing it.

Then I set --with-openssl=/usr/includes/openssl which moaned about an evp.h. I tried to locate this file using find / -type f -name evp.h and discovered it inside the /usr/includes/openssl/evp.h directory and so I again removed =/usr/includes/openssl.

2 Answers
2

You will likely need to install libxml2-dev via apt-get install libxml2-dev and then try again. This will install all the header files and other dev tools for this library. It's quite possible that this is necessary for other modules as well.

This is one of the reasons that it's a much better idea to install from binary packages and not clutter your production system with these unecessary packages. Also, to learn how to compile your own binaries, you shouldn't use a production system.

You seem to have --with-libxml twice in your configure line. Probably doesn't matter but it's best to remove the extra one.

Besides that, do you have libxml2 installed? You will need that. If you do have it installed, where is it? If it's not under /usr/lib/ (say, it's under /opt/ instead) then you will need to specify the path to it using --with-libxml=/path/to/libxml2.

It's important to completely remove the old version of PHP using apt-get purge before attempting to compile your own version. Failing to do this often ends up leaving two different versions of PHP on your system under two different paths and some difficult-to-debug problems. It's also good practice to build a .deb of your compiled PHP and install that, even if it's only for a single system and you aren't going to bother with dependencies, simply because it makes uninstalling it later on that much easier. Uninstalling a compiled package like this is about the same amount of effort as building a .deb so you might as well do it.

Make sure you also understand the differences between the CLI, CGI and Apache-module versions of PHP. With Debian-based distros these all have separate php.ini files. Make sure you uninstall all of those and compile the correct one for how you are running PHP.

Thanks for the information, to be fair you've mentioned a couple of things I had probably overlooked. That said, I was thinking of using update-alternative --config and set php to run the php54 version. But maybe this is a dumb thing to do. Either way some information above is very helpful. I shall further investigate later and return.
–
AshSep 25 '12 at 16:00