Webmin is a lightweight control panel to manage Linux machines with ease. With its web interface, you can create user accounts, set up cron jobs, check disk quotas, and much more. Better yet, installing Webmin is fairly straightforward, and the service is completely free.
All in all, Webmin is handy for Linux/VPS beginners who are not comfortable with the Linux command line.
In this article, we’ll set up Webmin on Ubuntu 18.04. These instructions should also work on Ubuntu 16.04.
Prerequisites for installing Webmin
- A new Ubuntu 16.04/18.04 machine with at least 2 GB of RAM.
- A valid DNS name pointing its A record to the IP address of your VPS.
Step 1. Configure fully-qualified domain name (FQDN) of your VPS
For Webmin to work you need to set up a fully-qualified domain name (FQDN). An FQDN is an absolute way of specifying a particular machine on a specific network and includes both a hostname and a domain name. Once you have an FQDN, you can set an A record on its DNS to point toward the IP address of your VPS.
Set the hostname of the system by editing the file /etc/hostname
, replacing YOUR-HOSTNAME
with your hostname of choice:
$ vi /etc/hostname
YOUR-HOSTNAME
Next, edit the file /etc/hosts and add the following line at the end: The format is YOUR-IP YOUR-HOSTNAME.YOUR-DOMAIN YOUR-HOSTNAME
.
$ sudo vi /etc/hosts
YOUR-IP YOUR-HOSTNAME.YOUR-DOMAIN YOUR-HOSTNAME
Here’s an example using an IP of 123.456.78.9
, a hostname of webmin
and a domain of example.com
.
123.456.78.9 webmin.example.com webmin
Run the command below to restart hostname service and network manager to apply changes:
$ sudo systemctl restart systemd-logind.service
$ sudo systemctl restart NetworkManager.service
Now check the hostname and FQDN of your VPS. They should be updated based on what you just specified.
$ hostname
panel
$ hostname -f
panel.YOURDOMAIN
Step 2. Install Webmin
The first step towards the installation of Webmin is to add Webmin’s repository information to your source list for easy installation and updating of Webmin and its modules using apt-get
. Edit /etc/apt/sources.list
and add the following lines at the end of the file.
$ sudo vi /etc/apt/sources.list
....
....
deb http://download.webmin.com/download/repository sarge contrib
Add Webmin’s PGP key, so your system trusts the new repository we just added.
$ sudo wget -qO- http://www.webmin.com/jcameron-key.asc | sudo apt-key add
OK
Update the system and install Webmin:
$ sudo apt-get update
$ sudo apt-get install webmin
You can now visit the Webmin interface via https://YOUR-HOSTNAME.YOUR-DOMAIN:10000
. Webmin warns you about an untrusted certificate—that’s fine, just add it to the exception list and login with the user you use to connect to the server via SSH.
On successful login, you are redirected to the Webmin dashboard.
Step 3. Install Let’s Encrypt
To keep the connection with your Webmin server encrypted, let’s use a free Let’s Encrypt’s SSL certificate. First, clone the Let’s Encrypt repository in the /usr/local
folder.
$ cd /usr/local
$ git clone https://github.com/letsencrypt/letsencrypt
Navigate to Webmin > Webmin Configuration
in the Webmin dashboard and click on the box with a gear icon on the top-left corner called “Module Config.” Enter the full path (/usr/local/letsencrypt/letsencrypt-auto)
of the Let’s Encrypt binary and hit the save button.
Go to Webmin > Webmin Configuration > SSL Encryption
and select the Let’s Encrypt tab. Enter your domain name in hostname for certificates box
. Choose Other directory
for Website root directory for validation file
option and enter /var/www/html
. You can choose another directory in place of /var/www/html
, but make sure the Let’s Encrypt ACME challenge can access that directory. Keep the rest of the options in their default state.
Click Request Certificate
. On successful fetching of the certificate, you get the following message:
Now that the Webmin is installed and encrypted with SSL, you can start exploring its many features and capabilities. An excellent place to start it upgrading your system’s packages. All packages available for update are listed on the left-hand side under the Package Updates
section.
You’re all set up to get cPanel-like administrative power for free!
celebratory gif
What’s next? It all depends on your needs and applications, but you can go ahead and experiment with creating users/groups, changing passwords, scheduling cron jobs, creating virtual hosts with Apache, manage firewalls, and more. With Webmin, you can do all this with a GUI rather than typing the commands—a nice bonus for those who don’t want to spend much time on a terminal.
You can also check out Webmin’s official wiki to explore Webmin’s features even further.
Optional step. Configure an Apache virtual host and proxy
If you have Apache installed and running on port 80, you can configure Apache to act as a proxy gateway for Webmin. This will allow you to access Webmin via https://YOUR-HOSTNAME.YOUR-DOMAIN
instead of https://YOUR-HOSTNAME.YOUR-DOMAIN:10000
.
For this, we need to enable three Apache modules: proxy
and proxy_http
and ssl
. Enable these modules one by one by issuing following commands from the terminal and restart apache.
$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo a2enmod ssl
$ sudo systemctl restart apache2
Next, create the Apache virtual host for our webmin installation with the following configuration:
$ vi /etc/apache2/sites-available/webmin.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName YOUR-HOSTNAME.YOUR-DOMAIN
ServerAlias YOUR-HOSTNAME.YOUR-DOMAIN
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/YOUR-HOSTNAME.YOUR-DOMAIN/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/YOUR-HOSTNAME.YOUR-DOMAIN/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/YOUR-HOSTNAME.YOUR-DOMAIN/chain.pem
ProxyRequests On
ProxyVia On
SSLProxyEngine On
ProxyPass / https://YOUR-HOSTNAME.YOUR-DOMAIN:10000/
ProxyPassReverse / https://YOUR-HOSTNAME.YOUR-DOMAIN:10000/
</VirtualHost>
</IfModule>
<VirtualHost *:80>
ServerName YOUR-HOSTNAME.YOUR-DOMAIN
Redirect permanent / https://YOUR-HOSTNAME.YOUR-DOMAIN/
</VirtualHost>
The ProxyPass
directive allows Apache to pass requests for YOUR-HOSTNAME.YOUR-DOMAIN
to the Webmin server, which is running in the port 10000, and the ProxyPassReverse directive ensures internal links generated from the Webmin server pass through apache.
Enable the virtual host by creating a symbolic link of the above file inside /etc/apache2/sites-enabled
directory. You can also activate the site using a2ensite command.
$ cd /etc/apache2/sites-enabled
$ sudo ln -s ../sites-available/webmin.conf .
Test syntax and restart it.
$ sudo apache2ctl -t
OK
$ sudo systemctl restart apache2
Lastly, add the line referer=YOUR-HOSTNAME
to your /etc/webmin/config
file.
$ vi /etc/webmin/config
....
....
referer=YOUR-HOSTNAME.YOUR-DOMAIN
Finally, you can restart Webmin.
$ sudo systemctl restart webmin
At this point, you can access your Webmin server using the Apache proxy by navigating to https://YOUR-HOSTNAME.YOUR-DOMAIN
in your browser.
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.