Manage Linux services with Webmin
Are you an experienced Windows system administrator who has just begun to work with CentOS or another Linux server distribution? With the help of the Webmin configuration tool you can perform your new sysadmin duties from a simple web interface.
Instead of manually editing configuration files and fiddling with command-line switches, you can use Webmin to configure your system from a GUI and automatically update the relevant underlying config files. Webmin can manage host systems and network services. You can use it to manage user accounts, set up disk quotas, create and configure virtual hosts for the Apache web server, and set up Samba file sharing, among many other services. Using Webmin keeps you from spoiling configuration files by making accidental syntax errors.
While you can use Webmin to manage many popular network services, you must have most of them installed already before Webmin can configure them. However, Webmin can install some popular servers, such as Apache, for you, as we'll see in a moment.
Although you can download precompiled binaries from its website, it's best to install Webmin from its official repositories. To do that, you first must create the repository file /etc/yum.repos.d/webmin.repo with the following contents:
name=Webmin Distribution Neutral
Next, import the GPG key with which the packages are signed:
# wget http://www.webmin.com/jcameron-key.asc
# rpm --import jcameron-key.asc
You can then install Webmin with a simple
yum install webmin command.
Webmin includes its own web server, so you don't have to worry about setting up one beforehand. While Webmin can use an existing web server on your network, the process is complicated and there's no performance benefits in doing so.
By default users access Webmin on port 10000. If you are logged in to the machine on which you have installed it, type http://localhost:10000 in a web browser to open Webmin. If you can't access the service on the default port, perhaps because you already have a service running on that port or it's blocked by the firewall, you'll have to manually edit Webmin's configuration file, /etc/webmin/miniserv.conf, to change it, then restart Webmin with
service webmin restart.
Before you can access Webmin you have to authenticate yourself with the credentials of the root user. Once you're logged in, Webmin takes you to the System Information page where it displays various information about the computer it's running on.
Webmin has an intuitive two-pane interface. On the left are categories labeled Webmin, System, Servers, and several more. You can expand each category to see a list of services it houses. In Webmin parlance these are called modules.
Each module is responsible for managing some service, such as the Apache web server, the firewall, or a software package. By default, when Webmin is installed, it reads the configuration files for all services from their standard installation locations. If you have installed a service from source instead of from a precompiled package, or installed one to a different location, Webmin may not be able to find its configuration file, and will list such services under the Un-used Modules category. Fortunately, that problem is easy to fix.
To point Webmin to an application's configuration file, navigate to the module and click on the module configuration link. From the screen that Webmin displays you can modify the information for the module to point to the location of its configuration file.
You can also install several popular server applications from within Webmin. They're shown under the Un-used category. Click on an icon for a server you wish to install, and along with a warning that it can't find the server, Webmin will give you a link to download and install the server using the yum package manager.
To get a hang of Webmin's potential, let's use the tool to secure itself by enabling SSL support.
For that you need to install the OpenSSL package on the host OS – which you can do via Webmin. Under System -> Software Packages scroll down to the Install a New Package section and tick the radio button next to the fourth option, to install packages from yum. In the adjacent text box, enter
openssl openssl-devel and click on the Install button. Webmin will invoke yum and install the packages.
You also need the Net::SSLeay Perl module to allow scripts to call the functions in the OpenSSL library. You can install this module from this page as well by entering
perl-Net-SSLeay in the text box.
After installing the packages you can enable SSL support in Webmin. Head to Webmin -> Webmin Configuration. Scroll down the page and click on the SSL Encryption option. Change the Enable SSL if available option to Yes and click on Save. Webmin should begin running in SSL mode, which means you must log in again to Webmin using an https URL.
You can do a lot more from under the Webmin section, which is used for configuring Webmin itself. For example, you can access the Webmin log from the Webmin Action module, add Webmin users who have limited access to the modules via the Webmin Users module, and even change Webmin's appearance from the Change Language and Theme module.
The modules to alter the base system are located in the System section. In addition to the Software Packages module, interesting modules under this section include Bootup and Shutdown, which provides access to all the init scripts under /etc/rc.d/init.d, and Disk and Network, which lets you create and edit mount points.
Set up Squid with Webmin
Now let's use Webmin to install and set up the Squid caching proxy server. Head to the module's page under the Un-used category and click on the link to install it. When it's installed, return to the Squid Proxy Server module.
Though Webmin installed Squid, it didn't set it up, so the module will display an error saying that the cache directory hasn't been initialized. If you wish to use the default /var/spool/squid cache directory you can initialize it by simply clicking the Initialize Cache button. If you wish to use another directory you'll have to point to it under the Cache Options page. Webmin will display any output produced when you set up the cache directory. When the process is complete you can return to the module's main page and start using the module.
Click on the Start Squid button to bring up the server with the default configuration. Once it's running, the Squid Proxy Server module will be listed under the Servers category, and you'll see links that let you stop the server and apply changes you've made to its configuration.
To see that it worked, configure a browser on your local network to use the Squid server as its proxy. Browse the web for a bit, then take a look at the logs from under the System Logs module in the System category. You should find both the Squid cache log (cache.log) and the store log (store.log) listed.
Webmin lets you manage many of Squid's features from within its GUI. By default, Squid runs on port 3128. You can change this from under the Ports and Networking section in the Squid module. If you plan to use a machine solely as a proxy server you'll need to add more cache directories, and you can do so from the Cache Options section. You can define and manage access control lists (ACL) under the Access Control section.
Squid is just one of the dozens of network servers and system services that you can install, customize, and control with Webmin. Webmin seamlessly fits into existing installations. It saves you the trouble of having to memorize numerous configurable parameters for a variety of server and services, and ensures that your system is set up properly.
Do you want to receive a compilation of Wazi's top
blog posts in the past year delivered directly to your inbox?
This work is licensed under a Creative Commons Attribution 3.0 Unported License