Backporting PHP 5.3.3 from Ubuntu 10.10 to 10.04 LTS
Update 15-May-2011: The below instructions seem to be working for backporting PHP 5.3.5 from Natty as well. I have not tested it much myself, but at least it builds and can run a test copy of this blog on my local Lucid VM. Therefore I have added a dash of jQuery magic to this post so as to avoid content duplication.
Use one of the links below to jump straight to the meat:
Why Backport?
Of all the Linux flavors out there, Ubuntu is least unknown to me, so it came as a natural choice when I was selecting an operating system for the VPS that hosts this Web site. I still had to choose between the latest Ubuntu 10.10 (code named Maverick Meerkat) and Ubuntu 10.04 LTS (Lucid Lynx). LTS stands for Long-Term Support, and LTS releases of Ubuntu Server are supported for five years, as opposed to 18 months for “normal” releases. This means security updates for 10.10 will stop next April, whereas 10.04 will be serviced till April 2015. Natural choice again?
Yes and no. The problem is that I really wanted to use PHP-FPM (FastCGI Processs Manager). PHP-FPM is bundled with PHP since version 5.3.3, which is the version included in Ubuntu 10.10, whereas Ubuntu 10.04 LTS comes with PHP 5.3.2 and hence no PHP-FPM.
I have evaluated the following options for getting PHP-FPM to work on Lucid:
- Retrieve the latest PHP sources right from php.net and build them on a reference Ubuntu 10.04 system. I built version 5.3.4 and it seemed to work, but the perspective of studying patches made by the Debian team has really put me off. I also wanted to install and update everything using APT tools.
- Retrieve PHP 5.3.2 sources from the Ubuntu 10.04 repository, get PHP-FPM from SVN and try to build the regular packages. Again, I would have had to study how to add the PHP-FPM package to the build and so on.
- Use unofficial PHP-FPM packages for Ubuntu 10.04. On launchpad.net, there are at least two PHP 5.3.3 backports from Ubuntu 10.10 ([backport 1], [backport 2]), plus a build of PHP 5.3.2 with PHP-FPM. But they are unofficial, so who knows what is in there, and are not updated regularly.
- Backport PHP 5.3.3 from Ubuntu 10.10 myself. It turned out to be very simple to accomplish with the help of
apt-src
, so I have eventually stuck to this method. (Credit goes to someone known as lykwydchykyn on Ubuntu Forums.)
And here is
How You Too Can Backport PHP 5.3.3 from Maverick to Lucid
- Get yourself a clean Ubuntu 10.04 LTS Server system, e.g. by cloning a baseline VM. That will be your build system.
-
Update the build system:
sudo aptitude update sudo aptitude safe-upgrade
-
If you do not have MySQL installed on the build system, do yourself a small favor and install it now:
sudo apt-get install mysql-server
(you may leave the MySQL root user password blank when prompted.)
-
Install
apt-src
:sudo apt-get install apt-src
-
Create a new file, say,
maverick.list
in/etc/apt/sources.list.d
:sudoedit /etc/apt/sources.list.d/maverick.list
and paste the following lines into it, substituting your preferred Ubuntu 10.10 mirror URLs if needed:
deb-src http://us.archive.ubuntu.com/ubuntu maverick main deb-src http://us.archive.ubuntu.com/ubuntu maverick-updates main deb-src http://security.ubuntu.com/ubuntu maverick-security main
This will add the respective Ubuntu 10.10 source repository.
Note: It does not matter how you call the file, but it must end with “
.list
“, otherwise APT tools will ignore it silently. -
Update APT cache:
sudo apt-src update | tee apt-src-update.log
Expected output (watch for “
maverick
” lines):. . . Get:1 http://us.archive.ubuntu.com maverick Release.gpg [198B] Get:2 http://us.archive.ubuntu.com maverick-updates Release.gpg [198B] . . . Get:9 http://security.ubuntu.com maverick-security/main Sources [39.8kB] . . .
- Create a working directory, e.g. in your own home directory, and change to it:
mkdir ~/php-5.3.3-backport cd !$
-
Fetch PHP 5.3.3 sources and all builld dependencies:
apt-src install php5 | tee apt-src-install.log
Notes:
- There is no need to use
sudo
since the sources will be placed in your own directory. However, the numerous build dependencies: tools, libraries, utilities, etc., must be installed system-wide, so apt-src may ask you to enter your sudo password. apt-src
will complain that it cannot check signatures on the source packages. Apparently this happens because you do not have Ubuntu 10.10 public keys on your build system, so this warning can be safely ignored.-
apt-src
will first say it needs to retrieve 14MB of archives, then calculate dependencies and say it needs a bit more - up to 189 more packages on a baseline Ubuntu installation. Unless you mirror Ubuntu repositories locally or have a very fast Internet connection, you may be tempted to leave for a coffee at this point. However, if you have not followed the above advice,apt-src
will in particular install MySQL, prompting for a root user password three times, so you better stay in this case.
- There is no need to use
-
Do the build:
apt-src build php5 | tee apt-src-build.log
At this point, it is really important to NOT use
sudo
, otherwise MySQL will fail to start during testing.Time for lunch!
Expected output when you get back:
Over 40000 lines of informational messages and warnings I: Successfully built in current-directory/php5-5.3.3
And if you see this, there will indeed be 27 fresh
.deb
files in the working directory.
See my next post for the instructions on setting up a local repository on your Ubuntu/Debian server so as to install the desired PHP 5.3.3 packages using conventional APT tools.
If you think you could simply copy those packages to the production system and run
sudo dpkg -i deb-file-1 deb-file-2 ...
I urge you to not do that, as dpkg
does not care about dependencies, which must be installed from an Ubuntu 10.04 repository.