Hello friends and welcome back to another new blog post. In the last blogpost I shared with you guys, how you can install ngrok in your termux. In this blogpost I’ll explain you how you can install apache2 in termux.
Table of contents
What is Apache2 ?
Apache2 is a open source web server software. With the help of apache you can create and run webserver on your device.
Install & Use Apache2
To install apache2 in your Termux follow the commands given below.
- Update the list of packages
- Install apache2
apt install apache2
- Done ! You’ve successfully installed apache2 in you Termux.
- To Run apache server type the following command
- Open your browser and go to localhost:8080 you’ll see “It Works” message, that means your apache server is running without any error.
- To stop the running apache server type
apachectl -k stop
Add HTML files Or Edit Existing Ones In Termux Apache2 Webserver
“It Works” message is displayed by the index.html file in apache’s directory. You can add your own html files too in apache’s directory or edit index.html file.
To add or edit files you need to get inside /data/data/com.termux/files/usr/share/apache2/default-site/htdocs directory. Enter the command available below to directly get inside htdocs directory.
In htdocs directory, you can add you own html files or even edit the existing one using nano text editor or any other text editor.
You can also add anchor tags in your html files to connect it with one another. For example, you can make your index.html as you homepage by editing it and then create another webpages then link them with your index.html
Make Apache Server Live Using Ngrok
You can also make your apache server live on internet. So that anyone with the link, can access the files in your apache server. Make sure you have ngrok installed and setup. If you don’t know how to do it click here. After that simply type the command below, to run ngrok that will start a secure http tunnel from port 8080.
./ngrok http 8080
After the ngrok connection is online. You can share the ngork link displayed on your screen to anyone you want, anyone can access your running apache web server with that link.
So this is how you can run apache2 web server in your android device with the help of Termux. You can also make your apache server online using ngrok, so that anyone on internet can access it. If you are stuck somewhere feel free to watch my video about it.