Using a Domain Name with a Raspberry Pi Web Server

The Raspberry Pi’s low power consumption makes it well suited to the role of always-on web server. This post describes how to use a domain name with your Pi-based web site. Setting up a web site on the Pi is very easy and was explained in an earlier post of mine, just here.

This article explains how to set up a domain name with your web site, so that you can surf to instead of http://your.ip.address. It assumes that you have already have an Apache web site running. If not, please read the above post, before coming back here.

My Raspberry Pi was purchased from RS Components in the UK. It was installed with Raspbian “Jessie” (Debian 8) by applying the image “2017-04-10-raspbian-jessie-lite.img” downloaded from the downloads page, where it is described as “Minimal image based on Debian Jessie”. The following procedure was then performed without any further pre-work (other than enabling ssh in the basic setup)

Note: The following procedure is for any Linux system running apache 2.4, not just the Pi.

Acquire a Domain Name

First, a domain name is needed. Some providers, such as, will give you a free one. Others will require a fee of perhaps £20 per year. Personally, I prefer to use a paid-for domain name, because the free ones are sometimes temporary, or come with strings attached.

Is this example, suppose you have a new domain name called Proceed as follows. to make it point to your website.

Point the Domain to your IP Address

The domain name needs to point (or “resolve”) to your IP address. If you are not sure what your external IP address is, just type “my ip address” into Google, like this, and it will pop right up.

Next, surf to your domain name provider’s web site and log in. Point your domain name at the IP address. How this is done will vary slightly from provider to provider, but it should be quite straightforward. For example, my provider is, so I login there, click on “hostnames”, add a hostname and insert the IP address into the text box provided.

Configure Apache

Log into the Pi, either on the graphical console or via SSH. I am using SSH, but the procedure is the same either way.

Make a copy of the default Apache config file, then edit it. You can use vi to edit the file, like I do, or another editor of your choice. Type the following commands, remembering to substitute your domain name for

$ cd /etc/apache2/sites-available
$ sudo cp 000-default.conf
$ sudo vi

Change this line:


to this


Save the file and quit out of the editor.

Enable the Website

Proceed as follows to enable the new configuration.

$ sudo a2ensite
$ sudo service apache2 reload
$ sudo systemctl daemon-reload

That’s it. The domain name has been enabled. You should now be able to surf to (substituting your own domain name) and see your web site.


I hope that the above was not to rambling or fiddly. You should now be able to view your website using your chosen domain name rather then the IP address.

2 thoughts on “Using a Domain Name with a Raspberry Pi Web Server

  1. Pingback: How to Convert a Website from HTTP to HTTPS | Unix etc.

  2. Pingback: Create a Basic Website on a Raspberry Pi | Unix etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.