root@server:~# LEMP-PRO-INSTALLER
LEMP PRO INSTALLER
Modern one-click installer for Nginx + PHP-FPM + MariaDB stack.
Supports WordPress, empty PHP site or just LEMP, optional SSL, phpMyAdmin and Telegram notification.
Script Features
- Interactive menu (CMS / domain / SSL / phpMyAdmin / Telegram)
- Supported CMS options:
- WordPress — auto download + wp-config.php generation
- Empty PHP site — creates index.php with phpinfo()
- LEMP only — no web files
- Automatic creation of secure random database + user for WordPress
- Optional phpMyAdmin installation + dedicated restricted user
- Let’s Encrypt SSL support via certbot (nginx plugin)
- Telegram notification on successful installation (with credentials)
- Installation report saved as TXT + JSON history log
- Colorful console UI with status icons
- Fixed PHP 8.3 (can be easily changed in script header)
How to Use
- Log in to your Ubuntu/Debian server as root (or use sudo)
- Download and run the script with one of these commands:
# Variant 1 – most convenient
The easiest way to execute the code is via bash. Further down the page, you will see a line to copy.
# Variant 2 – classic way
Copy the script code from their form below. The copy button is in the right corner. Don't forget to make the file executable.
chmod +x lamp_wp.sh
./lamp_wp.sh
Important Notes
Run only on clean / fresh server!
Script overwrites /var/www/html completely when installing WordPress or empty site.
Uses default nginx site (/etc/nginx/sites-available/default)
- Recommended OS: Ubuntu 22.04 / 24.04 or Debian 11/12
- Requires internet access and open ports 80 + 443 (for SSL)
- phpMyAdmin will be available at
http(s)://your-domain-or-ip/phpmyadmin - Telegram notification is optional — safe even if token/chat-id is wrong
- All passwords are randomly generated (openssl rand -hex)
Install LEMP PRO with one command
Copy the command below and paste it into your server console (as root or with sudo)
bash -c "$(curl -fsSL https://YOUR-DOMAIN.com/linuxScripts/lamp_wp.sh)"
After pasting, press Enter and follow the on-screen prompts
#!/usr/bin/env bash
set -euo pipefail
# ===================== COLORS =====================
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
BOLD='\033[1m'
NC='\033[0m'
# ===================== DEFAULTS =====================
WEB_ROOT="/var/www/html"
PHP_VERSION="8.3"
PORT=80
CMS=""
DOMAIN=""
INSTALL_SSL=false
INSTALL_PMA=false
DO_UPGRADE=false
SEND_TG=false
TELEGRAM_TOKEN=""
TELEGRAM_CHAT_ID=""
LOG_JSON="/root/lemp_installs.json"
# ===================== UI FUNCTIONS =====================
banner() {
echo -e "${CYAN}${BOLD}"
echo "╔══════════════════════════════════════════════════╗"
echo "║ LEMP INSTALLER ║"
echo "║ ║"
echo "╚══════════════════════════════════════════════════╝"
echo -e "${NC}"
}
ask_yes_no() {
read -rp "$1 [y/n]: " ans
[[ "$ans" =~ ^[Yy]$ ]]
}
step() { echo -e "${CYAN}➜${NC} $1"; }
ok() { echo -e "${GREEN}✓${NC} $1"; }
warn() { echo -e "${YELLOW}⚠${NC} $1"; }
fail() { echo -e "${RED}✗ $1${NC}"; exit 1; }
# ===================== TELEGRAM =====================
send_telegram() {
[[ "$SEND_TG" = false ]] && return
if [[ -z "$TELEGRAM_TOKEN" || -z "$TELEGRAM_CHAT_ID" ]]; then
warn "Telegram token or chat_id is empty. Skipping notification."
return
fi
MESSAGE="<b>🚀 LEMP INSTALL COMPLETED</b>%0A%0A"
MESSAGE+="🌍 <b>URL:</b> $(echo "$URL" | sed 's/&/%26/g;s/</%3C/g;s/>/%3E/g')%0A"
MESSAGE+="🧩 <b>CMS:</b> $(echo "$CMS" | sed 's/&/%26/g;s/</%3C/g;s/>/%3E/g')%0A"
MESSAGE+="🐘 <b>PHP:</b> $PHP_VERSION%0A%0A"
if [[ -n "$DB_NAME" ]]; then
MESSAGE+="<b>🗄 Database</b>%0A"
MESSAGE+="Name: <code>$(echo "$DB_NAME" | sed 's/&/%26/g;s/</%3C/g;s/>/%3E/g')</code>%0A"
MESSAGE+="User: <code>$(echo "$DB_USER" | sed 's/&/%26/g;s/</%3C/g;s/>/%3E/g')</code>%0A"
MESSAGE+="Pass: <code>$(echo "$DB_PASS" | sed 's/&/%26/g;s/</%3C/g;s/>/%3E/g')</code>%0A%0A"
fi
if [[ "$INSTALL_PMA" = true ]]; then
MESSAGE+="🛠 <b>phpMyAdmin</b>%0A"
MESSAGE+="User: <code>$PMA_USER</code>%0A"
MESSAGE+="Pass: <code>$PMA_PASS</code>%0A"
MESSAGE+="$URL/phpmyadmin%0A"
fi
RESPONSE=$(curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d text="$MESSAGE" \
-d parse_mode="HTML")
if [[ $RESPONSE == *'"ok":true'* ]]; then
ok "Telegram notification sent successfully"
else
warn "Telegram message failed: $RESPONSE"
fi
}
# ===================== SAVE REPORT =====================
save_report() {
TIMESTAMP=$(date "+%Y-%m-%d_%H-%M-%S")
REPORT_FILE="/root/install_${TIMESTAMP}.txt"
IP=$(hostname -I | awk '{print $1}')
cat > "$REPORT_FILE" <<EOF
════════ LEMP INSTALL REPORT ════════
Date: $(date)
Server IP: $IP
Domain: ${DOMAIN:-None}
CMS: $CMS
PHP: $PHP_VERSION
URL: $URL
Database:
Name: ${DB_NAME:-None}
User: ${DB_USER:-None}
Pass: ${DB_PASS:-None}
phpMyAdmin:
URL: ${URL}/phpmyadmin
User: ${PMA_USER:-None}
Pass: ${PMA_PASS:-None}
══════════════════════════════════════
EOF
ok "Report saved: $REPORT_FILE"
# JSON history
command -v jq >/dev/null 2>&1 || apt install -y jq >/dev/null 2>&1
[[ -f "$LOG_JSON" ]] || echo "[]" > "$LOG_JSON"
jq -n \
--arg date "$(date)" \
--arg ip "$IP" \
--arg domain "$DOMAIN" \
--arg cms "$CMS" \
--arg php "$PHP_VERSION" \
--arg url "$URL" \
--arg db "$DB_NAME" \
--arg user "$DB_USER" \
--arg pass "$DB_PASS" \
--arg pma_user "${PMA_USER:-}" \
--arg pma_pass "${PMA_PASS:-}" \
'$ARGS.named' | jq -s '.[0] + .' "$LOG_JSON" > /tmp/tmp.json
mv /tmp/tmp.json "$LOG_JSON"
}
# ===================== START =====================
[[ $EUID -eq 0 ]] || fail "Run as root"
banner
# Upgrade
if ask_yes_no "Run full system upgrade?"; then
DO_UPGRADE=true
apt update -y && apt upgrade -y
ok "System upgraded"
fi
# CMS
echo
echo -e "${PURPLE}Select CMS:${NC}"
echo "1) WordPress"
echo "2) Empty PHP site"
echo "3) LEMP only"
read -rp "Choice: " choice
case "$choice" in
1) CMS="WordPress" ;;
2) CMS="Empty" ;;
3) CMS="None" ;;
*) CMS="WordPress" ;;
esac
# Domain
if ask_yes_no "Configure domain?"; then
read -rp "Domain name: " DOMAIN
read -rp "Port [80]: " p
PORT="${p:-80}"
ask_yes_no "Install SSL?" && INSTALL_SSL=true
fi
ask_yes_no "Install phpMyAdmin?" && INSTALL_PMA=true
# Telegram
if ask_yes_no "Enable Telegram notifications?"; then
SEND_TG=true
read -rp "Bot token: " TELEGRAM_TOKEN
read -rp "Chat ID: " TELEGRAM_CHAT_ID
fi
# ===================== INSTALL =====================
step "Installing packages..."
apt install -y software-properties-common
add-apt-repository -y ppa:ondrej/php >/dev/null 2>&1
apt update -y
apt install -y nginx mariadb-server \
php${PHP_VERSION}-fpm \
php${PHP_VERSION}-{cli,mysql,curl,gd,mbstring,xml,zip,intl,opcache} \
wget curl unzip
systemctl enable --now nginx mariadb php${PHP_VERSION}-fpm
ok "Core packages installed"
# ===================== DATABASE =====================
if [[ "$CMS" = "WordPress" ]]; then
DB_NAME="wp_$(openssl rand -hex 4)"
DB_USER="${DB_NAME}_u"
DB_PASS="P$(openssl rand -hex 8)"
mysql <<EOF
CREATE DATABASE \`${DB_NAME}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';
GRANT ALL PRIVILEGES ON \`${DB_NAME}\`.* TO '${DB_USER}'@'localhost';
FLUSH PRIVILEGES;
EOF
ok "WordPress database created"
fi
# ===================== PHPMYADMIN USER =====================
if [[ "$INSTALL_PMA" = true ]]; then
PMA_USER="pmauser"
PMA_PASS="$(openssl rand -hex 8)"
mysql <<EOF
CREATE USER '${PMA_USER}'@'localhost' IDENTIFIED BY '${PMA_PASS}';
GRANT ALL PRIVILEGES ON *.* TO '${PMA_USER}'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
ok "phpMyAdmin user created: $PMA_USER / $PMA_PASS"
fi
# ===================== CMS INSTALL =====================
if [[ "$CMS" = "WordPress" ]]; then
step "Installing WordPress..."
cd /tmp
wget -q https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
rm -rf "${WEB_ROOT:?}"/*
cp -r wordpress/. "$WEB_ROOT"/
cp "$WEB_ROOT/wp-config-sample.php" "$WEB_ROOT/wp-config.php"
sed -i "s/database_name_here/${DB_NAME}/" "$WEB_ROOT/wp-config.php"
sed -i "s/username_here/${DB_USER}/" "$WEB_ROOT/wp-config.php"
sed -i "s/password_here/${DB_PASS}/" "$WEB_ROOT/wp-config.php"
ok "WordPress installed"
fi
if [[ "$CMS" = "Empty" ]]; then
echo "<?php phpinfo(); ?>" > "$WEB_ROOT/index.php"
ok "Empty PHP site created"
fi
chown -R www-data:www-data "$WEB_ROOT"
# ===================== NGINX =====================
PHP_SOCKET="/run/php/php${PHP_VERSION}-fpm.sock"
SERVER_NAME="${DOMAIN:-_}"
cat > /etc/nginx/sites-available/default <<EOF
server {
listen $PORT;
server_name $SERVER_NAME;
root $WEB_ROOT;
index index.php index.html;
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
location ~ \.php\$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:$PHP_SOCKET;
}
}
EOF
nginx -t && systemctl reload nginx
ok "Nginx configured"
# ===================== PHPMyAdmin =====================
if [[ "$INSTALL_PMA" = true ]]; then
apt install -y phpmyadmin
ln -s /usr/share/phpmyadmin $WEB_ROOT/phpmyadmin
ok "phpMyAdmin installed"
fi
# ===================== SSL =====================
if [[ "$INSTALL_SSL" = true && -n "$DOMAIN" ]]; then
apt install -y certbot python3-certbot-nginx
certbot --nginx -d $DOMAIN --non-interactive --agree-tos -m admin@$DOMAIN --redirect
ok "SSL installed"
fi
# ===================== FINAL =====================
IP=$(hostname -I | awk '{print $1}')
PROTOCOL=$([[ "$INSTALL_SSL" = true ]] && echo "https" || echo "http")
URL="${PROTOCOL}://${DOMAIN:-$IP}:${PORT}"
echo
echo -e "${GREEN}${BOLD}════════ INSTALL COMPLETE ════════${NC}"
echo -e "🌍 URL: ${CYAN}$URL${NC}"
echo -e "🧩 CMS: $CMS"
echo -e "🐘 PHP: $PHP_VERSION"
[[ -n "${DB_NAME:-}" ]] && echo -e "🗄 DB: ${YELLOW}$DB_NAME${NC}"
[[ -n "${DB_USER:-}" ]] && echo -e "👤 DB User: ${YELLOW}$DB_USER${NC}"
[[ -n "${DB_PASS:-}" ]] && echo -e "🔑 DB Pass: ${RED}$DB_PASS${NC}"
if [[ "$INSTALL_PMA" = true ]]; then
echo -e "🛠 phpMyAdmin URL: $URL/phpmyadmin"
echo -e "👤 PMA User: ${YELLOW}$PMA_USER${NC}"
echo -e "🔑 PMA Pass: ${RED}$PMA_PASS${NC}"
fi
echo
save_report
send_telegram
ok "Installation finished successfully!"