logo smart home family kruse

Kruse Smart Home

Easy living in our smart home & Garden

Hosting multiple websites on a Raspberry Pi 4 with Virtualmin

Hosting multiple websites on a Raspberry Pi 4 with Virtualmin

29 April 2023


1. Introduction

When hosting multiple websites on a Raspberry Pi 4 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 use Virtualmin (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 setup your hosting multiple websites on a Raspberry Pi 4 with Virtualmin. Installation and configuration instructions will be provided. Additional documentation can by found on the website of Virtualmin.

2. Requirements

For hosting multiple websites on a Raspberry Pi 4 with Virtualmin the following is required:

  • Working Raspberry Pi 4 with at least 1GB RAM and 1GB free disk space
    In our case a Raspberry Pi 4 model B with 8 Gb RAM and a 500 Gb Samsung sata SSD in a Geekworm NASPi 2.0 case
  • Internet connection (with reasonable up- and download speeds (in our case we have 250 Mbps).
  • Access to your router to setup port forwarding
  • Virtualmin
  • Webmin
  • Preferably domain names for your websites

For building a Raspberry Pi 4 system to be used as the web server see our article “Setup and configure a Geekworm NASPi v2.0 Raspberry Pi 4 case“. For installing Webmin, required before we install Virtualmin, see our article “How to install Webmin on a Raspberry Pi 4?“.

3. Installation

Follow the next steps to install Virtualmin (based on the Automated Virtualmin Installation):


  1. Get the installation script:
  2. Execute the installation script:
  3. Enter Y and enter:
  4. In our case an error message was displayed indicating that our hostname “RPW-webserver” is not a fully qualified hostname (also called a fully qualified domain name) as expected for a website.

    This fully qualified domain name (FQDN) is mandatory because many services rely on having a fully qualified domain name in order to function. Mail, in particular, but some Apache configurations and many of the Virtualmin-created configuration files, also require a valid fully qualified domain name to function correctly.

    A fully qualified domain name is one of the form “srv1.virtualmin.com”, or simply “virtualmin.com” (but do not use a name you’ll be hosting in Virtualmin). We recommend you choose a name that is not one for which you will be receiving mail, in order to simplify later configuration. A good choice is to use a name server designator, such as “ns1.virtualmin.com”. Some customers also choose something like “host1.virtualmin.com” or “primary.virtualmin.com”. Any of these would be valid and would satisfy the install script and the services that rely on this option.

    In our case I have a domain name from my current hosting provider which redirects to the IP address of my router. So I entered this site gallery.fotokruse.eu.

    If you do not have a domain name you could try to find the hosting name belonig to your routers IP address by first installing the nslookup command via:

    Then enter the following command:

    Where IP address is the IP address from you home’s internet connection, which you normally can find in your router/modem. The command will display a hostname which you could also use.

  5. Wait till installation has finished. This can take a while.
  6. You can now login to Virtualmin, which runs like Webmin on port 10000 and is encrypted using SSL. Thus, you can connect to your system with an address of the form:
    https://example.com:10000 or
    It might show a warning that the site is not secure, which is logical as SSL configuration has not been done yet.
  7. Log in as the Raspberry Pi 4 default/root user, or any user with sudo ALL access.

4. Initial configuration via the Post-installation Wizard

When logged in into Webmin/Virtualmin the Post-Installation wizard will be shown in Virtualmin.

Click on the next button to start answering a series of setup questions.

  1. Memory use; leave at default
  2. Enable virus scanning for receiving emails; disable as we will not setup an email server.
  3. Database servers; leave at default.
  4. MariaDB password; keep or change the default password. At least make sure you remember!

  5. DNS configuration; in our case our server domain name was displyed. Other option could be local IP address, i.e. Check “Skip check for resolvability”; leaving unchecked seems to cause more issues than solving them.
  6. All done; but there is an option for additional optional features when you click next.
  7. Password storage; for time being left at default.
  8. MariaDB database size; left at default.
  9. SSL key directory; left at default.
  10. Creation of default virtual server; left at default, so will be setup.
    When next is clicked configuration starts and takes about 1-2 minutes.
  11. A message will be displayed that configuration has been finished.Click on Finish.
  12. Click on “Re-check and refresh configuration”.
  13. A status overview will displayed.
  14. If no warnings/errors are displayed the configuration is finished.

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.


5. Fix SSL support via Lets Encrypt

In our case it appeared that the default virtual web server was not SSL protected although we requested to do so in step 10 in previous section. Go to Virtualmin > Server Configuration > SSL Certificate. It will show that the SSL certificate being used is the self signed webmin certificate and not the Let’s Encrypt one.

Follow the steps below to fix the issue (note this solution worked at least for us). Note it might be steps 1 and 4 are not required.

  1. Go to Per-IP Certificates and click on the domain name used for the Webmin/Virtualmin instance.
  2. Click on Delete.

  3. It looks like the site is now bussy, but it is not. As there is no SSL certificate for your server anymore, you need to reconnect via the IP address of the Raspberry Pi 4, i.e. for example
  4. Go back to Virtualmin and select the correct server from the dropdown.
  5. Goto Webmin > Webmin Configuration > SSL Encryption
  6. It shows the private key is not the one from Let’s Encrypt. Select Let’s Encrypt tab in the upper right.
  7. Replace the displayed IP address by the correct hostname for your Webmin server and click on Request Certificate.
  8. The certificate will be fetched and linked to the Webmin server.
  9. The SSL settings screen shows now the Let’s Encrypt certificates are used. Connecting via https will now show it is a secured site.

6. Install latest PHP version

The default installed PHP version during our installation of Virtualmin was PHP version 7.4. The recommended version currently is version 8.2. 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.

Follow the next steps to install additional PHP versions:

  1. Enter command:
  2. Enter command:
  3. Enter command:
  4. Enter command:
  5. Enter command:
  6. You can add specific PHP versions by using the command below. Replace 8.1 by another version number.
  7. Note: command updated 2-May-’23 to include curl required by WordPress plugins.
  8. Make sure you have selected the correct virtual web server and goto Server Configuration > PHP Options.
  9. Select the specific PHP versions as shown below and click on save.
  10. The changes will now be made.

7. Install phpMyAdmin

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL and MariaDB databases over the Web. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.

Installing is easy as Virtualmin has an install script for it by default. Be aware that this needs to be done for every virtual web server where phpMyAdmin is required.

  1. Go to Virtualmin > Install Scripts and select phpMyAdmin.
  2. Click at the bottom of the install script overview on “Show Install Options”.
  3. Leave the default settings and click on “Install now”.
  4. The installation process can be followed till finished.

  5. phpMyAdmin can now be accessed via https://<domain name>/phpmyadmin. If you login with the provided login info you only have basic rights. To add for example users login with the MariaDB root user account.

8. Create a virtual server

Creating a virtual server for a new website is now easy:

  1. Go to Virtualmin > Create Virtual Server
  2. Enter the required information:
    a. domain name of the website
    b. Administration password
    c. Custom username. This will be used to create the folder where the website files will be stored. So wise to enter the website name like www_fotokruse_eu for example.
    d. same for the default database name.
    e. As we are aiming for only a website we deselect all other items except Apache website and the MariaDB database. As we are using domain name hosted elsewhere we do not select Setup DNS zone (if you do so you will get issues with the SSL configuration).
  3. Click on Create Server. The virtual webserver will be setup now.
  4. When going back to editing the virtual server just created you have the option to change some settings if required.

The virtual server has been setup now and will display a default page when accessing the URL. Next step is for example installing WordPress or Piwigo.

Article by <a href="https://smarthome.familykruse.eu/author/iamjwk/" target="_self">Jan-Willem</a>

Article by Jan-Willem


Writen by the website owner


Submit a Comment

Your email address will not be published. Required fields are marked *