php apache setup on android with Termux (without root)
- Download Termux (allow installation from unknwon sources and install the termux app)
- Example htdocs files
Termux Setup Steps
update packages (If it asks you, choose yes in both cases.)
apt update -y && apt upgrade -y
- Install Apache and PHP 7
There is as of now a bundle that serves to introduce these two things together. That is, through apache PHP documents are prepared. To introduce our LAMPP on Android we will run:
apt install php-apache
That will install apache, PHP and a few libraries that will permit us to join the two things.
- configure apache to process the PHP files
We are going to configure the httpd.conf file. Attention here, because the route is important. The apache configuration file is in
You can change to that folder with:
Then open the file with nano:
- Load PHP module
on httpd.conf, scroll down until you see string start with LoadModule. Then add new line and type bellow code:
LoadModule php7_module /data/data/com.termux/files/usr/libexec/apache2/libphp7.so
- Set handler
Add new line after
LoadModule php7_module and type bellow code:
We are revealing to Apache that records that conform to a standard articulation/regex (where the document is one of PHP) are prepared by a controller.
Now above steps looks like:
- Change Index
Scroll again, and find text contains
DirectoryIndex index.html. Looks like bellow:
php, seem looks like bellow:
We do this to advise apache to serve index.php over index.html (this is a change and that doesn't mean we can not serve HTML).
For instance, in the event that we visit
example.com apache will default to index.html, rather this change will serve
index.php. Save changes and close the record.
CRTL+X -> Save Dont Rename
- Write first index.php on public directory
Our htdocs located in
/data/data/com.termux/files/usr/share/apache2/default-site/htdocs. Just type bellow code:
Write your first php code or any text. I suggest type bellow code:
Now save it.
CTRL+X -> Save don't rename
- Start apache
To start apache daemon, type bellow commands:
On the off chance that it doesn't show errors at that point all is well.