Skip to content

Instantly share code, notes, and snippets.

@Udara-Dananjaya
Created August 15, 2023 07:01
Show Gist options
  • Save Udara-Dananjaya/8f7d90ee64c32d28b3ab7b24f6f07235 to your computer and use it in GitHub Desktop.
Save Udara-Dananjaya/8f7d90ee64c32d28b3ab7b24f6f07235 to your computer and use it in GitHub Desktop.
Install Virtualmin on Ubuntu: Setup swap, firewall, hostname & Virtualmin with comprehensive port configurations. Simplify web hosting!
# Gain superuser privileges
sudo -i
# Create swap area for managing memory
sudo dd if=/dev/zero bs=1M count=5024 of=/mnt/swapfile.swap
sudo chmod 600 /mnt/swapfile.swap
sudo mkswap /mnt/swapfile.swap
sudo swapon /mnt/swapfile.swap
echo '/mnt/swapfile.swap swap swap defaults 0 0' | sudo tee -a /etc/fstab
# Check available RAM and disk space
free -m
df -h
# Define firewall rules for specified ports and sources
# Subnet > Ingress Rule > Source CIDR > 0.0.0.0/0
# TCP PORTS :22,80,443,10000,20-21,25,53,110,143,993,465,587,20000,10001-10009
# UDP PORTS :53
# Update the list of available software packages
sudo apt update -y
# Upgrade installed packages to their latest versions
sudo apt-get upgrade -y
sudo apt-get full-upgrade -y
# Clear existing iptables rules
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
# Set hostname
hostnamectl set-hostname hostname.domain
hostname
# Install Virtualmin
wget http://software.virtualmin.com/gpl/scripts/install.sh && sudo /bin/sh install.sh
# Set password
sudo -i passwd
# Set the root password
# Access Virtualmin web interface
# Open the browser and go to: https://hostname.domain:10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment