Apache

Terminal Guide & Documentation

Apache in Termux - Complete Installation and Usage Guide

What is apache

Apache HTTP Server is a free and open-source cross-platform web server software. It is one of the oldest and most reliable web servers in the world, powering a significant portion of the internet. In Termux, Apache allows you to host local websites, test web applications, and create a mobile development environment directly on your Android device.

Prerequisites

Before installing Apache, ensure your Termux environment is ready:

  • Storage Permission: Useful if you want to host files from your internal storage.
  • Port Awareness: By default, Termux services cannot use ports below 1024 without root. Apache in Termux typically uses port 8080.
  • Stable Internet: Required for downloading the initial package.

Installation Commands in Termux

Follow these steps to set up the Apache (httpd) package.

1. Update Repositories

Ensure your package list is current.

BASH - TERMINAL COPY CODE
pkg update && pkg upgrade -y

2. Install Apache (httpd)

Install the apache2 package (sometimes referred to as httpd in other distros).

BASH - TERMINAL COPY CODE
pkg install apache2 -y

3. Start the Server

Launch the Apache daemon.

BASH - TERMINAL COPY CODE
apachectl start

Basic Usage & Examples

Once started, your server is live. Here is how to manage it and locate your files.

Accessing the Default Page

Open your browser and navigate to the local host address.

URL - BROWSER COPY URL
http://localhost:8080

Locating Web Files

In Termux, the default document root where you should place your HTML files is:

PATH - TERMINAL COPY PATH
/data/data/com.termux/files/usr/share/apache2/default-site/htdocs/

Stopping the Server

Kill the Apache process when you are finished testing.

BASH - TERMINAL COPY CODE
apachectl stop

Restarting for Configuration Changes

Apply changes made to the httpd.conf file.

BASH - TERMINAL COPY CODE
apachectl restart

Explore More Tools

Nmap

Powerful network discovery and security auditing.

WAFW00F

Identify Web Application Firewalls (WAF).

Cool Commands

Visual and fun terminal commands for Termux.