Have Your Own (Chrooted) Debian LAMP Server While Running The Perfect Ubuntu Desktop 

This is a brief description about the steps to be taken to setup a Debian based Webserver (Debian Sarge alias Debian 3.1) that will run chrooted under Ubuntu 7.04.

I have followed Falkos excellent how to guide on setting up the perfect ubuntu 7.04 desktop:


However to make the desktop perfect for me I need to add one or two things. Firstly I will add AVG as I may be taking files and data to and other PC's and so I want to make sure I'm not passing on viruses, To do this I will follow another of Falkos excellent guides:


Then I need to install a web server that resembles my ISPs so that I can test before I upload them to their final resting place. I'm not running my own webserver because I connect to the net via ADSL, it may be up to 8M download, but it only gets 256K upload, which is what visitors to my sites will get and that will depend on the traffic at my local exchange.

I want my webpages to get the full benefit of the bandwidth available to my ISP's T1 connection, so I'm keeping my webpages hosted remotely.

This doesn't mean that I can't test everything thoroughly before it goes there and so I need my LAMP server to include:

  • Apache 1.3.33 (Debian GNU/Linux)
  • PHP/4.3.10-19
  • mysql 4.0.24.
  • phpmyadmin

These older versions of Apache, PHP and mysql are no longer available for installation under Ubuntu and can be only installed on debian Sarge, so instead of running this as my base platform I will install it as a minimal system on top of my Ubuntu Desktop and run the Debian programs through chroot.

If you're doing this too and have installed apache or mysql already then you will need to make sure that they are not running while you are installing or running your sarge apache/mysql. This is because the sarge apache and mysql will fail to bind to their respective listen ports if the ubuntu versions are already listening to them.

First we have to install debootstrap as we will be using it to create the minimal system. Then we can download and install Debian Sarge.

Open a Terminal window:

sudo bash
apt-get install debootstrap
mkdir sarge-dir

Now you should find your nearest debian mirror and use it to download and install the debian system. Go to http://www.debian.org/mirror/list/ and find the appropriate mirror address, then:

debootstrap sarge sarge-dir http://ftp.uk.debian.org/debian

I'm using the UK's mirror but you can change the uk part to whatever you need. After a few minutes the download and install should have completed, you need to:

mount -o bind /proc sarge-dir/proc

This will make proc filesystem available in chroot. The Proc psuedo file system is a real time, memory resident file system that tracks the processes running on your machine and the state of your system.

And from now on using the new system is a simple as typing:

chroot sarge-dir

This command puts you into chroot and you can modify files inside the newly installed sarge system.

At this point if you wish you could follow another of Falkos excellent howto guides:


Just start the tutorial after the networking section. Although some extra work will be needed to get the mail server installed properly as in that tutorial it is installed during startup, but that is for someone else to provide details of.

I'm not going to do that as I need a different version of apache and I don't need all the other stuff setup. So I'm going to edit the sources.list and update the file system.

echo deb http://ftp.uk.debian.org/debian/ sarge main > /etc/apt/sources.list
echo deb http://security.debian.org/ sarge/updates main >> /etc/apt/sources.list
apt-get update
apt-get upgrade

Now its time to install the programs that I need:

apt-get install apache php4 mysql-server phpmyadmin

Enable suExec? <-- Yes
MySQL will only install if you have a NON-NUMERIC hostname … <-- Ok
Which web server would you like to reconfigure automatically? <--- apache
Do you want me to restart apache now? <-- Yes

You may find some error messages flash up regarding the locales not being configured:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_GB.UTF-8

are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

This could be because the debootstrap method of installation may not have installed the locales.

apt-get install locales localeconf

Select locales to be generated.

[*] en_GB ISO-8859-1
[*] en_GB.ISO-8859-15 ISO-8859-15
[*] en_GB.UTF-8 UTF-8

<-- Ok

Which locale should be the default in the system environment? <-- en_GB

Manage locale configuration files with debconf? <-- Yes
If you do not wish to use the default system locale… <-- Ok
Environment settings that should override the default locale: <-- Blank
Replace existing locale configuration files? <-- Yes
If you are not sure … always supported. <-- Ok
Default system locale: <-- en_GB.UTF-8 UTF-8

I will now create a sarge user that is the same as my current ubuntu one. This means that I shouldn't have any issues with permissions when I edit my webpages in Ubuntu.

adduser user_name_in_ubuntu

The Apache configuration file is still located at: /etc/apache/httpd.conf, but it is referenced from the sarge-dir and the same thing applies to your web folder /var/www. When editing webpages from the Ubuntu Desktop go to the sarge-dir first then find /var/www/. When editing webpages in Ubuntu go to the sarge-dir first then find /var/www/

Now I will check the installations.

The apache and php installs can be done together by creating a phpinfo file in your /var/www folder with the phpinfo() command in it. Still chrooted for the moment.

nano /var/www/phpinfo.php

In this file you should type:


Point your browser to http://localhost/phpinfo.php and this should show the entire apache configuration and default settings.

The configuration file for mysql is located at: /etc/mysql/my.cnf again referenced from the sarge-dir. At this point it's also worth setting the Root password so, still chrooted:

mysql -u root

To get you to the mysql command prompt, then:

mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(your-password') WHERE user='root';

The phpmyadmin configuration file is located at: /etc/phpmyadmin/config.inc.php.

You may want to add your mysql password into it to save you logging into the phpmyadmin console each time you need to use it.

If you ever need to restart Apache or if apache doesn't start on startup, then you'll need to chroot into sarge first and then restart apache.

sudo bash
chroot sarge-dir
/etc/init.d/httpd restart
Share this page:

0 Comment(s)