Yesterday I wanted to host a web application that I have developed to let my friends play with it and tell me their opinion in it. At the moment I have only one home server machine that runs Microsoft Windowzzz XP professional “yes my other machines are dead :( ” I wanted to find a quick yet efficient way to host my app without paying a penny :D and thank God I did find a way, here are the steps that you can follow to host whatever you want on your home server:

Steps:

1- Download/get :P VMWare workstation 6.0 (ACE edition).
2- Download UBUNTU 7.10 Server Edition “Yes, I couldn’t wait another 18 days to get the new release :D “.
3- Install UBUNTU “guest OS” on the VMWare.

Note: Be sure to configure your virtual machine to use bridged networking.
4- Start your new guest OS (see the below screenshot).

VMWare UBUNTU

5- Inside UBUNTU install apache2 web server “You can install it during the installation process of UBUNTU and select to install a LAMP server” to do that type the following in your command prompt:
sudo apt-get install apache2
6- After installing apache2 web server, edit the file /etc/apache2/ports.conf to change the port on which apache2 listens for requests “You might be wondering why :D well it is a good thing from security point of view” :
sudo vim /etc/apache2/ports.conf
and then change port from 80 “which is the default” to lets say port 5555 “You must be sure that this port is not occupied by another application!!” :
Listen 5555
and finally save and close the file.
7- No we face a problem that our ISP is providing us a dynamic IP not a static one, so we need to figure out a way on how can we map our dynamic IP to a domain name ??!! Fortunately someone has done all the effort for us and provided it to us as a free service ;) . Now leave UBUNTU for a couple of minutes :( , open your web browser on Windowz and go to the following URL http://www.no-ip.com/ no-ip provides a free service that automatically updates our dynamic IP with a specific domain “This is called Dynamic DNS”. When you open no-ip website, first you have to choose the free service that this great company provides and create a new account (see the screenshot below):

8- After a successful registration process you should have an active account, now we need to add a host. Click on Add link in the Hosts/Redirects menu (step 1 in the below screenshot), you will be presented by new page where you enter your new host details (step2 in the below screenshot), and when you finish entering the required information press Create Host button (step 3 the in below screenshot) :

9- The last step we are going to do and I promise after that we will get back to UBUNTU ;) . In no-ip website click on Downloads link (step 1 in the below screenshot), and click to download no-ip updater client for our platform which is Microsoft Windowz (step 2 in the below screenshot)

You may wonder what is the updater thingy? why are we downloading it? The no-ip updater client is the voodoo behind all this, it constantly checks whether our external IP is changed or not and if it did change it will automatically update and remaps the new IP with our host/domain “very neat haaa :) “. After the download process is finished start installing it. You should see something similar to this:

You must check the check box(es) beside your host(s) and click update.. Now no-ip has our latest IP in its database.
10- As promised we will switch back to our beloved UBUNTU, now its time to configure our network interface (eth0). In the command prompt, open and edit the file /etc/network/interfaces:
sudo vim /etc/network/interfaces
and modfiy the setting of your eth0 interface like this:
auto eth0
iface eth0 inet static
address e.g. 192.168.0.3
netmask e.g. 255.255.255.0
network e.g. 192.168.0.0
broadcast e.g. 255.255.255.0
gateway e.g. 192.168.0.1

save and close the file, to apply our changes we need to restart the network by typing the following command:
sudo /etc/init.d/networking restart
11- Finally!, the last step :D , We need to configure our web server (apache2) to work correctly with our new host/domain. We can achieve this my using apache2’s virtual hosts. In your command prompt type the following:
cd /etc/apache2/sites-available
and now create a new file by typing the following:
sudo vim myNewSite
and insert the following text:
<VirtualHost your-eth0-IP >
ServerAdmin admin_email
ServerName your_new_domain
ServerAlias www.your_new_domain
DocumentRoot /var/www/
</VirtualHost>

save and close the file, then execute the following command:
cd /etc/apache2/sites-enabled
sudo a2ensite myNewSite

and the last thing, we must restart our web server to reflect the changes we made:
sudo /etc/init.d/apache2 restart

12- Yes I lied this is the last step :P we need to configure our router to do some Network Address Translation (NAT). I will show you how you can do this on D-Link DSL-520T “why you say :D because this is the model of my router :D ” fire up your web browser and go to the following URL http://192.168.1.1 then type the admin username and password. Click on Advanced link (see step 1the screenshot below) and select Virtual server link from the left menu (see step 2 in the screenshot below) and be sure that IP of your linux box is selected in LAN IP combo box (see step 3 in the screenshot below), then choose user radio button from categories (see step 4 in the screenshot below), and finally click on Add button (see Step 5 in the screenshot below):

When you clicked on the Add button a new page is loaded in which you specify a name for the service you want the router to do the NATing for and its port number(s):

and when you enter the information needed press the Apply button (Step 2 in the above screenshot). Now we should return back to the Virtual Server page and pick the newly created service “in our case webserver” from Available Rules list (see the below screenshot) and click on Add> button (see step 2 in the below screenshot), and finally click on Apply Button (Step 3 in the below screenshot):

Now its time to save and reboot our router.

PHEEEWW we are done :D , now you can access your web server from any place through this URL http://you_new_host:port/ where port is the port on which your web server listens on.

Feel free to ask me any question, or if you have a problem in one of the steps, by leaving a comment..

Chaw


  1. Wow, great tutorial I got my website up and running in about 3 weeks by learning php and mysql. Check it out: http://www.wallpapersearch.net

  2. Really great advice and tips. I appreciate your post.

  3. I was wondering if you could help me get this project going or point me in the right direction.

    Basically this is what is happening.

    I am 7th form at pakuranga college. and I’m currently under going a school project where I have to host a website for a company (this is one alternative way which I have to investigate)

    I’ve installed Vmware and installed ubuntu 7.10 server underneath it. however just cannot for the life of me get the network bridged so I can access the internet (So that ubunut 7.10 can access the internet)

    I’m using

    VMware Workstation e.x.p build-84113
    Windows Xp Pro Sp2
    Ubuntu Server 7.10

    Im bascially just stuck on two things for this school project.
    1. How to get the ubuntu 7.10 server to connect to the internet via a bridged network.
    2. Virtual servers dont seem to work on my modem.. so i guess thats a problem? the port is open yet IIS doesnt work (i tested it first with IIS.. no go.. )
    3. how to insert a website into apache2 so that it will host it etc.

    If i can get ubuntu to access the internet (The virtual machine) then i’d be happy. e.g. sudo apt-get update will work.

    Any help would be greatly appreciated :D

    Thanks

    Chris

  4. Amr Kamel

    @Chris,

    To enable bridged networking for your guest operating system “in our case ubuntu”:
    1-open your VMWare workstation.
    2-Locate/select your guest OS image.
    3-You will find “Edit virtual machine settings”.
    4-When you click on it a new window will open, select “Ethernet” from Devices found in Hardware tab.
    5-Select “Bridged” radi0 button from Network connections.
    6-Click in OK button, and thats it :D .

    now you should give your virtual ethernet card “in ubuntu” an IP address or you can use DHCP “But I think using static IP is much prefered in your case” for more info check
    man ifconfig

    For the modem can you send me its model and manufacturer may be I can help??

    For hosting a website on apache2, well read the post it explains the steps in details ;)

    I hope this would help a little bit ;)

    Chaw

  5. Thanks for that i’ll give it a try sometime this week when im able to.

    The modem is a dynalink rta220, however i also have a dynalink 504t at my disposal

  6. One last question i promise :)

    So i’ve managed to get it all going. except when i got to my address (from no-ip) i can get to the computer hosting the site. however i cant get to the website it is ment to be hosting. What i get instead is a directory as though i’m browsing a folder. How would i go about making it show the website rather than the directory?

  7. Amr Kamel

    @chris,
    congratulations ;) ok try to put an html page containing anything and name it index.html “I mean to put it in /var/www/ ” and try again.. You should see that page, it should be loaded automatically not the folder listing you saw before..

    and keep me updated ;)

  8. Macarena says : I absolutely agree with this !

  9. Aldayel

    I wish I can find like this page but in Arabic

    اتمنى لو وجدت مقالا مثل هذا كتب بالعربي

  10. Amr Kamel

    Dear,
    وأنا أيضاً لكني لا أعرف الترجمة الصحيحة للمصطلحات العلمية
    اذا أردت أن تساعد فلكا الشكر وسوف أساعدك

    You can contact me and we will see what we can do :)

    Best regards,

    Amr M. Kamel.

  1. 1 Work From Home

    [...] Alain wrote an interesting post today onHere’s a quick excerptsudo /etc/init.d/networking restart 12- Finally the last step , We need to configure our web server (apache2) to work correctly woth our new host/domain. We can achieve this my using apache’s virtual hosts. [...]




Leave a Comment