Debian Etch - installing Apache and PHP5

Debian Etch comes with Apache v.2.2.3 and PHP v.5.2.0. Although neither of these are the absolutely latest packages they do contain the changes that web administrators generally want, such as Apache's mod_proxy module.

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


Preparation

As we are using aptitude to install Apache and PHP5, there is very little preparation required.

However, I'm not going to install all the PHP modules that are available. If you want to see what is there, do a quick:

aptitude search php

Apache Install

A basic Apache install is very easy:

sudo aptitude install apache2 apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

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

Starting web server (apache2)...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.

force-reload

If you scroll up slightly you will see a list of the modules that have been installed such as:

...
Module dir installed; run /etc/init.d/apache2 force-reload to enable.
Module env installed; run /etc/init.d/apache2 force-reload to enable.
Module mime installed; run /etc/init.d/apache2 force-reload to enable.
...

It would seem a good idea to do what it asks:

sudo /etc/init.d/apache2 force-reload

You can see the default welcome screen by navigating to your Slice IP address:

http://123.45.67.890

Where you will see this wonderfully simple page:

Apache Welcome Screen

Well, that's a nice start.

PHP5 Install

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

As before, due to using aptitude to install PHP5, any dependencies are taken care of:

sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd   php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell 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.

Almost

Well, it's almost ready.

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

However, this will be the subject of the next article. This one got it installed on your Debian Etch Slice and, as shown, it is easy to install using aptitude.

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

PickledOnion.

Article Comments:

dave commented Wed Sep 12 16:54:40 UTC 2007:

What I'm struggling with is the directory structure / users / groups and permissions aspect of the apache vhost setup. Hopefully that will be part of part 2 :-)

Just want to make sure I have the right users/groups and directory structure for a secure setup.

thx onion!

PickledOnion commented Wed Sep 12 17:39:53 UTC 2007:

Dave,

I understand. It will be in the next couple of article - the very next one deals with the Debian Apache Layout and a2ensite, a2dissite and so on.

I hope by the end of the series I will have covered most areas.

PickledOnion.

Andy Croll commented Wed Sep 19 09:13:27 UTC 2007:

Do these instructions work equally well with Ubuntu?

PickledOnion commented Wed Sep 19 09:20:14 UTC 2007:

Andy,

Possibly.

As Ubuntu is Debian based the basics should be the same but I have not tested it on Ubuntu. There will be a separate set of articles for Ubuntu as time goes by.

One thing to note is that the Apache versions differ between distributions but the rest may be the same. LTS has Apache 2.0 for example.

I hope that helps but I have no guarantee and can't do more than say they might work on a Slice using Ubuntu :)

PickledOnion.

Andy Croll commented Wed Sep 19 09:23:06 UTC 2007:

Cheers Mr Onion.

Nothing ventured... :-)

I'll take notes as I go through.

Jim N commented Wed Oct 03 20:25:37 UTC 2007:

For some reason, on my machine I had to make one manual change to get it to work. Change

AddHandler php-script .php

to

AddHandler php5-script .php

in /etc/apache2/apache2.conf, then restart apache2.

It may have been a problem since I previously had php4 installed.

Big Pizzle commented Mon Oct 22 22:16:42 UTC 2007:

I just tried this on Ubuntu Gutsy and it works like a charm.

Kudos to SliceHost!

Seo Valencia commented Sat May 17 22:28:48 UTC 2008:

I have a problem with my php on my personal computer configuration... when type php -v

says me bash:php: command not found

I think is because i have php4 and php5... I will try to uninstall and try your suggestions on my debian etch.

Christefano commented Fri Jul 11 03:28:25 UTC 2008:

Seo Valencia, you also need to install php5-cli in order to have access to PHP from the command line.

sudo aptitude install php5-cli

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)