Android mobiles are incredibly versatile, being able to go from a portable console to an e-book reader, a Google Home or a webcam, to name a few. An Android mobile too can become a web server.
your next website can live on your mobile and be visible to the whole world, as long as your mobile is still connected to the Internet. Obviously, it’s not the most practical thing in the world, but it’s an interesting project that really won’t take you more than a few minutes.
My site lives on my mobile
When building a website, you basically have two options: use a hosting service or host it yourself. In the latter case, it is normal for you to have the server on a computer with a Linux distribution, but you can also do the same on something else that you walk around the house: on an Android mobile.
Better yet, the process of turn an android mobile into a web server It’s much simpler than it seems at first glance, even for those who have never touched a system terminal in their life, as this blog details, hosted on a mobile with Android 11.
all you need is termux, a powerful Linux emulator for Android. You can download it from F-Droid, because the Google Play version is outdated. Termux installs like any other application and does not require root.
Be a miniature Linux, Termux keeps multiple processes running on the system and may not work properly from Android 12 onwards, as the system limits the number of threads an app can keep running. However, for the simple web server in our experience, I had no issues with Android 13.
First, prepare the ground
With Termux installed, you will need to install all the necessary packages in your pocket Linux. For this we are going to have to open Termux and write some commands in the terminal. First let’s go update packages with the following commands:
package update
package upgrade
Write the above commands separately, pressing the submit button in between. You may be asked whether you want to update or overwrite some versions, in which case you can press the Enter key to use the default settings.
Then comes the time to install two packages which we will need for our web server. Again, enter the commands one by one in the terminal, one by one, and stay tuned as you will be prompted to respond by typing if you want to confirm the download or installation. If in doubt, accept the default option.
pkg install openssh
pkg install nodejs-lts
You create the web
At this point, you already have all the necessary tools, but you’re still missing the most important thing: your website. Since we’re basically doing an experiment, if you want you can opt for a basic “Hello world”, using the following command to generate an HTML page which says exactly that, “Hello world”.
echo “
Bonjour Monde
” > index.html
If you have something more complex in mind and fancy having an entertaining HTML writing session with Gboard, you can use the nano text editor to edit the HTML file and create a slightly more complex page:
nanoindex.html
Make your website accessible from the outside
You already have your website, but need to start the web server make the web accessible. You can start the Termux web server using the following command in the terminal:
npx http server &
At this time, you can visit your creation from the same device, at http://127.0.0.1 or from another device on the same local network, using the mobile’s local IP address. However, the website will not normally be accessible from the outside, unless you bothered to port forward the router. There is a better alternative.
Instead, you can use the Pinggy service to create a public web address. you can use pinggy free on a limited basis, which will cause each address to expire after 60 minutes, more than enough for our invention. Type the following command to enable pinggy redirect:
ssh -p 443 -R0:localhost:8080 a.pinggy.io
You will then see in the console the web address of your tunnelwhich will be a series of letters before pingggy.io, like https://ranaelvrajzeb.a.pinggy.io. This is the address of the webpage that lives on your mobile and now you can pass it on to your friends so they can visit it.
Upon payment, for about $2.50 per month that Pinggy Pro costs, you could have your live web server on Android with a permanent personalized addressAlthough it already depends on your motivation with the project of having the web live on your mobile.
Through | Hacker Newsletter
In Xataka Android | All the Google Icons Explained: Here’s What the Logos Mean for Gmail, Drive, Maps, and More
Table of Contents