> uploadtext_

v1.0.0 - Secure text sharing node

Install LEMP on Ubuntu bash script

Owner: keenlex Created: 2026-05-02 16:35:44 Size: 2.39 KB Expires: Never
[ RAW ] [ NEW ]
tty1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Ensure the script is run as root
if [ "$EUID" -ne 0 ]; then
  echo "Error: Please run this script as root (using sudo)."
  exit 1
fi

echo "========================================="
echo " Starting Expanded LEMP Installation...  "
echo "========================================="

# 1. Update the package lists
echo "--> Updating package repository cache..."
apt-get update -y

# 2. Install Nginx and Nginx-extras
echo "--> Installing Nginx and nginx-extras..."
apt-get install -y nginx nginx-extras

# 3. Install MariaDB (Server and Client)
echo "--> Installing MariaDB..."
apt-get install -y mariadb-server mariadb-client

# 4. Install PHP-FPM, PHP Common, and a comprehensive suite of PHP extensions
echo "--> Installing PHP-FPM and PHP extensions..."
apt-get install -y \
    php-fpm \
    php-common \
    php-cli \
    php-mysql \
    php-xml \
    php-mbstring \
    php-intl \
    php-curl \
    php-gd \
    php-zip \
    php-bcmath

# 5. Ensure services are enabled to start on boot and are currently running
echo "--> Enabling and starting services..."

systemctl enable nginx
systemctl start nginx

systemctl enable mariadb
systemctl start mariadb

# Ubuntu's apt automatically starts the specific PHP-FPM version (e.g., php8.1-fpm or php8.3-fpm).
# We can dynamically find the installed PHP-FPM service name and ensure it's enabled.
PHP_FPM_SERVICE=$(systemctl list-unit-files | grep -o 'php.*-fpm.service' | head -n 1)
if [ -n "$PHP_FPM_SERVICE" ]; then
    systemctl enable "$PHP_FPM_SERVICE"
    systemctl start "$PHP_FPM_SERVICE"
    echo "--> $PHP_FPM_SERVICE is enabled and running."
else
    echo "--> Warning: Could not automatically detect the PHP-FPM service name, but it should be running."
fi

echo "========================================="
echo " Installation completed successfully! :D "
echo "========================================="

# Print basic status
echo ""
echo "--> Installed Versions:"
echo "Nginx:   $(nginx -v 2>&1)"
echo "MariaDB: $(mysql -V)"
echo "PHP:     $(php -v | head -n 1)"

# Show loaded PHP modules
echo ""
echo "--> Loaded PHP Modules (Snippet):"
php -m | grep -E 'xml|PDO|intl|mbstring|curl|gd|zip'

# Secure installation reminder
echo ""
echo "Note: Run 'sudo mysql_secure_installation' next to secure your MariaDB database!"