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