I have just recently set up a website on my personal server. This blog entry aims to document the steps I took to host the website. I hope this is useful for those who want to try this out.

The first thing you need to host your own website is a PC that you keep on for most of the time. Most of us have such a machine at home; whether to serve as a media server for our media centers or as a file server to keep work documents accessible on the home LAN.

The PCs in my home network all run Ubuntu. Therefore, the rest of this tutorial is going to be written for that OS. Let us now get into the details of the process.

First, I set up an account with dyndns.com, a service that allows users to assign a domain name to a dynamic IP. To set up an account on that website, you need to choose a domain name, I chose sheriffadelfahmy.org, and associate it with a username and password.

Once you have done that, you need to install software on your server that updates the records at dyndns.com with the current value of your IP. There are many such programs, but I chose ddclient.

In order to install ddclient on your Ubuntu server, you use the standard package management command apt-get. The exact command you need to issue is

sudo apt-get install ddclient

At the end of the installation process, you are required to select the dynamic IP domain name service you subscribe to. You should choose dyndns.com at this point. The program then asks you to enter your username and password. Enter the username and password you created when joining dyndns.com. Thats it. The domain name you chose is now associated with your current IP.

To test this, you can try pinging your domain name and comparing the result with your IP address. Note that the IP address I am referring to is the one you use to access the Internet, not your LAN IP. So, for example, if you have a router that connects you to the Internet, the IP address I am referring to is the IP address assigned to the router by your ISP — more about this later and how you can use Network Address Translation (NAT) to route messages from your router to your server.

Once your IP address is assigned to a domain name, you can begin installing your server software. Decide on what you want to host. Personally, I wanted to host a website so I needed a web server. It is possible to host other services, like email for example, by installing the appropriate server, but I will restrict myself to web servers in this post.

Naturally, since I am on Linux, my choice of web server was apache. I downloaded the apache2 web server using the following commands.

sudo apt-get install apache2

Once apache2 is installed, you need to configure the server to point to your website. There are many configuration options for apache. To run through them would be fruitless, you can check the man pages for more information, but the most important file for beginners is the one that points to your website. That file is /etc/apache2/httpd.conf . To modify this file, open it with super userĀ privileges

sudo emacs /etc/apache2/httpd.conf

you can, of course, replace emacs with your editor of choice. Here is the contents of my httpd.conf file

# Ensure that Apache listens on port 80
#Listen 80
# Listen for virtual host requests on all IP addresses
#NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /home/sherif/webpage
ServerName 192.168.1.7
# Other directives here
</VirtualHost>

Notice the DocumentRoot entry in the file. It is here that you point apache to the directory where you keep the files representing your website. At this point you can begin creating html files and placing them in your directory. By default, apache will display the index.html file in the directory you specify when visitors access your website. The other entries in the file should be self explanatory. Thats it! You are good to go.

If you are creative enough, you can create whatever website you want. If, however, you are not very good at visual design, you may want to look at alternatives that automate the design process for you and allow you to concentrate on content — the alternatives also allow you to easily add advanced components to your website without actually having to write the code for them. Check outĀ WordPress for a great alternative to developing your site from scratch.

The next installment, after I finish grading student’s exams :D, will address NAT and how to forward incoming requests from your router to your server.

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.