Make PHP server in android - Dave's Blog

Tuesday, December 13, 2022

Make PHP server in android

"I want to code with php language, but i only have cellphone. how can it work?"

Don't panic, just stay calm. With cellphone we can build PHP server easily. But how? Just follow this tutorial, and enjoy :)

Before we starting the tutorial, I want to remind you first that your cellphone must have at least 500MB ~ 1GB of memory. So let's start the tutorial. the most important thing you must know is:

Install the termux application

Before you installing PHP server, you must have termux application to running the server. But termux in playstore is deprecated. So, you can install new version of termux with this link Termux V.0.118.0. After you have successfully installed the Termux application, open the application and follow the steps below.

1. Upgrade and Update termux application

The first one is upgrade and updating your termux application with this code:

pkg upgrade && apt update

So, it should be like this

Termux

Why we must upgrade our termux application? because there are several components that are not installed in the Termux application, and must be installed manually.

2. Install PHP & Micro editor

The next step is, install PHP and Micro editor with this code:

pkg install php micro

So, it should be like this

Termux

php here is the php server that you will use, and micro here is one of the editor files in Termux. After you have successfully installed both of them, try creating an index.php file using micro with the code below.

micro index.php

After you open the micro editor, fill in the index.php file with the code below as an example.

echo "Hello World";
?>

So, it should be like this

Termux

Save it using CTRL+S and quit micro using CTRL+Q. The next step is turn on your php server. if you want to turn on your php server just call it like this.

php -S localhost:8080

So, it should be like this

Termux

php means command to call php server, -S means server like localhost or 127.0.0.1, and 8080 means port of your server like localhost:8080 or 127.0.0.1:8080. then, you can access it at http://localhost:8080.

Termux

So that's how to easily create a php server on android.

No comments:

Post a Comment