How to Install Webmin on Ubuntu 18.04

By Ghulam Qadir, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Webmin is a web-based control panel for any Linux machine which lets you manage your server through a modern web-based interface. With Webmin, you can change settings for common packages on the fly, including web servers and databases, as well as manage users, groups, and software packages. Webmin helps system administrator to manage the operating system’s internal such as changing passwords, disk quotas, file system, process, scheduled jobs, software packages, system logs, and much more.

With Webmin, you can also manage/configure open source applications such as DNS, DHCP, MySQL server, PostgreSQL, Apache HTTPD server and other networking services.

In this tutorial, we’ll install and configure Webmin on an Alibaba Cloud Elastic Compute Service (ECS) server and secure access to the interface with a valid certificate using Let’s Encrypt and Apache. We’ll then use Webmin to add new user accounts, and update all packages on your server from the dashboard.

Until Ubuntu 18.04 matures and is included in Alibaba Cloud’s library of operating system images, we can upgrade Ubuntu 16.04 to Ubuntu 18.04 by using the do-release-upgrade utility.

Prerequisites

  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide.
  2. You should set up your server’s hostname.
  3. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC.

After completing the prerequisites, log in as root user with your root username & password via SSH client (e.g. Putty) or VNC console available in your Alibaba Cloud account dashboard.

To complete this tutorial, you will need:

  1. Apache to perform Let’s Encrypt’s domain verification and act as a proxy for Webmin. Ensure you configure access to Apache through your firewall when following this tutorial.
  2. A Fully-Qualified Domain Name (FQDN), with a DNS A record pointing to the IP address of your server.
  3. Certbot to generate the TLS/SSL certificate for Webmin.

Installing Webmin

First, we need to add the Webmin repository so that we can easily install and update Webmin using our package manager. We do this by adding the repository to the /etc/apt/sources.list file.

Open the file in your editor:

Then add this line to the bottom of the file to add the new repository:

Save the file and exit the editor.

Next, add the Webmin PGP key so that your system will trust the new repository:

Next, update the list of packages to include the Webmin repository:

Then install Webmin:

Once the installation finishes, you’ll be presented with the following output:

Now, let’s secure access to Webmin by putting it behind the Apache web server and adding a valid TLS/SSL certificate.

Securing Webmin with Apache and Let’s Encrypt

To access Webmin, you have to specify port 10000 and ensure the port is open on your firewall. This is inconvenient, especially if you’re accessing Webmin using an FQDN like webmin.your_domain. We are going to use an Apache virtual host to proxy requests to Webmin’s server running on port 10000. We’ll then secure the virtual host using a TLS/SSL certificate from Let’s Encrypt.

First, create a new Apache virtual host file in Apache’s configuration directory:

Add the following to the file, replacing the email address and domain with your own:

This configuration tells Apache to pass requests to http://localhost:10000, the Webmin server. It also ensures that internal links generated from Webmin will also pass through Apache.

Save the file and exit the editor.

Next, we need to tell Webmin to stop using TLS/SSL, as Apache will provide that for us going forward.

Open the file /etc/webmin/miniserv.conf in your editor:

Find the following line:

Change the 1 to a 0; this will tell Webmin to stop using SSL.

Next we’ll add our domain to the list of allowed domains, so that Webmin understands that when we access the panel from our domain, it’s not something malicious, like a Cross-Site Scripting (XSS) attack.

Open the file /etc/webmin/config in your editor:

Add the following line to the bottom of the file, replacing your_domain with your fully-qualified domain name.

Save the file and exit the editor.

Next, restart Webmin to apply the configuration changes:

Then enable Apache’s proxy_http module:

You’ll see the following output:

The output suggests you restart Apache, but first, activate the new Apache virtual host you created:

You’ll see the following output indicating your site is enabled:

Now restart Apache completely to activate the proxy_http module and the new virtual host:

Note: Ensure that you allow incoming traffic to your web server on port 80 and port 443. You can do this with the command sudo ufw allow in “Apache Full”.

Navigate to http://your_domain in your browser, and you will see the Webmin login page appear.

Warning: Do NOT log in to Webmin yet, as we haven’t enabled SSL. If you log in now, your credentials will be sent to the server in clear text.

Now let’s configure a certificate so that your connection is encrypted while using Webmin. In order to do this, we’re going to use Let’s Encrypt.

Tell Certbot to generate a TLS/SSL certificate for your domain and configure Apache to redirect traffic to the secure site:

You’ll see the following output:

The output indicates that the certificate was installed and Apache is configured to redirect requests from http://your_domain to https://your_domain.

You’ve now set up a secured, working instance of Webmin. Let’s look at how to use it.

Using Webmin

Webmin has modules that can control everything from the BIND DNS Server to something as simple as adding users to the system. Let’s look at how to create a new user, and then explore how to update software packages using Webmin.

In order to log in to Webmin, navigate to http://your_domain and sign in with either the root user or a user with sudo privileges.

Managing Users and Groups

Let’s manage the users and groups on the server.

First, click the System tab, and then click the Users and Groups button. From here you can either add a user, manage a user, or add or manage a group.

Let’s create a new user called deploy which could be used for hosting web applications. To add a user, click Create a new user, which is located at the top of the users table. This displays the Create User screen, where you can supply the username, password, groups and other options. Follow these instructions to create the user:

  1. Fill in Username with deploy.
  2. Select Automatic for User ID.
  3. Fill in Real Name with a descriptive name like Deployment user.
  4. For Home Directory, select Automatic.
  5. For Shell, select /bin/bash from the dropdown list.
  6. For Password, select Normal Password and type in a password of your choice.
  7. For Primary Group, select New group with same name as user.
  8. For Secondary Group, select sudo from the All groups list, and press the -> button to add the group to the in groups list.
  9. Press Create to create this new user.

When creating a user, you can set options for password expiry, the user’s shell, or whether they are allowed a home directory.

Next, let’s look at how to install updates to our system.

Updating Packages

Webmin lets you update all of your packages through its user interface. To update all of your packages, click the Dashboard link, and then locate the Package updates field. If there are updates available, you’ll see a link that states the number of available updates, as shown in the following figure:

Image for post
Image for post

Click this link, and then press Update selected packages to start the update. You may be asked to reboot the server, which you can also do through the Webmin interface.

Control Webmin

To start the Webmin, run:

To stop the Webmin, run:

To restart the Webmin, run:

To view the status of Webmin service, run:

Accessing the Webmin Interface

Now open up a browser and visit

Log in as root or any user who has sudo privileges when the Webmin prompts you for username and password.

Image for post
Image for post

Once you logged in, Webmin may redirect you to its dashboard where you can get basic information about your system.

To manage or configure any service or application, choose the desired one from the left pane.

Image for post
Image for post
Image for post
Image for post

One important feature of Webmin is that it has a built-in web-based ssh terminal. You can start the terminal by clicking the below icon or use the keyboard combination “Alt+k”.

Image for post
Image for post
Image for post
Image for post

Conclusion

You now have a secured, working instance of Webmin on an Alibaba Cloud Elastic Compute Service (ECS) instance, and you’ve used the interface to create a user and update packages. Webmin gives you access to many things you’d normally need to access through the console, and it organizes them in an intuitive way. For example, if you have Apache installed, you would find the configuration tab for it under Servers, and then Apache.

Explore the interface further, or check out the Official Webmin wiki to learn more about managing your system with Webmin.

Reference:https://www.alibabacloud.com/blog/how-to-install-webmin-on-ubuntu-18-04_594042?spm=a2c41.12123082.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store