How To Setup Linux Web Server And Host Website On Your Own Computer [Part - 2]
Table of Contents
- 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?
- ngrok, the Easiest way to make localhost available online
- How To Use ngrok To Make Linux Web Server Online?
- ngrok assigns a URL to the localhost automatically
- Conclusion
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 http 80
Warning – Apache web server that we setup in part 1 by default runs on port 80. But, if you changed the port, then please enter that port # in the above command instead of 80. For example, if you changed the port to 90 then use command
./ngrok http 90
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.
5a1851dd.ngrok.io
Conclusion
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.