Ubuntu Dapper - installing Apache and PHP5

Ubuntu LTS (Dapper) comes with Apache v.2.0.55 and PHP v.5.1.2. and is easily installed via the 'apt-get' command.

The advantage of using packages is that you will get any security updates from Ubuntu (if and when distributed) and dependencies are automatically taken care of.


Apache Install

A basic Apache install is very easy:

sudo apt-get install apache2 apache2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

At the end of the install you will see this warning:

apache2: Could not reliably determine the server's fully qualified domain name,
using 127.0.0.1 for ServerName

Please see this Apache Configuration Article for details of configuring the ServerName setting.

If you navigate to your Slice IP address:

http://123.45.67.890

You will not see a welcome screen as you might expect but rather this: Apache Directory Listing

If you click into the 'apache2-default' directory the welcome screen will be displayed: Apache Welcome Screen

If this concerns you and you would rather see the default welcome screen instead of the directory listing, then open up the default vhost file:

sudo nano /etc/apache2/sites-available/default

and uncomment the following line (remove the #):

RedirectMatch ^/$ /apache2-default/

Reload Apache:

sudo /etc/init.d/apache2 reload

Now when you visit your IP address you are automatically redirected to the Apache welcome screen rather than seeing the directory listing.

PHP5 Install

Let's move on to the PHP5 install. I'm not going to install all the modules available. Just some common ones.

As before, due to using apt-get to install PHP5, any dependencies are taken care of:

sudo apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-mhash php5-mysql php5-snmp php5-sqlite php5-xmlrpc php5-xsl

You may have notice that Apache was restarted during the install, so everything is now ready to use with PHP v.5.1.2.

Almost

Well, almost ready to use.

We do need to configure Apache for our setup so we can host multiple sites and so on.

The next article will go through the Ubuntu LTS (Dapper) Apache layout and configuration as it differs slightly from the 'classic' layout you might expect if you had installed from source.

PickledOnion.

Article Comments:

Paul commented Tue Oct 16 22:11:09 UTC 2007:

When I install apache this way proxy_balancer is not included =(

PickledOnion commented Wed Oct 17 09:25:23 UTC 2007:

Paul,

Ubuntu LTS includes Apache 2.0 which does not include the proxy module. You will need Apache 2.2 for that.

If you note, I have not included a mongrels/proxy article for Ubuntu LTS for this very reason.

You can, of course, install Apache from source if you wanted v2.2.

PickledOnion.

iain duncan commented Sun Oct 28 22:04:01 UTC 2007:

Sorry if this is a stupid question, does that also mean modproxy is not available? If I would like modproxy for TurboGears deployment, would I be better off:

  • upgrading to Fiesty
  • pinning an apache upgrade
  • installing apache from source?

Thanks again PO!

PickledOnion commented Mon Oct 29 09:03:14 UTC 2007:

Iain,

That is correct, mod_proxy is not available with Apache 2.0.

All of the options you mention are valid ways of obtaining Apache 2.2 although you may also want to look at other servers such as nginx or Litespeed.

PickledOnion.

adam commented Wed Mar 12 14:33:56 UTC 2008:

So using this setup where would I add a custom php.ini file?

denny commented Wed Apr 16 14:06:32 UTC 2008:

why not install the lamp stack instead?? sudo tasksel install lamp-server

PickledOnion commented Wed Apr 16 14:11:35 UTC 2008:

Hi denny,

Nothing wrong with that at all - this is only one option of many.

PickledOnion

Eric Jarvies commented Mon Dec 27 13:35:05 UTC 2010:

Package 'apache2-common' has become obsolete, thus, it should be replaced with 'apache2.2-common', e.g.-

sudo apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Regards,

Eric Jarvies Cabo San Lucas, Baja California Sur, Mexico

Eric Jarvies commented Mon Dec 27 13:40:51 UTC 2010:

When the Apache web server has been installed, it now displays this message:

===== It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

In the above tutorial, you are showing the old(er) 'Index of" message. So this is just a friendly reminder to update the corresponding visuals.

Regards,

Eric Jarvies Cabo San Lucas, Baja California Sur, Mexico

Jered commented Fri Jan 07 20:52:32 UTC 2011:

This article was actually written for an older LTS version of Ubuntu, Dapper Drake. I changed the title of the article to prevent the generic "LTS" part from tricking people into thinking it's written for a more recent LTS version like Lucid.

If you are trying to set up apache with Lucid, you might check out this newer article series for setting up apache.

If you actually do mean that Dapper's package names and default welcome screen for apache changed, let me know for certain and I will indeed update this article with those changes.

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)