Nginx in Termux – Installation & Setup Guide

Nginx is a high-performance web server that is used to run and manage websites on a local or live environment. It is known for its speed, stability, and easy configuration. You can easily install and run Nginx to create a local web server environment for testing and learning. It also helps you practice deploying and testing web pages before going live. Here’s what you can do with Nginx in Termux:

  • Host local HTML websites on your phone.
  • Test and preview web projects before going live.
  • Learn how web servers and hosting work.
  • Edit and practice server configuration files.
  • Run multiple web pages as a mini website setup.
  • Combine with PHP and databases for dynamic websites.

Installation Commands

Update and upgrade packages.

pkg update && pkg upgrade

Install Nginx.

pkg install nginx

Check installation.

nginx -v

Usage Commands

Start Nginx server.

nginx

Stop Nginx server.

nginx -s stop

Restart Nginx server.

nginx -s restart

Reload Nginx after configuration changes.

nginx -s reload

Check if Nginx is running.

ps aux | grep nginx

Check configuration file for errors.

nginx -t

Kill all Nginx processes (force stop).

pkill nginx

Start Nginx in foreground (debug mode).

nginx -g "daemon off;"

View error logs.

cat $PREFIX/var/log/nginx/error.log

View access logs.

cat $PREFIX/var/log/nginx/access.log

Edit Nginx configuration file.

nano $PREFIX/etc/nginx/nginx.conf

Edit default HTML website file.

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

Test and reload configuration safely.

nginx -t && nginx -s reload

Open web server in browser.

http://127.0.0.1:8080
SHARE THIS POST: