A robust, cross-platform bash script that automatically detects your Linux distribution and installs a complete LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack with comprehensive error handling and logging.
Deploy this script effortlessly on your MyHBD.net server with just a single click!
β
High-performance VPS solutions
β
Multiple data centers across Europe & Asia
β
Reliable and optimized for seamless deployment
Start now and streamline your server setup with ease!
- Cross-Platform Support: Works on Ubuntu, Debian, CentOS, RHEL, Fedora, Rocky Linux, AlmaLinux
- Intelligent OS Detection: Automatically detects your Linux distribution and uses appropriate package managers
- Comprehensive Error Handling: Retry mechanism for failed installations with detailed logging
- Security Configuration: Automatically secures MySQL/MariaDB installation
- Firewall Management: Automatically opens necessary ports (80, 443)
- Verification Testing: Creates test files to verify PHP and database connectivity
- Detailed Logging: Complete installation log saved to
/LAMPinstallLOGS.text
- System Information Collection: Gathers system specs and configuration details
- Linux-based operating system (Ubuntu, Debian, CentOS, RHEL, Fedora, Rocky, AlmaLinux)
- Root or sudo access
- Internet connection for package downloads
# Download and run the script directly
curl -sSL https://raw.githubusercontent.com/itsredbull/lamp-auto-installer/main/install-lamp.sh | sudo bash
# Download the script
wget https://raw.githubusercontent.com/itsredbull/lamp-auto-installer/main/install-lamp.sh
# Make it executable
chmod +x install-lamp.sh
# Run the script as root
sudo ./install-lamp.sh
- Copy the script content from
install-lamp.sh
- Save it to a file on your server (e.g.,
install-lamp.sh
) - Make it executable:
chmod +x install-lamp.sh
- Run as root:
sudo ./install-lamp.sh
Component | Description | Default Version |
---|---|---|
Apache | Web server (apache2/httpd) | Latest available |
MySQL/MariaDB | Database server | Latest available |
PHP | Server-side scripting | Latest available |
PHP Modules | Essential PHP extensions | mysql, cli, common, json, opcache, mbstring, xml, gd, curl |
After installation, the script creates test files to verify your LAMP stack:
- PHP Info:
http://your-server-ip/info.php
- Database Test:
http://your-server-ip/db-test.php
β οΈ Security Note: Remove these test files after verification for security reasons.
-
Change MySQL Root Password:
mysql -u root -p # Current password: temp_password ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_secure_password';
-
Remove Test Files:
sudo rm /var/www/html/info.php /var/www/html/db-test.php
-
Configure Virtual Hosts (if needed)
-
Set up SSL/TLS certificates
-
Configure backups
The script generates comprehensive logs at /LAMPinstallLOGS.text
including:
- Installation progress and errors
- System information
- Service status
- Network configuration
- Firewall settings
Script fails with permission denied
chmod +x install-lamp.sh
sudo ./install-lamp.sh
Package installation fails
- Check internet connection
- Verify repository configuration
- Review logs in
/LAMPinstallLOGS.text
Services not starting
# Check service status
sudo systemctl status apache2 # or httpd
sudo systemctl status mysql # or mariadb
# Check logs
sudo journalctl -u apache2 -f
sudo journalctl -u mysql -f
Firewall blocking connections
# For UFW (Ubuntu/Debian)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# For firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
For specific PHP versions, modify the script or install manually:
# Ubuntu/Debian - PHP 8.1
sudo apt install php8.1 libapache2-mod-php8.1
# CentOS/RHEL - Enable specific module
sudo dnf module enable php:8.1
sudo dnf install php php-mysqlnd
The script installs the default PHP version. For multiple versions, use tools like update-alternatives
or configure Apache virtual hosts.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow bash best practices
- Add appropriate error handling
- Update documentation
- Test on multiple distributions
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors who have helped improve this script
- Inspired by the need for a universal LAMP installer across different Linux distributions
If you encounter any issues or have questions:
- Check the troubleshooting section
- Review the installation logs at
/LAMPinstallLOGS.text
- Open an issue on GitHub
- Check existing issues for similar problems
OS | Version | Status | Notes |
---|---|---|---|
Ubuntu | 18.04+ | β | Fully supported |
Debian | 9+ | β | Fully supported |
CentOS | 7+ | β | Fully supported |
RHEL | 7+ | β | Fully supported |
Fedora | 30+ | β | Fully supported |
Rocky Linux | 8+ | β | Fully supported |
AlmaLinux | 8+ | β | Fully supported |
Made with β€οΈ for the Linux community