Ubuntu LTS - 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:

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

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 ago:
When I install apache this way proxy_balancer is not included =(
PickledOnion commented Wed Oct 17 09:25:23 UTC 2007 ago:
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 ago:
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:
Thanks again PO!
PickledOnion commented Mon Oct 29 09:03:14 UTC 2007 ago:
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 ago:
So using this setup where would I add a custom php.ini file?
denny commented Wed Apr 16 14:06:32 UTC 2008 ago:
why not install the lamp stack instead?? sudo tasksel install lamp-server
PickledOnion commented Wed Apr 16 14:11:35 UTC 2008 ago:
Hi denny,
Nothing wrong with that at all - this is only one option of many.
PickledOnion