Apache is a powerful and widely used web server that helps you host websites and web applications on Android using Termux. It provides a lightweight local server environment where you can test HTML, CSS, JavaScript, and PHP projects directly from your mobile device. Apache is useful for learning web development, practicing server management, and creating a portable localhost setup. Here’s what you can do with Apache on Android:
- Host local websites on Android.
- Practice web development.
- Test HTML, CSS, JavaScript, and PHP files.
- Learn Apache web server basics.
- Create a portable local hosting environment.
- Run a lightweight development server directly on mobile.
Requirements
Before using Apache on Android, make sure your device meets the following requirements.
- Termux installed (latest version).
- Internet connection required.
- Free storage: Minimum 500MB.
- Android version: Android 7 or above.
- Basic terminal knowledge recommended.
Installation Commands
Update and upgrade Termux packages:
pkg update && pkg upgradeInstall required packages:
pkg install lynx -yInstall Apache server:
pkg install apache2 -yCheck Apache version:
apachectl -vUsage Commands
Fix Apache ServerName warning message:
echo "ServerName localhost" >> $PREFIX/etc/apache2/httpd.confStart Apache server:
apachectl startStop Apache server:
apachectl stopRestart Apache server:
apachectl restartReload Apache configuration:
apachectl gracefulCheck Apache server status:
apachectl statusTest Apache configuration:
apachectl configtestRun Apache in foreground mode:
httpd -D FOREGROUNDCheck listening ports:
ss -tulnp | grep httpdOpen localhost in browser:
http://127.0.0.1:8080Open localhost using device IP (Root device):
ifconfig wlan0Then open:
http://YOUR-IP:8080Apache Basic Commands
Apache basic commands allow you to manage website files, check server information, edit configurations, and monitor Apache processes directly from the terminal.
Go to Apache website directory:
cd $PREFIX/share/apache2/default-site/htdocsList website files:
lsCreate a simple HTML page:
echo "<h1>Apache Running on Android</h1>" > index.htmlOpen HTML file in Nano editor:
nano index.htmlCreate a CSS file:
nano style.cssShow Apache version:
apachectl -vShow loaded Apache modules:
apachectl -MShow virtual host configuration:
apachectl -SView Apache configuration file:
nano $PREFIX/etc/apache2/httpd.confSearch inside Apache configuration:
grep "Listen" $PREFIX/etc/apache2/httpd.confCheck Apache process:
ps aux | grep httpdCheck disk usage:
df -hCheck memory usage:
free -hClear terminal screen:
clearRemove test HTML file:
rm index.htmlThese commands are useful for beginners to understand how Apache works and how to manage a local web server on Android using Termux.
End Note
Now your Apache server is successfully running on Android using Termux, allowing you to host local websites and practice web development directly from your mobile device. Apache provides a simple and powerful way to test projects locally, manage web server functions, and explore Linux server administration on Android.

