LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Configuring Virtualmin on CentOS 7 for Website Hosting: Part 1

In the professional Linux web hosting world, cPanel rules as king. That’s not necessarily a bad thing! cPanel is rich in features and is for the most part stable and reliable. But it’s also completely unsuitable for a small, inexpensive VPS that you’d find here at LowEndBox.  Most likely the cPanel license will cost significantly more than the VPS you’re using, and it will severely tax the resources of a smaller VPS. Does that mean that you’re out of the web hosting game altogether? Not by a long shot! We have an excellent number of open source control panel options. In this tutorial we’re going to focus on installing one such solution:

Enter Virtualmin. Virtualmin GPL (the Free Open Source version of the Virtualmin commercial product) is a fully featured open source web hosting control panel that allows you to run multiple websites on the same server. Virtualmin  consumes a small amount of disk space (less than 1GB) and supports CentOS, Debian, and Ubuntu without any extra complication. It’s got a friendly web based GUI for server and account management. Furthermore it respects the package manager of your chosen OS and allows you to make configuration changes outside of Virtualmin without overwriting them.

For this tutorial, we’re going to Virtualmin on a CentOS 7 VPS found right here on LowEndBox. Our KVM VPS has 15GB of disk, 1 cpu, and 512mb RAM. How is it possible to have a full web control panel on such a small server, you ask? Read on to find out!

Pre-Installation Preparation

You’re going to need to use SSH throughout this tutorial.  If you haven’t logged into your new VPS yet, then be sure to check our tutorial “Using SSH Keys to connect to your VPS.” It’ll help you to get logged in and configure your SSH keys. 

If you haven’t already chosen a hostname for your server, then we’ll need to do that now. It can be tempting to just use “yourawesomevps.com” but for things to work properly, you need what’s called a Fully Qualified Domain Name. A FQDN uses a prefix like “server” ahead of “virtualmin-tutorial.tld”. The FQDN would be “server.virtualmin-tutorial.tld”. 

If you’ve already chosen a name for your VPS, your VPS provider will have set it for you. Otherwise, you need to set it manually. On CentOS 7 you can set the hostname with the following command, via SSH:

echo "server.virtualmin-tutorial.tld" > /etc/hostname

Next we’re going to turn off SELinux as its use is not supported for our purposes. We’re going to use ‘sed’ which is a Linux program that can perform file edits without even opening the file. The following command changes the current SELINUX= line in /etc/selinux/config to say “disabled”:

sed -i 's/SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config

Reboot your server to ensure that your hostname is set correctly and that SELinux gets disabled:


Log back into your VPS, and check its hostname to be sure it’s set correctly:

[root@server ~]# hostname

Let’s also check to make sure SELinux is disabled:

[root@server ~]# getenforce

Excellent! Now we will install some basic utilities, including a couple that will make our life easier when installing Virtualmin. Run the following command:

yum -y install perl lsof sysstat lsof traceroute whois wget ftp nano

Now we’re ready for the next step: Installation!

Installing Virtualmin

To get Virtualmin into our small VPS, we’re going to make use of the Virtualmin installer minimal install feature that essentially strips out the main memory hogging feature- the email server. While it is possible to install the mail server on 512mb RAM, it’s not advisable because the spam filtering will slow down the server significantly. If you want to enable the mail server features of Virtualmin, it’s advisable to get a VPS with at least 1GB of memory.

One of the luxuries of using Virtualmin is that it will install Apache, MySQL and PHP for you.  We’ll be using the Minimal install as previously noted. If you have a server with 1GB or more memory, you can omit the “–minimal” tag below.

wget http://software.virtualmin.com/gpl/scripts/install.sh
sh install.sh --minimal

Here’s how the installation looked on our test VPS:


Press “y” to continue. Now, we just wait a few minutes for Virtualmin to install its Minimal stack. While we wait, let’s talk about what’s next. The minimal install skips many of the most memory intensive parts of the server, but it does install a full LAMP stack. In 10 minutes or less the install should be complete! You should see something similar to the following screen:


Down at the bottom right corner you can see a URL for your server’s new control panel. Copy that URL to your notes. Before we continue further, we need to set the root password for MySQL. MySQL has no root password set, and that’s not a secure configuration. Thankfully this is very easy to resolve. In the following few commands, replace “ROOTPASS” with a secure password. The password you choose does not need to be your actual root password. In any case, make sure you have a record of it as we’ll need it later.

First, type “mysql” to get a mysql prompt:

[root@server ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

Now you can paste in the following, after correcting the root password:

use mysql;
update user set password=PASSWORD("ROOTPASS") where User='root';
flush privileges;

This is how the process looked on our VPS:


Logging in to Virtualmin

Log in at the Virtualmin control panel URL you previously took note of. Ours is https://server.virtualmin-tutorial.tld:10000. You’ll also note that you’ll receive a security warning when you visit it. The SSL is just a self-signed certificate at this point. Go to the URL in your browser, bypass the SSL certificate errors, and you should be greeted with a login screen for Webmin. Don’t be alarmed- Webmin is what Virtualmin is based on, and the actual server administration is still done with Webmin. Virtualmin handles the virtual hosting portion of the workload.


Log in with the username “root” and with your root password. The Post-Installation Wizard appears. If you get a connection error, try using a private browser- some browser extensions will interfere with Virtualmin.


The Post-Installation Wizard

Go ahead and click on Next and we’ll work through the different options. The first is asking if we want to preload the Virtualmin libraries. We’re going to select No for the sake of keeping memory usage low. If you’ve got a VPS with at least 1GB of memory, you can select Yes.


The format is the same for the rest of the questions.

Run a MariaDB/MySQL database server? Yes (almost everything uses this!) 
Run PostgreSQL database server? No (unless you specifically need it)

Click Next

Now you’ll be presented with the MySQL Password section of the wizard:


Put in the your root password for MySQL that you set earlier. If prompted, select “Yes” for removing the test database and anonymous user. Click Next.

For MariaDB/MySQL configuration size, select Medium System (512M). If you have a larger system, you can select the appropriate size. Click Next.

For the DNS configuration, you have some choices to make. Since our system is only 512M and the BIND DNS service can be a memory hog, we’re going to run our DNS externally. For that, you can just check the “Skip check for resolvability” box and click Next.

The next configuration option is for Password storage. Make a choice that makes sense for you. We chose “Only store hashed passwords” due to its higher security. Click Next, and you’re done with the Post-Installation Wizard. Click the “Re-check and refresh configuration” box and let it complete:


When the “Checking Configuration” screen is done, click on the Dashboard on the left column. You’ll be presented with the following screen:


This is the first screen you’ll see when you log in from now on. The work is not done yet however- we still have several things to complete! The next steps will involve setting up an SSL certificate for Virtualmin, configuring Apache so that it has a smaller memory footprint, and installing an updated PHP version and making some PHP configuration tweaks. All of these things are considered in the second half of this tutorial:

Configuring Virtualmin on CentOS for Website Hosting: Part 2

No Comments

    Leave a Reply

    Some notes on commenting on LowEndBox:

    • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
    • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
    • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

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