How to start Local server in termux?
Hello, thank you for visiting Mr Idealhat again. Today we will know that how can we configure and start local server in termux with the help of termux.
What is server?
Server is a place where we can host your website or you can say your webpages and anyone can access your website all over the world anywhere and anytime with domain name and without domain name.
Very first thing is that, we must know what is server if you are going to start a server in your system probably you know about server.
But here is a quick info.
What is local server?
Local server or local host(127.0.0.1:80) is a host where anyone can host their website on their own system and make changes according to their need and can do much more and without making any payment.
Actually I forgot to mention it in video that what is localhost.
Description:
Let's check that our local server is running or not. For that first go to your browser (choose any browser of your choice) and type localhost in your browser.
Download Commands
Download Web Page
If localhost in on:
If any web page is showing you that means your local server is running and you can host your webpage on your local server.
If localhost is off:
If any webpage is not showing in your browser that means localhost in not running in your device. If your local server is off then when you search for localhost in your browser you will get an error.
Let's know the command which I have used and install local server in my android or you can say successfully started localhost or local server via termux.
Read Also:
- Scan wifi with termux.
- How to install ubuntu in termux?
- What is Brute-Force attack?
- How to hack wifi password?
- Access call history of any device?
Commands:
If you are not comfortable for reading this full article. you can download commands. or you can also download html page for your practice.
apt update
This command helps you to update the packages of termux which will fetch and install new and updated versions of packages in your termux.
apt upgrade -y
This will help you to update your pre-installed packages in termux.
apt install python -y
We are going to install this python package because this is very useful command or packages. This command will install and download python in termux you can do many more stuffs in python but we are here only going to start our local server via termux in android.
Important Note:
localhost:8000
Before next command I want to check that if your local server in running or is in use or not. For that just copy the above URL and paste in your any browser. You can also use (127.0.0.1:8000) as URL.
If you are getting error message like this that means you can proceed fir next command.
Now, you can proceed for next command.
python -m http.server
This is the command which helps us to start local server in android with the help of termux. Just type localhost:8000 command in termux in android and visit your browser and type 127.0.0.1 in search bar or you can follow next step.
localhost:8000
After successfully starting your local server in android with the help of termux. Then, you can visit above url or just type 127.0.0.1 in search bar.
Note:
This server will start the server where your or in which directory you used python -m http.server command. For example, if you started your server in your termux home directory then localhost:8000 will all the files and folders which are present in termux home directory.
Project:
Let's understand with a project or a demo. Make sure you have created a html file or any web page. If you have any webpage you can download mine.
Make sure you have downloaded a web page or created own page. Save it any folder.
For convenience, I have saved html file in a folder named server in my internal storage. So, let's know the commands now.
First, I have to access my internal storage in termux. For that
termux-setup-storage
This command will help you to access the internal storage of your device or you can say in android because termux is not available in iOS.
A pop up will appear to ask you and press allow to permissions.
cd /sdcard/server
This command is helping me to access my server folder which is present in my internal storage.
python -m http.server
This command will again start local server in android which contains a file which is your html page. Just open 127.0.0.1:8000 or localhost:8000 in your browser and you will see a fresh html clean page.
That's how you can host your web page in your local server.
0 Comments