Skip to content


Installing PHP5.3 RC2 on Ubuntu 8.10

Over the last couple of days I’ve been attempting to install the second release candidate for PHP 5.3 on Ubuntu 8.10. It shouldn’t have taken me more than perhaps an hour. But it took me a couple days because I was being stubborn and wanted to be more efficient (that sure backfired).

Anyway, I have to give my thanks to Jake over at The Netocracy for putting together the steps that I initially followed to install PHP 5.3. I had a few variations, but it ended up being a similar process.

I’m assuming that Apache2 isn’t installed yet, in which case you’ll need to run the following three commands to get some of the basics out of the way:
sudo apt-get install apache2
sudo apt-get install apache2-threaded-dev
sudo apt-get install libxml2-dev

In case you’re wondering why you need those, apache2 gets you your server, apache2-thread-dev gets you the apxs2 file that you’ll need when you go to configure PHP, and libxml2-dev is required for configure as well.

Next you’ll need the latest PHP snapshot. Download and extract the contents. Good, you’re ready to begin. First off you’ll need to run this:
sudo ./configure --with-apxs2=/usr/bin/apxs2

That shouldn’t give you any issues, in which case you can run this:
sudo make

Now, before you begin installing PHP, you’re going to need to edit your httpd.conf file to account for the fact that the Ubuntu installation of Apache2 doesn’t use the file (it exists, but it’s empty). It’s pretty simple, first you need to launch an editor for the file:
sudo gedit /etc/apache2/httpd.conf

And then add the following couple of lines into the file:
#stuff
LoadModule stuff

Great, now you’re ready to install:
sudo make install

Everything should’ve installed successfully at this point, in which case we need to undo what we just did to the httpd.conf file. Run the following command and delete the contents of the file (including the LoadModule line that the PHP installer just added):
sudo gedit /etc/apache2/httpd.conf

Excellent. Now we need to set up the Ubuntu way of handling modules in Apache2. We’re going to create a couple files, php5.conf and php5.load, starting with the former:
sudo gedit /etc/apache2/mods-available/php5.conf

This is what you’ll want to place in the php5.conf file:
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>

Next up is php5.load:
sudo gedit /etc/apache2/mods-available/php5.load

Add this to php5.load:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Now that you’ve set up the files for the module, you should be able to enable the module by using this command:
sudo a2enmod php5

Finally you’ll want to edit the apache2.conf file to add a line so that Apache2 doesn’t complain about not having a server name every time you start or stop it. Run this command to start editing:
sudo gedit /etc/apache2/apache2.conf

And add this line at the end of the file:
ServerName localhost

You’re ready to start using Apache2 with PHP 5.3. Let’s get Apache2 up and running:
sudo apache2ctl start

Success!

Posted in development.

Tagged with , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.