1. Introduction
When hosting multiple websites on a Raspberry Pi you need to setup so called virtual servers as the web server needs to forward used URL’s to the correct folder of the website. This can be done via manual configuration, but it handier to Install Virtualmin on a Raspberry Pi (a virtual hosting platform) as it is a web based interface preventing the use of Unix commands.
Virtualmin is a powerful and flexible web hosting control panel for Linux and BSD systems available as open-source version and a commercial version having more features.
This article describes how to install Virtualmin on a Raspberry Pi, which will also install Webmin. Installation and configuration instructions will be provided. Additional documentation can by found on the website of Virtualmin.
2. Requirements
For hosting multiple websites the following is required before we start to install Virtualmin on a Raspberry Pi:
- Working Raspberry Pi with at least 1GB RAM and 1GB free disk space
In our case a Raspberry Pi 5 model B with 8 Gb RAM and a 500 Gb Samsung sata SSD in a Geekworm NASPi 2.0 case as development/testserver and a Raspberry Pi 5 with 16Gb RAM and a 500Gb NVMe SSD as operational server. - Internet connection (with reasonable up- and download speeds (in our case we have 250 Mbp).
- Access to your router to setup port forwarding
- Preferably domain name for your server
3. Preparation
Before we install Virtualmin on a Raspberry Pi we need to make sure:
-
Hostname is a proper Fully Qualified Domain Name (FQDN)
1234# Check current hostname & debian versionhostnamectl# Set hostname if requiredsudo hostnamectl set-hostname server.example.comUpdate the hosts file:
1sudo nano /etc/hostsAssure it has entry looking like:
1127.0.0.1 server.example.comAnd check via:
1hostnamectlPrevent it gets overwritten after a reboot:
1sudo nano /etc/cloud/cloud.cfgFind ‘preserve_hostname: false’ and change into true. Reboot and test again the hostname of your server:
1sudo reboot - Assure system is up to date:
12sudo apt updatesudo apt full-upgrade -y
- Remove conflicting packages as the Virtualmin installer wants a clean system:
12sudo apt remove --purge webmin usermin apache2 nginx mysql-server mariadb-server postfix dovecot* -ysudo apt autoremove -y
- Check swap file size as SpamAssassin + ClamAV can spike RAM usage. Even with 8 or 16 GB RAM, Virtualmin works best with 2-4 GB swap. Check current settings:
1swapon --show
If none or not 4GB:
1234sudo fallocate -l 4G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfileAdd swapfile to fstab. Open the file for editing:
1sudo nano /etc/fstaband add:
1/swapfile none swap sw 0 0Save the file and close the editor. Reboot the system to check all goes fine:
1sudo reboot -
the NVMe SSD(s) are configured; in our case 512Gb SSD as bootdrive and a 4TB SSD as datadrive. Also move the home folder to the second SSD.
Note: skip this part if only one SSD!Create the proper mount point. As /home already exists, create a temporary mount point first:
1sudo mkdir /mnt/newhomeMount the 2nd SSD:
1sudo mount /dev/nvme1n1p1 /mnt/newhomeCopy existing /home data as even on fresh systems there may be default files. Use rsync to preserve permissions:
1sudo rsync -av /home/ /mnt/newhome/Mount NVMe permanently as /home by adding it to fstab. Open the editor with fstab:
1sudo nano /etc/fstabAdd (we use the UUID of the SSD as the safest option):
1UUID=YOUR-UUID-HERE /home ext4 defaults,noatime,nofail 0 2note; the UUID can be found via:
1blkid /dev/nvme1n1p1Check before reboot everything is fine:
1234sudo mount -amount | grep ' /home 'df -h /homels /homeIf sudo mount -a prints nothing and /home shows the expected contents, you’re good. Additional check:
1df -hIt should for show something like: nvme1n1p1 3.7T /home
Reboot the system:
1sudo rebootCheck again with df -h.
The old /home data files still exist under the root filesystem but hidden by the mount. You can later remove them safely by booting into rescue or by temporarily mounting root elsewhere — but on a fresh system this it is usually negligible.
Final note: Mounting a separate disk at /home is fine, but only if the second disk has the home directory and is mounted without issues. If not, users will appear to have “lost” their files / websites will fail.
-
DNS for the hostname points at the server; we use our hosting provider DNS server to point to our home public IP address. Assure the required tools are installed:
1sudo apt install dnsutils -yRun the following commands and check your public IP address is linked to your domain name:
12hostname -fhost $(hostname -f) - Tune the filesystem and some Linux kernel settings before installing Virtualmin. By doing so the server handles large numbers of small files and heavy PHP/WordPress traffic efficiently. On a 4 TB NVMe dedicated to /home, these tweaks improve metadata performance and reduce unnecessary writes.Increase filesystem watch limits (important for many sites) as hosting servers often hit Linux’s default file-watch limits. Create a sysctl config:
1sudo nano /etc/sysctl.d/99-virtualmin.conf
Add:
123fs.file-max = 2097152fs.inotify.max_user_watches = 524288fs.inotify.max_user_instances = 1024Save and close the editor. Apply via:
1sudo sysctl --systemIncrease open file limits to prevent problems when many domains or logs are open simultaneously. Open limits.conf:
1sudo nano /etc/security/limits.confAdd:
12* soft nofile 1048576* hard nofile 1048576Save and close the editor.
- Optional, but recommended; add better directory hashing, which dramatically improves performance when directories contain thousands of files (common in hosting).For NVME SSD
Check by:1sudo tune2fs -l /dev/nvme1n1p1 | grep featuresYou want to see ‘dir_index’. If it is missing use:
12sudo tune2fs -O dir_index /dev/nvme1n1p1sudo e2fsck -f /dev/nvme1n1p1For SATA SSD
Be it only works on ext4 type partition, so not on the vfat type boot partition (sda1), but on the second psartition (sda2). Check by:1sudo tune2fs -l /dev/sda2 | grep featuresYou want to see ‘dir_index’. If it is missing use:
12sudo tune2fs -O dir_index /dev/sda2sudo e2fsck -f /dev/sda2
- Optional; reduce number of reserved blocks on SSD. Default is 5% being reserved which for a 4TB SSD wastes about 200GB of space. This can be reduyced to 1% which frees up 160-180GB:
For NVME SSD1sudo tune2fs -m 1 /dev/nvme1n1p1For SATA SSD
1sudo tune2fs -m 1 /dev/sda2 - Disable unnecessary services. Check enabled services via:
1systemctl list-unit-files --state=enabled
Things safe to disable for servers if present:
– bluetooth
– avahi-daemon
– triggerhappy
– ModemManager
Stop the services:1234sudo systemctl stop bluetoothsudo systemctl stop ModemManagersudo systemctl disable avahi-daemon.socketsudo systemctl stop avahi-daemon.service avahi-daemon.socketTo disable these:
1234sudo systemctl disable bluetoothsudo systemctl disable avahi-daemonsudo systemctl disable triggerhappysudo systemctl disable ModemManagerCheck with:
1systemctl is-enabled bluetooth avahi-daemon avahi-daemon.socket ModemManager - Install minimal required utilities:
1sudo apt install curl wget sudo gnupg2 ca-certificates -y
-
Make sure ports 80, 443, and 10000 are pointing to your server. These ports need to be forwarded to your server. Virtualmin notes it may automatically request a real cert for the hostname during install if resolution and ports are correct. Optional:
– 25 → mail
– 587 → mail submission
– 993 → IMAP - Reboot the server
1sudo reboot
4. Installation
Follow the next steps to install Virtualmin on a Raspberry Pi (based on the Automated Virtualmin Installation):
- Via Raspberry Pi connect open a remote shell (terminal).
- Download and start the installation script:
1sudo sh -c "$(curl -fsSL https://download.virtualmin.com/virtualmin-install)" -- --bundle LAMP
The installation script will display info and ask if ok to continue. Confirm.
- The installer will first perform some checks and then start the installation.
Wait till installation has finished. This can take a while. The progress will be show and if finished it will indicate how the installation went. In our case the firewalld / fail2ban has not been installed, but that won’t be an issue as we will install a firewall later.
- You can now login into Virtualmin via https://server.example.com:10000. Or via the servers internal network IP address like https://192.168.1.22:10000.
- Log in as the Raspberry Pi default/root user, or any user with sudo ALL access.
5. Initial configuration via the Post-installation Wizard
When logged in into Virtualmin the Post-Installation wizard will be shown in Virtualmin.
Click on the next button to start answering a series of setup questions.
- Mail performance: slower mail processing as we will not use the RPi as mailserve
- Enable virus scanning for receiving emails; disable as we will not setup receive large amounts of mail, we will mainly sent notifications out.
- Spam filtering (if shown): set to no.
- Database servers; leave at default.
-
MariaDB password; keep or change the default password. At least make sure you remember!
- DNS Configuration; we won’t use the internal DNS server, but the one from the hosting provider.
- Set email address for notifications from Webmin/Virtualmin:
- All done.
Click on Finish. - Click on “Re-check and refresh configuration”.
- A status overview will displayed.
If no warnings/errors are displayed the configuration is finished.
- Reboot the system and check everything is working fine.
- Disable DNS feature globally in Virtualmin for new servers:
1sudo virtualmin set-global-feature --default-off dns
And for existing ones use:
123for d in $(sudo virtualmin list-domains --name-only); dosudo virtualmin disable-feature --domain "$d" --dnsdone
Now the install is finished you will see that the Virtualmin dashboard contains a Webmin tab and a Virtualmin tab in the left-hand menu. We can switch between the Webmin menu and Virtualmin menu. What is the difference?
- Webmin provides general purpose systems management features, such as user/group management, listing processes, managing installed packages, network settings, and firewall settings.
- Virtualmin provides access to domain accounts management functionality, including creating new domain accounts, new databases associated with those accounts, and installing applications.
6. Install latest PHP version
The default installed PHP version during our installation of Virtualmin was PHP version 8.4.16. The recommended version currently is version 8.4. Virtualmin makes it possible to install multiple PHP versions and allows you to choose execution mode and PHP version used for a given virtual web server. We focus on v8.4 with execution mode php-fpm.
- Install the latest version and common extensions:
1234567sudo apt install \php8.4 php8.4-fpm php8.4-cli php8.4-common \php8.4-mysql php8.4-pgsql php8.4-sqlite3 \php8.4-gd php8.4-imagick \php8.4-curl php8.4-zip php8.4-bcmath \php8.4-mbstring php8.4-intl php8.4-xml \php8.4-soap php8.4-opcache php8.4-readline - Restart PHP and apache server
12sudo systemctl restart php8.4-fpmsudo systemctl restart apache2 - Configure Virtualmin to use PHP-FPM as default execution mode. Go to System Settings > Server Templates and edit each of the templates PHP Options (see section dropdown for eacht template). Assure the indicated setttings are made:
7. Finally
This concludes this article “Install Virtualmin on a Raspberry Pi”.















0 Comments