How to Install and Use Nginx in Termux

If you're someone who loves experimenting with powerful tools on Android using Termux, then you’ll definitely want to check out Nginx , one of the most popular open-source web servers available today. Whether you’re testing websites locally, setting up a lightweight server, or learning web hosting basics, Nginx in Termux can help you do it all without needing a computer or a VPS. Run a live website using Nginx in Termux In this blog post, I’ll walk you through the process of installing and using Nginx in Termux on any Android device. What is Nginx? Nginx (pronounced as “engine-x”) is a high-performance web server that is also used as a reverse proxy, load balancer, and HTTP cache. It is known for its speed, stability, low resource usage, and ease of configuration. Many high-traffic websites rely on Nginx because of how well it handles large numbers of concurrent connections. The best part is you can install and run Nginx directly in Termux on Android, making it an excellent option for learning and testing purposes on the go. Why Use Nginx in Termux? Using Nginx in Termux is a great way to turn your Android phone into a local web server. You can host your HTML files, run tests on your site before publishing, or even use it as a backend tool for local development. It's a lightweight alternative that doesn't consume too many resources, and it gives you a better understanding of how servers work, all from the palm of your hand. Step-by-Step Guide to Installing Nginx in Termux Let’s get into the practical part. Follow the steps below to install and start using Nginx in Termux: ### Update Your Packages pkg update && pkg upgrade ### Install Nginx pkg install nginx && pkg install termux-services Wait for the installation to complete. Once done, Nginx is ready to be used. ### Start the Nginx Server nginx After running this command, Nginx will start the server, and it will begin listening on port 8080 by default. ### Check If It’s Working Now that the server is running, you can check it by opening your mobile browser and entering the following URL: http://127.0.0.1:8080 live website hosted successfully If you see a page that says “Welcome to Nginx!”, that means your server is up and running successfully. Nginx Configuration in Termux The main configuration file for Nginx can be found in $PREFIX/etc/nginx/nginx.conf. You can open and edit this file using a text editor like nano: nano $PREFIX/etc/nginx/nginx.conf Inside this config file, you can tweak the server behavior, change ports, add server blocks, and much more, just like you would on a regular Linux system. Hosting Your Own Website on Android If you want to host a custom HTML website using Nginx on Termux, all you need to do is replace the default HTML file located at $PREFIX/share/nginx/html/index.html. Use the following command to edit or replace the file: nano $PREFIX/share/nginx/html/index.html Paste your custom HTML code here, save the file Ctrl + S, close the nano editorCtrl + X and refresh your browser. You’ll now see your own website instead of the default Nginx page. How to Stop Nginx in Termux When you’re done testing or hosting, you can stop the Nginx server using this command: nginx -s stop This will gracefully shut down the server and free up the resources. Final Thoughts Running Nginx in Termux is a perfect way to learn about web servers and site hosting, especially if you’re working without a laptop or want a lightweight solution for Android. Whether you’re a student, a developer on the move, or just curious about web technology, this setup allows you to explore the full power of Nginx using only your mobile device. I highly recommend giving it a try—you might be surprised by how much you can do with just Termux and a little bit of curiosity. Originally published at TerminalTools

Apr 21, 2025 - 06:49
 0
How to Install and Use Nginx in Termux

If you're someone who loves experimenting with powerful tools on Android using Termux, then you’ll definitely want to check out Nginx , one of the most popular open-source web servers available today. Whether you’re testing websites locally, setting up a lightweight server, or learning web hosting basics, Nginx in Termux can help you do it all without needing a computer or a VPS.

Illustration of a web server setup with three stacked server icons connected to a monitor displaying code, alongside bold text saying ‘Run Live Website Using Termux’ featuring Nginx and Termux tags, designed in a clean modern tech style.
Run a live website using Nginx in Termux

In this blog post, I’ll walk you through the process of installing and using Nginx in Termux on any Android device.

What is Nginx?

Nginx (pronounced as “engine-x”) is a high-performance web server that is also used as a reverse proxy, load balancer, and HTTP cache. It is known for its speed, stability, low resource usage, and ease of configuration. Many high-traffic websites rely on Nginx because of how well it handles large numbers of concurrent connections.

The best part is you can install and run Nginx directly in Termux on Android, making it an excellent option for learning and testing purposes on the go.

Why Use Nginx in Termux?

Using Nginx in Termux is a great way to turn your Android phone into a local web server. You can host your HTML files, run tests on your site before publishing, or even use it as a backend tool for local development. It's a lightweight alternative that doesn't consume too many resources, and it gives you a better understanding of how servers work, all from the palm of your hand.

Step-by-Step Guide to Installing Nginx in Termux

Let’s get into the practical part. Follow the steps below to install and start using Nginx in Termux:

  • ### Update Your Packages
pkg update && pkg upgrade
  • ### Install Nginx
pkg install nginx && pkg install termux-services

Wait for the installation to complete. Once done, Nginx is ready to be used.

  • ### Start the Nginx Server
nginx

After running this command, Nginx will start the server, and it will begin listening on port 8080 by default.

  • ### Check If It’s Working

Now that the server is running, you can check it by opening your mobile browser and entering the following URL:

http://127.0.0.1:8080

Screenshot of the default Nginx welcome page on a black background, confirming successful installation of the Nginx web server with instructions and support links to nginx.org and nginx.com.
live website hosted successfully

If you see a page that says “Welcome to Nginx!”, that means your server is up and running successfully.

Nginx Configuration in Termux

The main configuration file for Nginx can be found in $PREFIX/etc/nginx/nginx.conf.

You can open and edit this file using a text editor like nano:

nano $PREFIX/etc/nginx/nginx.conf

Inside this config file, you can tweak the server behavior, change ports, add server blocks, and much more, just like you would on a regular Linux system.

Hosting Your Own Website on Android

If you want to host a custom HTML website using Nginx on Termux, all you need to do is replace the default HTML file located at $PREFIX/share/nginx/html/index.html.

Use the following command to edit or replace the file:

nano $PREFIX/share/nginx/html/index.html

Paste your custom HTML code here, save the file Ctrl + S, close the nano editorCtrl + X and refresh your browser. You’ll now see your own website instead of the default Nginx page.

How to Stop Nginx in Termux

When you’re done testing or hosting, you can stop the Nginx server using this command:

nginx -s stop

This will gracefully shut down the server and free up the resources.

Final Thoughts

Running Nginx in Termux is a perfect way to learn about web servers and site hosting, especially if you’re working without a laptop or want a lightweight solution for Android. Whether you’re a student, a developer on the move, or just curious about web technology, this setup allows you to explore the full power of Nginx using only your mobile device. I highly recommend giving it a try—you might be surprised by how much you can do with just Termux and a little bit of curiosity.

Originally published at TerminalTools