Virtualmin hosting on Debian 10 Buster

With the come of spring, new OS versions and more knowledge about Linux, I think time has come to make another tutorial about how to setup a small hosting server, mainly for personal usage.

Virtualmin has been the best open source solution for a hosting panel. I have tried many before and in my opinion it’s even better than cPanel – compared as a solution for simpler needs.

I have previously used ubuntu as a server solution and it completed the job in an honorable manner. Together with a new LTS release and the abundance of tutorials, it still makes one of the best choices out there. In fact, it is so good that mainly curiosity pushed me towards trying debian, especially since they are quite similar in the end.

Prerequisites and conventions

I will be using a digitalocean vps with Debian 10. I will be doing most of what digitalocean recommends for setting up a new debian server:

We will asume the following:

  • the sudo user will be sudouser;
  • the address of the server is

Initial server setup

As a starting point, I will use an older article related to how to setup a virtualmin hosting server:

A sudo user

  • adduser sudouser
  • usermod -aG sudo sudouser
  • passwd -l root
  • su - sudouser

Setup the locales

  • sudo nano /etc/default/locale 
  • add the following, should you want en_US.UTF-8:
  • sudo locale-gen

Enable swap

Simplified its role, the swap space uses disk memory as RAM when there is no more RAM available on your system. There is much to talk about on the subject. For getting started, we can conclude the it is generally useful and we can use the following commands to enable it:

  • sudo swapon --show
  • sudo fallocate -l 4G /swapfile – creates a 4GB swap file
  • ls -lh /swapfile
  • sudo chmod 600 /swapfile
  • ls -lh /swapfile
  • sudo mkswap /swapfile
  • sudo swapon /swapfile
  • sudo swapon --show
  • sudo nano /etc/fstab and append: /swapfile none swap sw 0 0

More about swap and swappiness:

Changing the swap size

After setting the swap for my system in the way described above, I this error: Not enough swap space for hibernation. So, the following series of commands helped:

  • sudo swapoff -a – turn off all swap
  • sudo rm /swapfile – this step is if you want to delete the current file
  • sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 – makes a 8GB file
  • sudo chmod 600 /swapfile – set permission to root only if you made a new file
  • sudo mkswap /swapfile – converts file to swap format
  • sudo swapon /swapfile – enable swap on the file.



  • sudo apt-get update && sudo apt-get upgrade -y
  • sudo apt install git


  • sudo apt-get update && sudo apt-get upgrade -y
  • sudo apt-get install sqlite3 libsqlite3-dev -y


I like nice things. This is why I still prefer MacOS to Linux, though UbuntuDDE seems like a very-very interesting project.

Of course, there are some other shells out there which people say are better. But I am of those guys who often stick to a solution they now works. And if curiosity “enforces” change, then I will try to change one thing at a time. I am now changing the operating system, but I am keeping the shell.

  • sudo apt-get update && sudo apt-get upgrade -y
  • sudo apt install zsh -y

Setting up zsh for users

The first time you run zsh for a user, you need to select how to configure it. The recommendation is for:

  • (1) Continue to the main menu.
  • (0) Exit, creating a blank ~/.zshrc file.

You can use it in combination with antigen, which is a plugin manager for zsh:

  • mkdir ~/.antigen/ && cd ~/.antigen
  • curl -L > antigen.zsh
    (Remember the 3rd rule about preserving debian)
  • nano ~/.zshrc and load antigen, together with your configuration

An example configuration is:

source ~/.antigen/antigen.zsh

antigen use oh-my-zsh

antigen bundle git
antigen bundle heroku
antigen bundle pip
antigen bundle lein
antigen bundle command-not-found

antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions

antigen theme bira

antigen apply

To update the default shell for a user, you can do the following:

  • sudo nano /etc/passwd
  • replace /bin/bash with /bin/zsh for whichever user you want to use this shell as default.

Enable the firewall

  • sudo apt-get update && sudo apt-get upgrade -y
  • sudo apt-get install ufw -y
  • sudo ufw allow OpenSSH
  • sudo ufw allow in "WWW Full"
  • sudo ufw enable

More information:

Commands which might be useful

  • uptime – show the system uptime;
  • uname --help – useful information about your sytem;
  • killall -9 <process name> – kill a process;
  • speedtest – I guess it’s obvious what it does and you install it with sudo apt install speedtest-cli -y

Configure the hosting solution


First of all, run the following commands to install virtualmin on your system:

  • sudo apt-get update && sudo apt-get upgrade -y
  • wget
  • sudo /bin/sh ./ --minimal --force

First login

Once the setup has finished, you will be prompted to login to the web administration panel, found at: You can login with previously created your sudo user and password.

You will have to complete a setup, where you can comfortably keep the defaults.

Once the setup is completed, I recommend disabling the email.

If you use Google Chrome or any flavour of it – e.g. brave, chromium – you might encounter this NET::ERR_CERT_INVALID warning.

Error without the proceed button.

Whenever you see this error, you should just type badidea or thisisunsafe. There will be no indicator of your typing, but once you are done, the proceed button will be unlocked.


Change the port

It is important to change the default server from 10000 to something else. For this, you need to go to the Webmin tab, Webmin > Webmin Configuration > Ports and Addresses. There you should replace 10000 with your desired port.

Once you have changed the port, remember to add it to the allowed firewall ports. Should your port be 99999, the command is:

sudo ufw allow 99999/udp

Setup backups

You should always have backups for your server – this will save a lot of headaches in case you get hacked, you accidentally delete something and other uncomfortable situations. Should your server be small, you can use the free tier or Amazon S3.

Setup the first server

I usually add a website for the address of the virtualmin, on port 80 for having virtualmin handle the SSL certificate automatically.

Should you encounter Failed to change address : IPv6 cannot be enabled unless the Socket6 Perl module is installed you need to install the following package:

apt-get install libsocket6-perl -y

Set the time

Just to have the time accurate on your system, you should check the settings and maybe choose and set a syncing option. To do that, in your Virtualmin sidebar you should go to Webmin > Hardware > System Time. An example value for synchronizing time is:

Read more:

Multiple PHP versions

You should get updated versions of the software and be as much up to date as possible with your packages. However, when the software you use might require older php versions, it’s recommended to use that only in the virtual server you setup. This can be done with the following commands:

  • sudo apt-get -y install apt-transport-https lsb-release ca-certificates curl
  • wget -q -O- | sudo apt-key add -
  • echo "deb buster main" | sudo tee /etc/apt/sources.list.d/php.list
  • sudo apt-get update && sudo apt-get upgrade -y

After this, you should be able to install different php versions. E.g. to install php 7.0 you can use:

sudo apt install php7.0 php7.0-fpm -y



  • sudo apt-get install build-essential libssl-dev -y
  • sudo nano /etc/profile.d/ and add:
if [ ! -f ~/.nvm/ ]; then
# May need to be updated with the latest nvm release
wget -qO- | bash
source ~/.nvm/
  • sudo chmod +x /etc/profile.d/
  • For each of the users who will run it do:
    source /etc/profile.d/


  • sudo apt-get update && sudo apt-get upgrade -y
  • curl -sS -o composer-setup.php
  • sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer


  • curl -O
  • chmod +x wp-cli.phar
  • sudo mv wp-cli.phar /usr/local/bin/wp-cli

Moving virtual hosts

You might be migrating from a different install or host to this one. For example, I am migrating most of the websites I want to host from an Ubuntu based server which is still online. Handling DNS together with testing is tricky, because the updates do not happen instantly.

However, there is a “hack” you can use – the hosts file on your own computer. More information about how to edit it you can find here:

So, using this you can easily switch between the possible destinations of a domain name.