How To Setup Linux Web Server And Host Website On Your Own Computer [Part – 2]
What are we not going to cover when setting up Linux web server?
What are We going to cover to setup Linux web server without problems?
When you setup a web server on your own Linux box, people can only access it using the IP address. And all of us know that the IP address keeps changing. In a day we’re allotted many IPs so if we host a web server with this problem, no one will be able to access our website after a few hours or even minutes. So we need to setup static IP that does not change. But, here is another solution to this problem. As I mentioned above that setting up static IP can be a mess so we will not go for setting up static up. Rather, we’ll update the changing IPs with the web server and allot a URL or domain. So whenever IP changes, a small client updates the new IP with domain and we have a working website after months, years and forever until that tunnel is running.
ngrok, the Easiest way to make localhost available online
How To Use ngrok To Make Linux Web Server Online?
It’s easy. Firstly visit ngrok website and download ngrok client for your Linux machine. Be sure that you select the right architecture (64bit or 32bit). After the download is completed extract it somewhere on your computer. For ease of access, I extract it in my home folder. Now open a terminal and run the following command to create a tunnel to your localhost.
ngrok assigns a URL to the localhost automatically
Hurrah! Now it has successfully created a tunnel to your localhost. There are two URLs that go to the same website that we hosted on our computer. The second URL is https version. Just copy the URL from the terminal and past it into the browser from any part of the world! You’ll see your hosted website. Now just take a deep breath and relax. You’ve hosted your own Linux web server. Now as longs as the client are running, your website is running. If you stop the tunnel then restarting tunnel will provide a different URL. Though you can have your own custom URLs with a subdomain it is paid. You can also reserve a URL that will not be assigned even if you stop your tunnel.
I hosted a website using the same method and it’s running on my laptop. You can check it up.