Who this post is for: anyone who’d like to quickly set up a Debian Etch development server with a LAMP stack and put it in a closet somewhere to be accessed remotely from a workstation via VNC. In this walk through, I install a bare bones GNOME desktop, but you could get away with an even skinnier desktop environment if you’re partial to something like XFce4. It’s your choice … and that’s exactly why you and I run Linux :)

This is what I did earlier this evening …

6:59 PM – Insert CD and boot into the installer

The CD image being used here is the netinst image. TIP: Typically, it’s quickest to only choose the Standard System task while the CD is in the drive because the more you install from the disc image, the more packages may need to be upgraded later during (or after) the install.

Just bang through the default prompts for a minute or so until the network setup begins.

7:00 PM – Let installer use DHCP

You could set the network properties manually, but letting the installer blow through things using DHCP actually saves some time … more detail on that later. For now, just take this at face value: if you have a DHCP server, use it for now.

7:00 PM (still) – Configure a host and domain name

While ‘debian’ is a wicked cool choice, it’s probably neither A.) to your liking, nor B.) a good idea to advertise your system’s OS in 10,000 watt flashing lights. Choose something that makes you happy — since hockey season is only days away, I chose Datsyuk.

If your DHCP server is setup accordingly, the domain name on the next screen will be filled in automatically. If not, the value will be blank. Either way, a suggestion is to leave the default value in there. Clowns may bust in on the spot and eat you if you stray from this advice …

7:01 PM – Partition and format the disk

Again, no need to think too much here. Choose whatever makes sense for your setup.

7:02 PM – Set ROOT pwd and create a user

After a moment or two, the installer will prompt you to choose a root password. Immediately after that, you’ll need to create a non-root user and set the password. NOTE: I think this an odd sequence of events, because, ironically, Debian does not set this non-root user as a sudoer. In fact, sudo isn’t even installed by the Standard System install task. Hmph.

7:05 PM – Choose a Net Mirror and select only the Standard System task from CD

If you’re lucky enough to live near a college with a decent CompSci program, chances are they have a Debian mirror and they’re on the list of mirrors. If not, the default Debian FTP mirrors will suffice. At this time, the mirror site you chose gets added to /etc/apt/sources.list.

7:07 PM – Install GRUB and reboot

Wow. You’re only 8 minutes in and ready to boot into the new system. Remove the CD and reboot.

7:08 PM – Edit /etc/network/interfaces to use a static IP

Now you’ll probably want to override the installer’s default DHCP configuration. You don’t absolutely have to, per se, but it’s nice if your development server doesn’t keep getting a new IP address every few days.

Login as root and open /etc/network/interfaces:

datsyuk:~# nano /etc/network/interfaces

Find your primary network interface and, assuming that turns out to be eth0, replace the line that reads:

iface eth0 inet dhcp

with the following (but use the IP values appropriate to your network):

iface eth0 inet static
address 192.168.0.13
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

Remember a few minutes ago when you let the installer configure this interface to use DHCP? Well, it was probably also nice enough to grab valid DNS Server addresses from your DHCP server and put them in /etc/resolv.conf along with a search suffix. To verify, open it with nano and look for something like:

search myarbitraryhomenetworkname.com
nameserver 68.87.71.226
nameserver 68.87.73.242
nameserver 68.87.64.146

So, unless you need to use different name servers than the rest of your DHCP clients, the installer saved you some time.

Save the file and restart the interface so the changes take effect:

datsyuk:~# /etc/init.d/networking restart

If you want to make sure it worked:

datsyuk:~# ifconfig

7:09 PM – Disable the package manager’s CD repository

Unless you want to install stuff from CD only to update it later, you should comment out the CD repository in /etc/apt/sources.list.

Put an octathorp (#) in front of anything that starts with “deb cdrom:[Debian GNU/Linux 4.0 [...]“:

# deb cdrom:[Debian GNU/Linux 4.0 r4a _Etch_ ... / etch contrib main

7:10 PM - Get the latest patches via apt

Still as root:

datsyuk:~# apt-get upgrade

This will likely install a new kernel, in which case, you're advised to reboot. Do so, log back in as root again, and check for held back upgrades:

datsyuk:~# apt-get dist-upgrade

7:13 PM - Install MySql Server

No rocket surgery here. As root:

datsyuk:~# apt-get install mysql-server

7:14 PM - Install Apache and PHP

datsyuk:~# apt-get install apache2 php5 libapache2-mod-php5 php5-mysql phpmyadmin

At this point, you have a perfectly viable LAMP server. To kick the tires a little before continuing, point a browser (from a different machine) at http://datsyuk/phpmyadmin/ (using your new server's name instead of mine.) Login with the ROOT MySql user and no password. REMEMBER TO FIX THAT LATER! You should see something like:

PhpMyAdmin

PhpMyAdmin

The next few steps make your new LAMP server suitable for disconnecting the monitor, keyboard, and mouse, and packing it away in a dark corner somewhere. From here on out, you'll configure a secure means to remotely access the server through either an X-Terminal or a VNC client.

7:16 PM - Install and configure the X-Server

Now, install the X-Server from the net mirror:

datsyuk:~# apt-get install xserver-xorg xorg

After a whole boatload of packages are installed, you'll need to manually configure things to work with your video card. Use the following command and answer all the questions:

datsyuk:~# dpkg-reconfigure xserver-xorg

Now, you can test that the X-Server is working with your card:

datsyuk:~# startx

This should render a hatched gray background with a small, border-less terminal in the upper left hand corner. If all goes well, leave your X session:

datsyuk:~# exit

7:19 PM - Install the smallest version of GNOME available

Of course, if you prefer something else, you can adapt the rest of this to your liking, but I prefer GNOME, as long as it includes only the absolute bare essentials ... which is why the folks at Debian gave us the gnome-core package. So, again as root:

datsyuk:~# apt-get install gnome-core

After the packages are yanked down to your new server and installed, you may choose to test the GNOME desktop. You can do this again with the startx command. Hopefully everything goes well and you notice that you've got a very snappy and quick GNOME desktop with only a handful of other apps installed. Yay. Now, logout of the desktop session to return to the command prompt.

TIP: If you want to install XFce4 instead, check out VNCServer on Debian Etch XFce4 at newvibes.net.

7:24 PM - Install and configure SSH and VNC server

Trust me on this: tightvnc is what you want to use over SSH. To install it along with OpenSSH:

datsyuk:~# apt-get install tightvncserver ssh

Once installed, you'll want to logout of the root account and into your non-root user account. This is because you want to configure VNC server settings specific to your non-root account. DON'T USE THE ROOT ACCOUNT FOR REMOTE VNC ACCESS ... beware the hungry clowns ...

Logged in as non-root:

ricky@datsyuk:~$ vncserver

This will ask you to provide a password for your VNC desktop and finally give you output that looks something like this:

ricky@datsyuk:/$ vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'X' desktop is datsyuk:1

Creating default startup script /home/ricky/.vnc/xstartup
Starting applications specified in /home/ricky/.vnc/xstartup
Log file is /home/ricky/.vnc/datsyuk:1.log

A new ~.vnc/xstartup file has been created for you, but you need to add one line to get GNOME to start when you log in. First, kill the X desktop:

ricky@datsyuk:~$ vncserver -clean -kill :1

Then open the new xstartup file with your handy nano editor and replace everything after #!/bin/sh with:

/etc/X11/Xsession &

The file should now look something like this:

#!/bin/sh

/etc/X11/Xsession &

Save, exit, and restart your vncserver. You can also specify a few params:

ricky@datsyuk:~$ vncserver -geometry 1152x864 -depth 16
New 'X' desktop is datsyuk:1

Starting applications specified in /home/ricky/.vnc/xstartup
Log file is /home/ricky/.vnc/datsyuk:1.log

7:28 PM - Login from a remote workstation

The moment of truth has arrived. From a different workstation--and may Steve Yzerman help you if it's a Wind0ze machine--fire up a VNC client that supports SSH. vncviewer on most Linux distros does exactly that if you use the -via option:

ricky@zetterberg:~$ vncviewer -via 192.168.0.13 192.168.0.13:1
ricky@192.168.0.13's password:
VNC server supports protocol version 3.3 (viewer 3.3)
Password:
VNC authentication succeeded
Desktop name "ricky's X desktop (datsyuk:1)"
Connected to VNC server, using protocol version 3.3
[blah, blah, blah ...]
Using shared memory PutImage
Tunneling active: preferring tight encoding

The first password prompt is from the SSH server at 192.168.0.13 (Datsyuk in my case), while the second is the VNC server asking for the password you chose a few minutes ago when you first started up the VNC server. Hopefully, you see something like this:

TightVNC X Desktop w/GNOME

TightVNC X Desktop w/GNOME

7:29 PM - Install MySql GUI tools

Admittedly, you could have done this at anytime after you installed your desktop environment (GNOME in this example.) Some folks may choose not to install them on the server at all, but if you do:

datsyuk:~# apt-get install mysql-admin mysql-query-browser

8:00 PM - A few thoughts

Typically, your server will sit deep in a closet somewhere with no VNC server instance running. At least, that's what this configuration is intended for. What I generally do to access the server is simply use SSH. But if I want more than an X-Terminal, I go the extra step and start a VNC server when I have an SSH session up.

Once I am done accessing the desktop remotely through my VNC client, I close the client and simply kill the VNC server in my already existing SSH session. Yes, it's two windows open on my workstation, but it has worked fine for me as long as I can remember.

If you plan to access your new server from outside your network, you'll likely need to forward at least one port through at least one firewall and it would be wise to consider changing the defaults. Check out Change Standard SSH Ports. There's a also a series of related articles to this one there: Setting up a LAMP Webserver with Apache, PHP, MySQL on Debian Etch.

And one last thought ... if this actually takes you 30 minutes the first time you do it, be completely shocked. Outside of the fact that I get over 800Kbps when downloading from the MIT mirror, I have done this so many times I could probably recite the steps backwards and in Pig Latin while balancing a flaming coconut on my head.

Cheers!

Share

  4 Responses to “Build a Debian Etch LAMP server in 30 minutes … complete with SSH remote desktop access”

  1. Great post. I am interested in trying this on Lenny when my schedule frees up.

  2. big thanks! particularly the interfaces edit .. I had it half right, and now it works.

    I made my headless server beep when it reaches the login prompt.
    Here’s how:

    from http://leb.net/blinux/list-archive/blinux-list/2000/msg00628.html

    when the logon box comes up I’d like to hear a double beep.

    This is not hard either, but a little tricky.
    Replace the file /etc/issue with a simple file
    that has two control g bells in it.

    how to do that I found here
    http://speakupmodified.org/HOWTO_INSTALL.html#grapgrub

  3. wow!!

    as an alternative to putting a gui on the server, consider webmin:
    http://www.webmin.com/index.html

    I installed it on fedora 7 with gnome and kde (but running IceWM)
    and then on my Debian Etch server with no gui (and no monitor, keyboard or mouse.)

    The resources available without a gui installed on the server are nearly double what’s available on the fedora box (both have only 256 mb ram each) and and you still have a web-based gui, without incurring the overhead of the vnc server and client.

  4. Nice. Can’t believe I’ve never seen Webmin before. I just tried it out on the very box in this post … pretty slick. Thanks for the tip.

    Here’s a decent post on its installation: http://onlyubuntu.blogspot.com/2007/05/how-to-install-webmin-in-ubuntu.html

    Ubuntu is a Debian-based distro, so things worked just fine for Etch.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
Your Ad Here