DEV Community

Stephano Kambeta
Stephano Kambeta

Posted on

How to Host a Local Website on Android Using Termux

Did you know you can turn your Android phone into a mini web server? No need for hosting accounts, no need for cPanel. Just use Termux and a tool like Nginx to host a simple local website directly from your device.

In this guide, I’ll show you how to install Nginx in Termux and host your own local site. Perfect for testing, learning web development, or running a lightweight internal site.

📲 Requirements

  • Android phone
  • Termux installed – Install Termux
  • Internet connection (for installation only)

🔧 Step 1: Update Termux

pkg update -y && pkg upgrade -y
Enter fullscreen mode Exit fullscreen mode

🔌 Step 2: Install Nginx Web Server

Use the command below to install Nginx:

pkg install nginx -y
Enter fullscreen mode Exit fullscreen mode

This installs the Nginx server on your Android via Termux.

🌐 Step 3: Start the Server

nginx
Enter fullscreen mode Exit fullscreen mode

To check if it’s running, open your browser and visit:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

You should see the default Nginx welcome page.

If that worked, congrats—your Android is now a local web server!

For more info on this, see the full guide: Install and Use Nginx in Termux.

📝 Step 4: Add Your Own Website Files

Website files are stored in this directory:

$PREFIX/share/nginx/html
Enter fullscreen mode Exit fullscreen mode

Use cd to navigate:

cd $PREFIX/share/nginx/html
Enter fullscreen mode Exit fullscreen mode

You’ll see a default index.html file. Replace it with your own HTML file:

nano index.html
Enter fullscreen mode Exit fullscreen mode

Add your custom content, then save it. Refresh localhost:8080 in your browser to see your site!

🛑 Step 5: Stop the Server

To stop Nginx:

nginx -s stop
Enter fullscreen mode Exit fullscreen mode

This cleanly shuts down the web server.

🔒 Bonus: Keep It Secure

Even if you’re hosting locally, it’s a good idea to stay security-conscious. Learn more about:

🔗 Related Termux Posts You’ll Love

✅ Final Words

Hosting a website locally on Android is easier than most people think. Termux + Nginx gives you a solid way to test HTML, run local services, or even build secure internal tools.

If you’re learning cybersecurity or ethical hacking, this is also a great first step toward understanding servers and traffic. Just remember to stay ethical, secure your setup, and always test responsibly.

Need to take it further? Learn how to gather cyber threat intelligence or explore cybersecurity frameworks like NIST.


💬 Got stuck or want to share your setup? Drop a comment and let’s talk!

Top comments (0)