Skip to content

CreatorB/php-web-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ PHP Web Terminal - PWT

A lightweight, browser-based terminal for shared hosting environments where SSH/Terminal access is blocked.

PHP Laravel License Hosting


πŸ“Œ Background

Most affordable shared hosting providers block SSH and Terminal access by default. This tool was built to solve that β€” providing a real terminal experience directly through the browser using PHP's execution functions.

Built & battle-tested on Indonesian shared hosting (cPanel, PHP 8.2, CloudLinux).


✨ Features

  • πŸ” Password protected login screen
  • πŸ’» Real-time AJAX execution β€” no page reload
  • πŸ“ cd navigation with persistent directory across commands
  • πŸ“œ Unlimited scroll history β€” scroll up to see all previous output
  • ⬆️⬇️ Arrow key history navigation (like real terminal)
  • 🎨 Linux-like dark UI with green prompt
  • πŸ”„ Smart PHP CLI detection β€” uses correct PHP binary, not web PHP
  • πŸ“¦ Composer & Git & Laravel Artisan compatible

πŸ“Έ Preview

(work in progress)


πŸš€ Quick Start

1. Upload

Upload terminal.php to your public_html via cPanel File Manager or FTP.

2. Set Password

Open the file and change on line 3:

define('PASS', 'your-secure-password');

3. Access

https://yourdomain.com/terminal.php

πŸ“¦ Install Composer (No SSH Required)

Since shared hosting blocks SSH, download Composer binary directly:

Step 1 β€” Find PHP CLI binary

which php
# or use full path:
/opt/alt/php82/usr/bin/php --version

Step 2 β€” Download Composer binary

curl -o composer.phar https://getcomposer.org/download/latest-stable/composer.phar

Or with wget:

wget -O composer.phar https://getcomposer.org/download/latest-stable/composer.phar

⚠️ Do NOT use curl ... | php or php -r "copy(...)" on shared hosting
β€” it may execute via web PHP and output HTML instead of binary.

Step 3 β€” Verify

/opt/alt/php82/usr/bin/php composer.phar --version
# Composer version 2.x.x

Step 4 β€” Create alias (optional but recommended)

alias php='/opt/alt/php82/usr/bin/php'

Now you can use php composer.phar normally.


πŸ—οΈ Deploy Laravel on Shared Hosting

Full workflow from zero to running Laravel β€” no SSH needed.

1. Clone / Pull from Git

git clone https://github.com/username/your-laravel-repo.git .
# or update existing:
git pull origin main

2. Install Dependencies

COMPOSER_HOME=/home/username/.composer /opt/alt/php82/usr/bin/php composer.phar install --no-dev --optimize-autoloader

If fileinfo extension error, either:

  • Enable via cPanel β†’ Select PHP Version β†’ Extensions β†’ fileinfo
  • Or add flag: --ignore-platform-req=ext-fileinfo

3. Setup Environment

# Copy env file
cp .env.example .env

# Open and edit database config
nano .env
# or edit via cPanel File Manager

Edit these values:

APP_NAME=YourApp
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password

4. Generate App Key

/opt/alt/php82/usr/bin/php artisan key:generate

5. Run Migration

/opt/alt/php82/usr/bin/php artisan migrate

With seeder:

/opt/alt/php82/usr/bin/php artisan migrate --seed

Fresh migration (reset all):

/opt/alt/php82/usr/bin/php artisan migrate:fresh --seed

6. Storage & Cache

# Link storage
/opt/alt/php82/usr/bin/php artisan storage:link

# Clear & optimize all cache
/opt/alt/php82/usr/bin/php artisan optimize:clear
/opt/alt/php82/usr/bin/php artisan optimize

7. Set Permissions

chmod -R 755 storage
chmod -R 755 bootstrap/cache

πŸ” Daily Deploy Workflow

After pushing code updates:

git pull origin main
COMPOSER_HOME=/home/username/.composer /opt/alt/php82/usr/bin/php composer.phar install --no-dev --optimize-autoloader
/opt/alt/php82/usr/bin/php artisan migrate
/opt/alt/php82/usr/bin/php artisan optimize:clear
/opt/alt/php82/usr/bin/php artisan optimize

🟒 Node.js Deploy (Coming Soon)

Node.js workflow example will be added here, inshaAllah.


βš™οΈ Recommended PHP Extensions

Enable these in cPanel β†’ Select PHP Version β†’ Extensions:

βœ… fileinfo     βœ… mbstring     βœ… curl
βœ… zip          βœ… gd           βœ… pdo_mysql
βœ… opcache      βœ… xml          βœ… openssl
βœ… json         βœ… tokenizer    βœ… bcmath
βœ… ctype        βœ… intl         βœ… sodium

πŸ›‘οΈ Security

⚠️ This file provides command-line access to your server. Handle with care.

Best practices:

  • βœ… Use a strong unique password
  • βœ… Delete the file after deployment is done
  • βœ… Move to a hidden path (e.g. /private/tools/)
  • βœ… Restrict by IP via .htaccess:
<Files "terminal.php">
  Order Deny,Allow
  Deny from all
  Allow from YOUR.IP.ADDRESS
</Files>
  • ❌ Never expose on production long-term
  • ❌ Never commit with password in plain text

πŸ“‚ Project Structure

php-web-terminal/
β”œβ”€β”€ terminal.php     # Single-file web terminal (AJAX-based)
β”œβ”€β”€ term.log         # Command history log (auto-created, gitignored)
└── README.md

🌐 Tested On

Hosting PHP Status
Indonesian Shared Hosting (cPanel) 8.2 βœ… Working
CloudLinux + cPanel 8.2 βœ… Working

πŸ“„ License

MIT License β€” Free to use, modify, and distribute.


⭐ Support

If this helped you, give it a ⭐ on GitHub!

About

A lightweight PHP-based web terminal for shared hosting without SSH access. Supports command execution, unlimited history, cd navigation, and password protection.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages