lampctl

LAMP Control Panel

A powerful bash-based control panel for managing LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) and virtual hosts on Ubuntu systems.

Features

Prerequisites

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/lamp-control-panel.git
    cd lamp-control-panel
    
  2. Make the script executable:
    chmod +x lampctl.sh
    
  3. Optional: Create a symlink for system-wide access:
    sudo ln -s $(pwd)/lampctl.sh /usr/local/bin/lampctl
    

Usage

./lampctl.sh

This launches an interactive menu where you can choose from all available options.

Command Line Mode (For automation/scripts)

# Apache Controls
./lampctl.sh start      # Start Apache
./lampctl.sh stop       # Stop Apache  
./lampctl.sh restart    # Restart Apache

# Database Controls
./lampctl.sh startdb    # Start MySQL/MariaDB
./lampctl.sh stopdb     # Stop MySQL/MariaDB
./lampctl.sh restartdb  # Restart MySQL/MariaDB

# Virtual Host Management
./lampctl.sh add        # Add new virtual host
./lampctl.sh list       # List all virtual hosts
./lampctl.sh remove     # Remove virtual host

Virtual Host Management

Adding a Virtual Host

When you choose β€œAdd Virtual Host” (option 7), the script will:

  1. Ask for your project path (relative to /var/www/html)
  2. Automatically detect project type:
    • Laravel/Composer: Uses public/ as document root
    • WordPress/PHP: Uses project root as document root
  3. Ask for your domain name (e.g., myapp.test)
  4. Create Apache configuration file
  5. Enable the site
  6. Add entry to /etc/hosts
  7. Optionally reload Apache

Example Workflow

Project path: my-laravel-app
Domain: myapp.test

This creates:

Project Structure

The script organizes projects under /var/www/html/ by default:

/var/www/html/
β”œβ”€β”€ project1/
β”‚   └── public/     # Laravel projects auto-detected
β”œβ”€β”€ project2/
β”‚   └── index.php   # Standard PHP projects
└── wordpress/
    └── wp-config.php  # WordPress detected

File Locations

Configuration

You can modify these variables at the top of the script:

APACHE_SITES_AVAILABLE="/etc/apache2/sites-available"
APACHE_SITES_ENABLED="/etc/apache2/sites-enabled"
HOSTS_FILE="/etc/hosts"
PROJECTS_BASE="/var/www/html"

Safety Features

Troubleshooting

Common Issues

  1. Permission Denied
    • Ensure the script is executable: chmod +x lampctl.sh
    • Run with sudo when needed (script auto-prompts)
  2. Apache not starting
    • Check syntax: sudo apache2ctl configtest
    • Verify Apache is installed: sudo systemctl status apache2
  3. Virtual host not working
    • Check if site is enabled: sudo a2ensite your-domain.conf
    • Verify hosts entry: cat /etc/hosts
    • Reload Apache: sudo systemctl reload apache2

Debug Mode

Add set -x at the top of the script for detailed debugging output.

License

MIT License - Copyright (c) 2025 Attila

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Support

If you encounter any issues:

  1. Check the troubleshooting section above
  2. Ensure all prerequisites are met
  3. Check Apache error logs: sudo tail -f /var/log/apache2/error.log

Note: This script is designed for development environments. Use caution in production environments and always test configurations thoroughly.