Friday, February 20, 2009

How to build a Web Host on your computer that is accessible from the outside world?

I assumed that your followed my previous post for your webhost (http://ccstone.blogspot.com/2008/09/how-to-build-web-host-on-your-computer.html) and it is now the time make it accessible from outside world.

1) Change Default Port of your WebHost

1a) Open \mowes\apache2\conf\httpd.conf
1b) Goto line 127 (or somewhere around there
1c) Search for "Listen 80"
1d) Change 80 into any number between 2000 to 8000 (as you like), e.g. 2337
1e) Save and exit
1f) Restart mowes
1g) Give your homepage a test: originally you access a page like http://localhost/mingpao.php , now you have to access the same page with http://localhost:2337/mingpao.php

Notes: the reason behind changing default port is that most ISP blocked port 80, and it is not an easy (noob) task to redirect traffic

2) Setup Port forward in your router (if you have one)

There is no detailed instruction for this setting, as everyone use different brand and model of router. But in general you can follow procedure

2a) Open Command Prompt ("Run..." then enter "cmd")
2b) Type ipconfig and press enter. This is an example of result:

Windows IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.222
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

2c) Start browser and browse the page indicated by "Default Gateway". E.g. http://192.168.1.1/ . You are now in router setting.
2d) Enter password as needed. Those login information can be retrieved from your router manual.
2e) Look for Firewall setting / Port Forward / DMZ / etc.. Every brand and model differ from each other, so you have to navigate yourself to the destination.
2f) Setup a Port Forward to your computer. E.g. map port "2337" to "192.168.1.222" as IP Address in your ipconfig result.
2g) Save setting and retrieve your EXTERNAL IP address from your router setting. It can usually be found in "Connection Status" page or "Internet Setting" page. E.g. "202.169.200.234"
2h) Test if your setting is correct. Instead of using http://localhost:2337/mingpao.php, now try http://202.169.200.234:2337/mingpao.php

3) Setup a free domain name for your webserver

Some new router include this function internally. If so, follow the instruction in router manual. For those routers without such setting, or if you do not use a router at all, follow this instruction for easy domain setup.

3a) Visit http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html
3b) Sign up the FREE DNS redirect service
3c) Register a Domain of your choice. E.g. helloworld.myvnc.com
3d) Download and install the No-IP DUC client.
3e) Add in the Hosts your newly registered domain
3f) Test your new host. Instead of http://202.169.200.234:2337/mingpao.php, try http://helloworld.myvnc.com:2337/mingpao.php
3g) (Optional) Setup the "Port 80 redirect" function at NO-IP DUC, so that you don't have to enter the port 2337 (I didn't do it personally)

-------------

After all those setup, you can now access your webhost from anywhere in the world, including your Laptop, iPhone, PDA, etc.

Enjoy