#

Sunday, February 19, 2017

Put Your Website Online from Home with Port Forwarding & DDNS

You can use any web server or even a PC if you can afford it for your web host. This is just how I did it with my Raspberry Pi..

Start with giving your server a static IP address from your private home network. I gave 192.168.1.254 to my Pi and connected it to my home router.

If your server is a Debian based like mine, you can enter the exact commands I enter from here, or you must find alternatives from online to do what I do here..

Enter following commands to install Apache and PHP modules..
sudo apt-get install apache2
sudo apt-get install php libapache2-mod-php -y

May be you need to restart the Apache server; Enter following command
sudo service apache2 restart

Now Enter your IP address on a webserver; It will point to the default landing page of Apache. 

Now navigate to the default hosting page directory by entering the following command..
cd /var/www/html

Now if you hit ls you can see the index.html page which is the default landing page of Apache.
You can delete this by entering the following command..
sudo rm -f index.html

Now you can replace contents of your website here. I am just creating a default simple page by entering the following commands..
sudo nano index.html

Now hit Ctrl+X, Y & Enter to save it.




If the static IP of the server is entered on the web browser, you can see the home page of your website now..

Now it is the time to create a DDNS account from a service provider. There are plenty of DDNS service providers out there. I created an account on no-ip.com


It is very simple to get a web address through your DDNS service provider online. Just use common IT sense..







You can see the IP address assigned to your web address. Now you need to install the Dynamic Update Client of your DDNS service provider on your server..

Enter the following commands to create a folder, download and unzip the Client..
sudo mkdir /home/pi/noip
cd /home/pi/noip
sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
sudo tar vzxf noip-duc-linux.tar.gz

Now hit ls to view the contents of the folder.




Now you can see the folder is noip-2.1.9-1
Enter following commands to compile the Client..
cd noip-2.1.9-1
sudo make
sudo make install



















By entering the following command you can run the Client;
sudo /usr/local/bin/noip2

Finally you need to set Port Forwarding on your home router.

How you do it depends on the type of your router. My home router is a TP-Link one. On it's administration page, there is an option named "NAT" and under that there is another option named "Virtual Server" to setup port forwarding. Following capture shows you all the configuration..

















Now everything is done. You can type the URL you got from your DDNS provider and enter it on your web browser to see whether your website is online or not..


No comments:

Post a Comment