Run powerful PHP scripts directly on your Android using Termux—no root needed!
If you’re looking to install PHP in Termux on your Android device, this beginner-friendly tutorial will walk you through each step clearly. With just a few commands, you’ll be writing and executing PHP scripts like a pro—even from your phone.
🤔 Why Install PHP in Termux?
PHP is a widely-used scripting language, especially for web development. Installing PHP in Termux allows you to:
- Test websites locally
- Run small web servers
- Automate tasks
- Learn backend development—all from your Android
✅ Step-by-Step: How to Install PHP in Termux
🔹 Step 1: Update Termux
pkg update && pkg upgrade -y
🔹 2: Install PHP
pkg install php -y
🔹Then Step 3: Check PHP Version
php -v
You should see something like: PHP 8.2.x (cli) confirming the installation.
💻 How to Run PHP Scripts in Termux
Create a new file:
nano hello.php
Add this code:
<?php
echo "Hello from PHP in Termux!";
?>
Save and exit (CTRL + X, then press Y and Enter)
Run it:
php hello.php
✅ You’ll see: Hello from PHP in Termux!
🌐 Want to Use PHP with a Localhost Server?
Install a lightweight server:
pkg install nginx -y
Serve PHP files using php -S:
php -S localhost:8080
Then visit http://localhost:8080 in your browser.
🧠 Bonus Tips
- Combine PHP with SQLite or MySQL for full-stack mobile development
- Use PHP to automate server-side tasks
- Learn Laravel or Symfony on desktop after mastering basics in Termux
🎥 Full Demo Coming Soon
Subscribe to Egwimcodes Hub on YouTube for step-by-step video tutorials on PHP, Git, Python & more.


