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.

13 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.

  3. Many thanks for a very clear and well presented guide.
    I have a problem with the a2ensite command, I get a response
    ERROR: Site does not exist!
    The edited line in the file reads
    I have also tried
    I can see the site locally HTTP I have port forwarded to 80 HTTP and 443 HTTPS
    Any help would be appreciated

  4. Apologies, I made a mistake with renaming the config file as
    I have since renamed to rydepier.conf and proceded to enable it.
    It appears in the sites-enabled directory and if I try and enable it again with
    sudo a2ensite rydepier.conf I get the response
    Site rydepier already enabled

  5. Massive apologies, I am a complete dufus and had not enabled HTTPS in apache2.
    I followed your guide and after a few syntax corrections everything worked.
    Thanks once again for a very well presented how-to guide.

    • Wow, that camera has good resolution. The frame rate looks to be about 10 frames/sec. I can see sea gulls, and was that a hover craft ? Incidentally, not sure if you are aware, but having such a high frame rate will put quite a strain on your Internet upload speed. Domestic Internet connections are slower for uploading than downloading (my maximum upload speed here is 10 megabits/sec). Just having one person view th camera at this speed is likely to use up most of your upload capaity. If you reduce it to 1 frame per sec or even 1 frame every 5 or 10 seconds, the traffic might be more manageable.

      Cheers, Jim

  6. Hi,

    I’m curious how you would do this for a wordpress website that you’re hosting on a raspberrypi? I cannot find a single source that proceeds from installing apache 2, to changing the path from localhost to a domain name that’s hosted by (say) google. Most that I’ve found drop you off after establishing a wordpress site, but that remains local. Do you have any advice for a source that does this?

    • Hi Bradley. Creating a blog in the way you describe is a sizeable piece of work, but roughly:

      1. Carry out the procedure above.

      2. Install WordPress using a suitable procedure (I have written one here: Install WordPress Blog on Raspberry Pi

      2.5 Go into the WordPress Dashboard/configuration settings, and change the URL to your domain name ( in the example).

      3. Associate the web site with the blog as follows. Check the directory specified as “Document Root” in your Apache config file ( in the procedure above). Then replace this directory with a link to /usr/share/wordpress, eg.

      $ grep DocumentRoot /etc/apache2/sites-enabled/

      $ sudo mv /var/www/html/something /var/www/html/something.original
      $ sudo ln -s /usr/share/wordpress /var/www/html/something.original

      Apache will now treat /usr/share/wordpress as your site, and the blog should be live. The important thing is that the “DocumentRoot” points, eventually, to /usr/share/wordpress.


  7. Hey, even after following the tutorial it says that my website couldn’t be found. I set up the hotname as (I’m using google domains) and set the IPv4 address to my external IP that I found with the google search.

    Even when I go to after completing the apache config it still doesn’t connect. Does this have something to do with port forwarding on my router ? Or is it something else.

    I just got my raspberry pi today and I’m familiar with Linux, but networking is completely foreign territory to me !

    Your help would be much appreciated, thanks in advance !

    • Hi bigchungus50, port 80 on your router needs to be forwarded to the Pi’s IP address. The article should probably have mentioned this.

      To forward the port, log into your router and look for “port forwarding”. The exact method will vary depending on what brand of router you have, but it shouldn’t be too difficult.


    • Hi Phil this article is about using a domain name with an existing website. For a guide to setting up a web site, including port forwarding, see my accompanying article, linked in the first paragraph above.

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.