How to setup your own linux home server on Ubuntu with custom domain

You have a domain and you want to run your webserver from your own computer? You can, let me describe how.

Requirements :

1. ISP that provides Dynamic IP address upon connect.

2. A domain name(even a subdomain would do) and access to manage its nameservers.

3. Ubuntu with Webserver up and running.

Steps :

1. Create a free account at http://freedns.afraid.org

2. Change the nameservers of your domain to ns1 through ns4.afraid.org through your domain control panel. Like for example I have set up a domain nitesh.info and its nameservers as :

Nameserver Setup on 1and1

Nameserver Setup on 1and1

3. Login to your account at FreeDNS and add a new domain. Then navigate to Dynamic DNS. And then download the wget batch script for windows.

Dynamic DNS Script from afraid.org

Dynamic DNS Script from afraid.org

4. When you open .bat file you shall see a wget url like http://freedns.afraid.org/dynamic/update.php?<identifier>. Copy that. You shall need it for setting up cron job.

5. In terminal, type

crontab -e

Cron Job on Ubuntu

crontab -e

6.  If you are asked to setup cronjob for the very first time, select second option as a editor. Then enter the following. Replace identifier matching identifier you receive from freedns batch script.

*/5 * * * *  wget -q –read-timeout=0.0 –waitretry=5 –tries=400 http://freedns.afraid.org/dynamic/update.php?<identifier> > /dev/null

Crontab

Cron Job

What it does is, it updates the A record of your domain to the current ip of your computer every 5 minutes

7. I presume, you have already set up your webserver with Apache. Next thing we do is edit httpd.conf to serve the request to your domain name. Enter following command to the terminal:

sudo gedit /etc/apache2/httpd.conf

Add following lines to your httpd.conf file

<VirtualHost *:80>
DocumentRoot /path/to/your/resource
ServerName yourdomain.com
<Directory “/path/to/your/resource”>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Httpd Config

Httpd Config

8. Now next thing you do is setup port forwarding in your router if you access internet behind router. Forward port 80 (external) to port 80 internal of your pc ip. I have forwarded port 8080 (external) to port 80(private) because my ISP has blocked port 80 traffic. as for example :

Dlink Port Forwarding

Dlink Port Forwarding

9. Now you are done. Access your domain and it should point to your webserver. As easy as that. If you have any queries, drop a comment. I will love to answer your queries.

Related Article :

http://www.nitesh.com.np/website-maintenance/configuring-virtualhost-and-host-alias/

3 Comments

  1. Jon says:

    Thank you. That was helpful.

  2. hi thanks, i have developed my own web hosting server for huge websites with dynamic ip

Leave a Reply