Thursday, December 24, 2015

Raspberry Pi Technique: How to configure an IP address as a custom domain name for a browser

If an Apache HTTP server is installed on a Raspberry Pi, entering the IP address obtained from the ifconfig command in the Epiphany web browser gives this result:




Or the result of a PHP page:




However, is it possible to use a custom domain name to access the above 192.168.xx.xx IP address with a personal Mac?

Yes. The solution is easy. And the good news is: there's no need to pay for the custom URL!!

Just modify the hosts file of Mac using this terminal command:

sudo nano /etc/hosts

And add this line:

192.168.xx.xx     yourdomain.com




Save this hosts file and enter your custom domain name in the browser:



This solution also works with PHP.



You may give your server an awesome domain name you like and then you no long need to enter the numbers of your server's IP address in the browser!

Note the different hosts file path:
Raspberry Pi:   /etc/hosts
Mac:                 /private/etc/hosts

Reference:

No comments:

Post a Comment