How to Setup Apache Web Server On Any Android Device?
Last Updated :
10 Nov, 2020
In this article, we will learn how we can set up Apache Web Server On Any Android Device. For doing this we have to install the Termux app available on the play store. Termux is an Android terminal emulator and Linux environment application that works directly with no rooting or setup required. Termux provides a Linux-like shell to the user where he can do tasks like running commands and executing scripts. Termux provides pkg and apt package manager for installing packages, these package managers are just like apt and other package managers of Linux.
So let's use one of the package managers provided by Termux to install an Apache web server on your Android device. Here below is the step-by-step guide to setup Termux and Apache on your device.
Step 1: Download the Termux app from Google Play Store.

Step 2: After the installation is complete, open Termux and type the following commands to update pre-installed packages and to installed apache2 package.
sudo apt update
sudo apt install apache2

Step 3: After installing Apache start the Apache server using the following command to start the Apache server.
apachectl -k start
Some errors will be thrown after the execution of this command you can safely ignore them.

Now open the browser and visit http://127.0.0.1:8080. The browser will return the following response which confirms that the server is active and the apache2 server is configured on your device.

Step 4 (Optional): If you are on a Wi-Fi network and want to access your Apache server from any device on the same network then use the following commands.
$ apt install vim
This command installs the vim text editor.
$ cd ..
$ vim usr/etc/apache2/httpd.conf
After executing these commands httpd.conf file will open, add ServerName to the httpd.conf here value of ServerName will be your local IP address over the WiFi network, like in case if your IP address is 192.168.1.2 then add the following line to httpd.conf and restart the apache server by using the same command used in step 3 and open the URL http://<your-IP-Address>:8080 like in this case the URL would be http://192.168.1.2:8080.
ServerName 192.168.1.2
Note: Replace 192.168.1.2 with the IP address of your android device.
Step 5: If You want to remove the default page served by Apache then go to the following directory
$ cd usr/share/apache2/default-site/htdocs
Similar Reads
How to Run the Android App on a Real Device? The time comes when the Android Studio project is ready and you want to test that application. One can test the application by running the application which can be done in two ways. By running the app on an Android Virtual Device(AVD), andBy running the app on a real device So in this article, we ar
2 min read
How to install and configure Apache Web Server on Godaddy Server? GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. Itâs a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache HTTP Server is an open-source web server softw
2 min read
How to Install PHP on Android Device? Php is an open-source programming language that is typically used for Web development but may also be used for other purposes (backend developing). To put it succinctly, PHP is a server-side scripting language that may be installed on any device (e.g. bits of code to add forms to your site).It opera
2 min read
How to Install and Set up a WAMP Server ? Windows, Apache, MySQL and PHP is commonly abbreviated as WAMP. Some people may confuse with LAMP but the only difference between the two is their operating systems. In case of LAMP, L stands for Linux. Setting up a server included the installation of all the software listed in the abbreviation. Ano
3 min read
How to Connect to Android with ADB over TCP? In this article, we will discuss how we connect the Android Debug Bridge (ADB) over TCP. ADB is used to communicate with the device. It provides access to a Unix shell that you can use to run a variety of commands on a device. It has mainly three components: Client: It is the user who sends the comm
2 min read
How to Create a News App in Android? Networking is an integral part of android development, especially when building data-driven clients. The java class mainly used for network connections is HttpUrlConnection. The class requires manual management of data parsing and asynchronous execution of requests. For network operations, we are be
9 min read