Install Apache on Ubuntu Server 13.10

First you need to prepare the machine that you are going to use. I’m using a Rackspace cloud server. In which case, all I need to do is spin up a server and update the Operating System software.

Install Apache2

Installing Apache is easy, simply run apt-get install apache2 as the root user.

root@apache:~# apt-get install apache2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
  ssl-cert
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,302 kB of archives.
After this operation, 5,314 kB of additional disk space will be used.
Do you want to continue [Y/n]? 

Once the installation has finished, open up a web browser and enter the IP address into the address bar. Hopefully you should see a page like the below.

Installing Apache
Testing apache

And that’s it! Apache is now installed and working!

Set the Hostname

Your likely to see the below error message.

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2a00:1a48:7806:117:936d:610a:ff08:747d. Set the 'ServerName' directive globally to suppress this message
                                                                                                  [ OK ]

This is caused by the hostname not being set correctly. Open up /etc/hosts and enter something similar to the below, adjusting for your own environment.

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 www.yourdomain.co.uk www localhost

2a00:1a48:7806:0117:936d:610a:ff08:747d	www.yourdomain.co.uk www
162.13.144.164	www.yourdomain.co.uk www
10.180.66.169	www.yourdomain.co.uk www

If you too are using a Rackspace cloud server, the most important line is shown below.

2a00:1a48:7806:0117:936d:610a:ff08:747d	www.yourdomain.co.uk www

This will stop the warning message.

Update Ubuntu Rackspace Cloud Server

Assuming you’ve already “spun-up” a Linux cloud server of your choice, the first thing to do is update the system. Here I’m using Ubuntu Server 13.10.

SSH onto your box with the below command, replacing the IP address with that of your server. You will need to accept the key when prompted.

andy@work-pc:~$ ssh root@162.12.137.166
The authenticity of host '162.12.137.166 (162.12.137.166)' can't be established.
ECDSA key fingerprint is 12:af:51:e2:bf:ed:b8:2c:dc:89:de:ca:55:a7:36:6a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '162.12.137.166' (ECDSA) to the list of known hosts.
root@162.12.137.166's password: 

Then update the system and reboot if needed.

root@apache:~# apt-get update
root@apache:~# apt-get upgrade
root@apache:~# reboot

Delete Unused Rackspace Cloud Servers

To avoid any unnecessarily high Rackspace bills, make sure you delete any unused cloud servers or products.

Here I have three servers. One is in production, another is occasionally used for testing and development. I am half-way through setting the last one up but it is not yet in production.

You might think that you can just power-off the server to stop being billed for it….but you’d be wrong! If you simply shut down the server, you will still be billed per hour for it’s use.

If like me, you have any servers that are not currently in use, either by you or your customers, it makes sense to take an image of the device and then delete it. You can always spin up a new server from the image you create.

Take an Image

To take an image, click the cog icon next to the server. That will create a drop-down menu. Within there, you will see “Create Image” – select that.

Taking an image
Taking an image

You will then be asked to give the saved image a name. If you hover over the small pound sign symbol, you will also see the associated costs.

Give the image a name.
Give the image a name.

Delete Server

Before I delete a server I might come to rely on later, I like to first make sure the image was created successfully. To do that, navigate to the “Saved Images” section/tab.

Saving images.
Saving images.

Once imaged, simply select the servers you wish to delete and click on the “Delete” button.

Deleting servers
Deleting servers

Rebuild Server from an Image

When you next require the deleted server, we can spin up a new server from the image we took.

One downside to this is that the newly created server will have a different public IP address than it did previously. If this is an issue for you, I would recommend creating a load-balancer to sit in front of the device. It is possible to have a load-balancer with one node behind it. Load-balancers IP addresses do not change.

To spin up a new server from an existing image, simply navigate to the “Saved Images” section of the server tab. Click on the cog next to the image you wish to use and select “Create Server with Image...“.

Then simply give the server a name, select a flavour and/or alter any other details. Then click on “Create Server“.

You will be given a new password for the server. Make a note of this and “Dismiss Password” when ready.

Root Admin Password
Root Admin Password

You can monitor the progress from the cloud servers tab.

Cloud Server Rebuilding
Cloud Server Rebuilding

Job done!

“Spinning up” a Rackspace Cloud Server

Assuming you’ve already created yourself a Rackspace cloud account and that you’ve just logged in, you will see a list of cloud servers (if you have any yet). These are your current servers. If a server is listed here, you will be getting charged for it at an hourly rate. Even if you shutdown your server through the Operating System! To avoid getting charged for something you are not using, take a snapshot and then delete it. You can always build a new server instance from that snapshot at a later point in time when it is required.

Servers tab
Servers tab

To create a new server, you simply click “create server“, then provide the following information.

Server name:
Region:
Image:
Size:
Networks:

Once filled out, kick the build process off by clicking “create server” at the bottom of the page.

Select flavour and instance type
Select flavour and instance type

The server will then go into “building” state until complete when it then goes into “active". Although it only takes a few minutes to be deployed, you are free to continue using other parts of the website. You can even spin up more servers while you wait if you want!!

Building server
Building server

And that is it! Your first cloud server! Easy!

Your new server details
Your new server details

How to connect to your new cloud server depends on what Operating System you chose to install, Windows or Linux? If you chose Linux, you will need to use SSH. If Windows, you can use RDP. Here we chose CentOS – which is essentially just a free, re-branded release of Red Hat Enterprise Linux. If using SSH, issue below command.

[root@server ~]# ssh root@1.2.3.4

Don’t forget to replace 1.2.3.4 with the public IP address of your cloud server!