Installing Ubuntu Linux
Background
In the past my Linux experience has mainly been with Red Hat and Fedora. My old web server ran Red Hat 9 for a couple of years and I have installed and used various versions of Red Hat and Fedora Core on other PCs and laptops. I am quite used to the Red Hat/Fedora layout and happy with it as an operating system (although I haven't seriously used any other Linux or BSD OSes, except Slackware in 1998.) However after hearing a bit about Ubuntu and there being a chance that I would be running my web site on a Ubuntu server, I decided to give it a go on my new PC in Thailand. Well after some playing around, I was quite happy with Ubuntu so now have it installed and use it regularly on my PC (I still have Windows XP and Fedora Core 5 as well) and it is running on my Bangkok Web Server.
So here are the steps that I followed to install my Ubuntu Web Server, as well as a few side notes on my Ubuntu PC installation. Most of this information has been found from the Ubuntu manual and the Ubuntu Guide, as well as other websites.
Computer Specifications
You can find details of my server and PC specifications here, but in summary my server is a Pentium III 933MHz with 128MB RAM and my PC is a Pentium D2.8GHz with 1GB RAM.
Obtaining Ubuntu
The first step is to get a copy of Ubuntu. It is free to download (about 700MB), which is a good option of you have broadband Internet. Go to the Ubuntu website for more details. I got my copy from the local Thai NECTEC mirror.
There are different versions to choose from - some for a standard PC install (which I used for my PC) and some for a server install (which, surprise, surprise, I used for my web server). I choose to install version 6.06 LTS (Long Term Support) in both cases, rather than the most recent version 6.10, with the hope that it may have a bit more stability.
Once downloaded (I downloaded in Windows XP), you burn the ISO image to a CD using something like Nero.
The CD is a so-called Live CD, meaning when you boot your computer from the CD, Ubuntu is booted. In other words you can use and try Ubuntu without installing on the hard disk (which requires the often stressful process of hard disk partitioning).
Pre-Installation Setup
The first thing I did was to make sure my computer would boot correctly. Upon starting, I entered the BIOS (usually press Delete within the first few seconds of the computer starting to enter BIOS) and set the Boot order to be Floppy, CDROM and then Harddisk. In this way I can insert the Ubuntu CD in, restart the computer and boot from the CD (rather then hard disk).For the server, the other possible option in the BIOS is to make sure if the computer boots with no keyboard or mouse attached, then it doesn't cause an error (and wait for user input - which is of course difficult if there is no keyboard attached!). There may be an option in BIOS to set this, but in my BIOS I couldn't find it. No worries - the error doesn't occur with my server. Booting without keyboard etc attached works ok.
Server Installation
The following are the steps I followed for my server install. The server version of Ubuntu does not use a window manager/GUI like Gnome or KDE. It provides a minimal install of the most important applications for a server.
Insert the CD into the drive and reboot the computer. The Ubuntu startup menu should appear, which gives you several options including something like Install Ubuntu on Hard Drive, Install LAMP Server and Check CD for Errors. Make sure you check the CD for errors first! I didn't and sure enough, half way through an install and errors were detected. So I had to burn another CD in my desktop PC and try again. Luckily no errors this time.
As my server is mainly a web server, I chose the Install LAMP Server option. LAMP being Linux, Apache (the web server), MySQL (database), PHP/Perl/Python. Follow the install instructions - most of the time defaults values are used. Here are some of the settings I made:
- DHCP didn't work - I set the IP address manually. This is what I wanted anyway, since it is going to be a web server I need a static (although private) IP address. I set the IP address to 192.168.1.3, subnet mask to 255.255.255.0 and gateway to my ADSL router address of 192.168.1.1.
- Hostname
- Partitioning: I chose to erase the entire hard drive and install. That meant everything existing on the disk, including and Microsoft Windows installs and any pre-existing data, is deleted. Do not chose this option if you want to keep already existing data on the hard drive (e.g. a PC installation).
- Clock: UTC
- Username: created a username and password
And that was about it for the install. Apart from the first attempt when the CD had errors, everything went fine. After the install was finished, I could reboot and log in to my new Ubuntu server. It took me about 1 hour, perhaps would have taken half that if the CD didn't have errors.
Configuring Ubuntu
Some of the things I did to configure my server include:
Using sudo
Having background in Fedora and Red Hat, sudo is new to may. Basically to run privileged commands (e.g. those that only root should run) you prepend the command with sudo. If the current user is the sudoers group (by default, the first user you create in the Ubuntu installation is), then you are prompted for that users password and the command runs. These avoids you having to log in as root to perform privileged commands. It takes a while to get used to it, but I am gradually starting to like it.
At some stage I got a problem with using sudo, as when I invoked it, it would report that the timestamp was too far into the future or something. Well this is very annoying because I couldn't run any privileged commands. The quickest fix is to switch to another terminal: Alt-F2 opens another terminal and you can login and use sudo. Also make sure you set the root password (not set by default in the install) using:
sudo passwd root
Add A User
Add a user for my web editor (the last command makes the web editor the owner of the web directory that I will use):
sudo addgroup web
sudo adduser --ingroup web www
sudo chown web.www /var/www/html
Managing Packages
The packages in Ubuntu are managed using the command line tool apt-get
, the text-based GUI aptitude
or the fully GUI (if you have Gnome installed) using Synaptic Package Manager. The GUIs are just interfaces to apt-get. Once you know the basics, they are all quite easy to use.
Maybe the most important thing to know is that apt-get
uses the file /etc/apt/sources.list
to determine where to find packages from. You can edit this file and add different mirrors to search for packages as well as packages other than the default ones to be downloaded (for example, universe and multiverse).
Being int Thailand where international Internet connections are not always very fast, I commented out all lines in my /etc/apt/sources.list
file and added the following so that apt-get
would use the Thai National Mirror to get packages:
deb http://mirror.in.th/ubuntu/archive dapper main restricted universe multiverse
deb http://mirror.in.th/ubuntu/archive dapper-updates main restricted universe multiverse
deb http://mirror.in.th/ubuntu/archive dapper-security main restricted
Do an update of the package list if you are running by command line (apt-get):
sudo apt-get update
Now you can use aptitude
or the Synaptic Package Manager to browse, select and install packages that you want. Or if you know a package name, you can use:
sudo apt-get install packagename
Apache2 Web Server
I am using Apache2 as my web server.
First, an overview of the default locations of important files:
/usr/sbin/apache2ctl
- used for starting, stopping, and restarting the webserver. You need to restart the webserver for changes to the configuration to take effect./etc/apache2
- directory for Apache 2 configuration. apache2.conf is the main configuration file./var/www
- the default web directory./var/www/apache2-default
- the default Apache2 test site. If you browse to http://localhost/apache2-default/ you should see a message saying the Apache is working.
The configuration can be started in the /etc/apache2/sites-available/default
file, where you can specify the document root and other options. For me, I'm used to working with /var/www/html
as the document root (rather than /var/www
which is the default in this install), so I set that up in this file. The changes are:
Line 5: DocumentRoot /var/www/html
Line 10:
To take effect, Apache must be restarted:
/usr/sbin/apache2ctl restart
Pine Email Reader
If you want to use Pine to read email then download the Debian package from the Pine website and install using dpkg
. You may also need to install libssl
:
wget ftp://ftp.cac.washington.edu/pine/pine_4.64_i386.deb
sudo apt-get install libssl0.9.7
sudo dpkg -i pine_4.64_i386.deb
Created on Sat, 09 Dec 2006, 5:59pm
Last changed on Wed, 30 May 2007, 5:02pm