PHP on Ubuntu

Here’s how to get a nice little php testing environment on the new Ubuntu 9.1, the easy way…

Open a terminal and install Apache web server…

sudo apt-get install apache2

Now test your Apache set up. Open a browser and go to…
http://localhost/

If it works, you will see a subtle message telling you so.

OK, now it’s on to PHP…

Install it by:
sudo apt-get install php5 libapache2-mod-php5

When that is done, it’s time to restart the Apache server…
sudo /etc/init.d/apache2 restart

That should be it, but let’s test it out and see what the default configuration is.

Now, by default you will not be able to just save a file in the var/www/ folder of your new Apache server without root access. As such you have to open and create a php file using sudo and the terminal…
sudo gedit /var/www/testinfo.php

paste the following into the empty text file.

Save the file.

Now in your web browser go to http://localhost/testinfo.php and you will see all the information about your new PHP installation.

A little extra

There is one thing missing from this basic setup that I really like to use and that is cURL. cURL lets you do some very nice integration with different web based php sites automatically.

To install cURL, just open a terminal and type:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Then you have to restart the server as before…
sudo /etc/init.d/apache2 restart

Now you can refresh your testinfo.php page and you will see that a new module has been added, cURL.

Now you can write the next killer web application from the comfort of you own home.

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to PHP on Ubuntu

  1. Graeme says:

    Thanks Gary!

    Will be sure to do that before writing my next killer web application!

    :-) :-) :-)

Leave a Reply

Your email address will not be published. Required fields are marked *