DEV Community

Bishakh Ghosh
Bishakh Ghosh

Posted on

Website in your pocket. Turn your Android phone into a web server! πŸš€

Hosting a website is simple right? Let us do something cooler insted. How about hosting a website from your Android device? Do not worry, we need not root/jailbreak your phone.

πŸš€ Let's Get Started!

Tools You'll Need:

  1. Termux: Termux is an Android terminal emulator for running a web server like Node.js http-server.
  2. Pinggy: Pinggy.io is a tool to obtain public URLs for accessing your server.

Sneak Peek

Here's a sneak peek of a blog running on a $180 Android phone. Check out the screenshots below:

Node.js http-server running

Pinggy’s terminal interface showing live requests

Step 1: Install Termux

First, we need to install Termux. This app emulates a terminal and Linux environment on your Android device without rooting or additional setup. You can get Termux from F-Droid or download the APK directly from the Termux website.

Step 2: Install Necessary Packages

Now, let's get the essential packages for our web server. Open Termux on your phone. Update and install the packages using these commands:



pkg update
pkg upgrade
pkg install openssh
pkg install nodejs-lts


Enter fullscreen mode Exit fullscreen mode

Check the versions to ensure they installed correctly:



node --version
npm --version


Enter fullscreen mode Exit fullscreen mode

Image description

Step 3: Start the Server and Pinggy Tunnel

Create a sample HTML page:



echo "<h1>My awesome website!</h1>" > index.html



Enter fullscreen mode Exit fullscreen mode

You can edit this page using nano or vim editors. Then, start the http-server:



npx http-server &



Enter fullscreen mode Exit fullscreen mode

This command runs the server on port 8080 by default.

Now let's get a public URL with one Pinggy command. In a new Termux window tun the following.



ssh -p 443 -R0:localhost:8080 a.pinggy.io


Enter fullscreen mode Exit fullscreen mode

You'll receive a public URL like https://ranxyzxxxx.a.pinggy.online. Share this URL with your friends and see live stats of visitors on the Pinggy terminal interface. πŸŽ‰

Hosting a website or blog from your Android device might sound impossible, but it's totally doable with the right tools! Using Termux and Pinggy, you can create and share your content with the world. So, why not give it a try? Unleash your creativity and bring your ideas to life on your personal web server! 🌟

Top comments (0)