How to run php on Android

How to run php on Android





 

As you might know, you need a computer or laptop to run a PHP script using the Apache server. however, how great it would be if you could run PHP scripts on your Android smartphone or tablet. yes, you heard it right! in this article, you will learn how to run PHP and MySQL on your android phone using the KSWEB


What is PHP?



  • PHP is an acronym for "PHP: Hypertext Preprocessor"

  • PHP is a widely-used, open-source scripting language

  • PHP scripts are executed on the server

  • PHP is free to download and use


How to Set Up a Local Web Server on Android 


For this, you need an App called KSWEB, you can download it from play store for free.
it includes:

  • lighttpd server 

  • nginx 

  • PHP v7.3.3

  • MySQL 

  • FTP server

  • PhpMyAdmin

  • Port Routing

Installation of KSWEB


goto the play store and download "KSWEB" it offers a 6-day trial to test its features. after which you can purchase it for further use.
 

Configuration of KSWEB



After you successfully download and install it from the play store, open it. for the first time, it will show a prompt as "installing PHP" and "installing MySQL". let this process happen and make sure you are connected to the internet during this process.


After the above process is complete, you will be re-directed to the main screen as shown below:

 

Steps on How to setup Apache Web Server on Android



  • open KSWEB which you installed previously.

  • Navigate to Apache and turn it on(it will be turned off by default).

  • after turning apache server on, come back to "status" tab

  • Click on the URL shown to you under the heading Apache


  • example: http://localhost:8000 or http://localhost:8001

  • you can either click this URL or manually type it in a web browser.

  • now your web server is successfully running.





How to run PHP on Android



  • open your file manager

  • goto internal storage > htdocs

  • inside htdocs, create a folder with any name you like, for demonstration purpose, we have created a folder named techarena360

  • open any code editor.

  • if you don't have a code editor, click here to read about how to install an HTML code editor on android.

  • next, create a file named "first" and save with(.php)extension i.e "first.php" inside the folder you created within htdocs in the steps above.

  • now, go to the browser you opened earlier and type the URL: http://localhost:8000/techarena360/first.php 

  • here, output will be shown to you.




How to use PhpMyAdmin on Android


  1. inside KSWEB, navigate to tools

  2. click on PhpMyAdmin

  3. enter "root" as the username, and keep the password blank and click "Go".

  4. now you will successfully enter PhpMyAdmin.

What Can PHP Do?


  • PHP can generate dynamic page content

  • PHP can create, open, read, write, delete, and close files on the server

  • PHP can collect form data

  • PHP can send and receive cookies

  • PHP can add, delete, modify data in your database

  • PHP can be used to control user-access

  • PHP can encrypt data


Why PHP?



  • PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)

  • PHP supports a wide range of databases

  • PHP is free. Download it from the official PHP resource: www.php.net

  • PHP is easy to learn and runs efficiently on the server-side


follow TechArena360 for more such amazing Tech content. cheers!


0 Comments: