The Ubuntu Linux distribution is available as an easy to install Server version that comes complete with DNS server and LAMP (Linux, Apache, MySQL, PHP) server components. Unfortunately, the Server version does not install with an easy to use GUI and useful programs like OpenOffice and Firefox that come standard with the Desktop version. But you can have the best of both words by first installing the Server version then installing a GUI so you can use the same machine as a desktop and server. This post details the steps you need to take to accomplish this. These steps are based on my Ubuntu administration notes, which are a few years old so there may be some slight differences with the latest Ubuntu releases. Nevertheless, I am sure the essence of the process is the same, and, if nothing else, this post should get you started on the right track.
Step 1: Install Ubuntu Server Edition with LAMP server components.
Download the disk image (*iso) for Ubuntu Server and burn it to a CD. Ensure that your BIOS is configured to boot from the CD-ROM drive. Restart with the Ubuntu disk in the drive and the machine should boot into the Ubuntu installation shell. If you would like to configure a static IP address, select F6 - Other Options
and enter
netcfg/disable_dhcp=true
at the end of the options string, and the install script will prompt you for network information during the installation. Otherwise, the static IP must be configured post installation as per the second part of step 2 below, and your network will be automatically configured using DHCP (as long as DHCP is enabled on your router). In either scenario, you must enter a hostname when prompted.
As you work through the installation (most of which is self explanatory), you will also be prompted to select a partitioning method. The most straightforward method is “use entire disk”, which will format a drive of your choice before installing system files to it. Finally, you will be prompted to enter a full name and a short name for a non-administrator account (separate from root). After a few more trivial questions (like “What is your time zone?”), and a plethora of file copying, the install shell will ask you to select optional software to install. Select LAMP (using the arrow keys and spacebar). If you wish to install a name server as well, you may select DNS also. You may also elect to install an OpenSSH server at this point and bypass the first component of step 3 below. After making selections, continue the installation by pressing enter. At some point, you will be prompted to enter a MySQL root user password. If you wish, this password can be left blank for now.
Step 2: Enable root access and configure a static IP address.
After installation finishes and the system reboots, log in using the non-administrator account created during installation. (Note: my system hung after reboot and I had to press enter to get the login prompt.) The first thing you will probably want to do once you log in is set the root password (by default the password is left blank). To do so, type the following at the command prompt.
sudo passwd root
Since you are planning to use the machine as a web server, you will also need to specify a static IP address (if not already configured during the installation). To do so, you must edit the interfaces
configuration file (use your favorite text editor; I use vi here).
sudo vi /etc/network/interfaces
If DHCP was enabled during installation, a chunk of this file should look like the following:
auto eth0
iface eth0 inet dhcp
Change dhcp
to static
and add the lines shown below. Of course you need to use your IP address, netmask, and gateway instead of mine.
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
You also need to specify the DNS server(s) in the resolv.conf
file.
sudo vi /etc/resolv.conf
Replace the xxx.xxx.xxx.xxx
in the nameserver xxx.xxx.xxx.xxx
line with the address of your DNS server. You can add multiple DNS servers if you like by duplicating this line using other DNS server addresses. Now restart your network components.
sudo /etc/init.d/networking restart
Ping www.google.com to make sure your network configuration is working.
Step 3: Install OpenSSH and Ubuntu Desktop components.
If you didn't do so during the installation, you will probably want to install an SSH server at this point so you can login to your new LAMP server from other machines on your local area network. Installing packages is a snap with Ubuntu using the apt-get package management software. The first step is to update the packages database by typing
sudo apt-get update
Then install the openssh-server package.
sudo apt-get install openssh-server
You need to insert the Ubuntu Server installation disk to complete the installation. Installation of the Ubuntu desktop environment (and all of the goodies that go with it) is also a snap using apt-get. Type
sudo apt-get update
apt-get install ubuntu-desktop
Because a significant number of files need to be downloaded, the Ubuntu GUI installation may take some time. Near the middle of the installation you will be asked to configure the Postfix mail transfer agent. Since my machine is not going to be a mail server I selected 'no configuration' and continued, but you may want to configure Postfix differently. When the Ubuntu desktop installation finishes, fire up the GUI.
sudo /etc/init.d/gdm start
Congratulations, you now have a fully operational Ubuntu LAMP server with the niceties of the Ubuntu desktop environment.