Apache Linux Server on Android – Installation & Usage Commands

Apache Linux server is widely used in cloud hosting, Linux server administration, and enterprise web infrastructure. You can install and run Apache directly on Android using Termux to create a local web server. It is useful for learning web hosting, testing websites, and practicing server management. Here’s what you can do with Apache Linux Server on Android:

  • Host local websites on Android
  • Test HTML, CSS, JavaScript, and PHP projects
  • Learn web server management
  • Practice Apache configuration
  • Create a local web development environment

Installation Commands

Update Termux packages:

pkg update && pkg upgrade -y

Install Apache Server:

pkg install apache2 -y

Check Apache version:

apachectl -v

Start Apache Server:

apachectl start

Usage Commands

Stop Apache Server:

apachectl stop

Restart Apache Server:

apachectl restart

Check server status:

apachectl status

Open localhost in browser:

http://127.0.0.1:8080

Check Apache configuration:

apachectl configtest

Create and Load a Test HTML Page

Go to Apache website directory:

cd $PREFIX/share/apache2/default-site/htdocs

Create HTML file:

nano index.html

Paste this example HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apache Server in Termux</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}

body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #0f172a, #1e293b);
color: white;
text-align: center;
padding: 20px;
}

.container {
width: 100%;
max-width: 700px;
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 20px;
padding: 40px 25px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

h1 {
font-size: 42px;
margin-bottom: 15px;
color: #38bdf8;
}

p {
font-size: 18px;
line-height: 1.7;
color: #e2e8f0;
margin-bottom: 20px;
}

.badge {
display: inline-block;
background: #22c55e;
color: white;
padding: 10px 18px;
border-radius: 30px;
font-size: 14px;
font-weight: bold;
margin-top: 10px;
}

.footer {
margin-top: 25px;
font-size: 14px;
color: #94a3b8;
}

@media (max-width: 600px) {
h1 {
font-size: 30px;
}

p {
font-size: 16px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Apache Server Running</h1>

<p>
Your Apache web server is successfully running inside Termux on Android.
You can now host local websites, test projects, and practice web development directly from your phone.
</p>

<div class="badge">
Apache + Termux Active
</div>

<div class="footer">
Powered by Termux & Apache2
</div>
</div>
</body>
</html>

Save and exit Nano:

CTRL + X
Y
ENTER

Start Apache server:

apachectl start

Open localhost in browser:

http://127.0.0.1:8080

Apache Basic Commands

Show Apache version:

apachectl -v

Show loaded modules:

apachectl -M

View server information:

apachectl -S

Edit Apache configuration:

nano $PREFIX/etc/apache2/httpd.conf

View website files directory:

cd $PREFIX/share/apache2/default-site/htdocs
READ ALSO  C++ in Termux – Installation & Usage Commands

Leave a Comment