Documentation

First Things First

How to use the documentation - Start here. It provides a brief (about one page) overview of the conventions and organization of this documentation.

Getting Started

Installation Guides - Automatic and manual installation procedures for Virtualmin Professional and GPL.

Upgrading Virtualmin Software - Upgrading Virtualmin and related software from within Virtualmin and from the command line.

Step by Step Tutorials - Simple task-oriented guides for dozens of common tasks in Virtualmin, such as logging in, using email, creating virtual servers, etc. all in one big list (also available categorized below).

Installation FAQ - Have questions about installing Virtualmin?

Installation Troubleshooting - Troubleshooting common installation problems.

Email

POP3 and IMAP Configuration - How to configure common mail clients to download mail for POP3 and IMAP.

Spam and Anti-Virus Scanning - Explanation of Spam and Virus scanning features in Virtualmin.

Email FAQ - Have questions about the Virtualmin email stack?

Email Troubleshooting - Troubleshooting common email problems.

More...


Web

Website Content - Uploading and managing website content and data.

Web server FAQ - Have questions about web service and web applications in Virtualmin?

Website Troubleshooting - Troubleshooting common problems with web service.

Subversion and Virtualmin - Creating SVN repositories hosted with Virtualmin.

Git and Virtualmin - Creating Git repositories hosted with Virtualmin.

More...

DNS

Automatic DNS Slave Configuration - Configuring Virtualmin to automatically create and manage DNS slave zones on secondary servers.

DNS FAQ - Have questions about DNS in Virtualmin?

Domain Name Server Troubleshooting - Troubleshooting common problems with domain name service.

More...


Web Development

Ruby on Rails support in Virtualmin - Installing and managing a Ruby on Rails environment under Virtualmin.

PHP support in Virtualmin - Working with PHP in a Virtualmin environment.

More...

Administrative and User Account Guides

Virtual Server Owners Guide - A brief guide for virtual server account holders, covering logging in, uploaded and managing web content, and creating mailboxes.

Resellers Guide - A guide for Virtualmin resellers, covering creation and management of virtual servers.

Mail and FTP Users - A guide for Virtualmin mailbox account holders, covering logging into Usermin, and basic usage of mail features.

Accounts FAQ - Have questions about account types and users in Virtualmin?

More...

Developer Documentation

Command Line API - Command line tools for managing Virtualmin.

Remote API - Remote access to the Virtualmin API.

Writing Virtualmin Plugins - Building Webmin modules that interact with Virtualmin.

Creating Install Scripts - Making applications easily installable with the Virtualmin Install Scripts interface.

Creating New Content Styles - Creating new content styles for the Virtualmin website editor, or converting existing templates for use in Virtualmin.

More...

System Configuration and Maintenance

Backup and Restoration - Backing up and restoring Virtualmin virtual servers.

Virtualmin on Low Memory Systems - Configuration tips for running Virtualmin on systems with 256MB or less memory.

Mobile Devices and Virtualmin - Using Virtualmin on iPhone, Android, Palm Pre, or any other mobile device with a web browser.

Support Requests and Remote Login Access - Using the Virtualmin Support module to file tickets from within Virtualmin and get hands-on support for Virtualmin Professional and Cloudmin products.

OS Notes - Notes and caveats about specific operating systems. While Virtualmin and Webmin are generally fully functional on most modern Linux and UNIX systems, there are some known issues with some operating systems and versions.

More...

Cloudmin Documentation

Installation Guide - How to install Cloudmin.

Introduction to Virtualization Concepts - What virtualization is and how it works.

Using Cloudmin - An introduction to various tasks in Cloudmin.

More...

Amazon EC2 Instances

Virtualmin GPL AMI

Virtualmin Professional Paid AMI

Cloudmin Paid AMI

Administrative and User Account Guides

Administrative and User Account Guides

Virtual Server Owners Guide - A brief guide for virtual server account holders, covering logging in, uploaded and managing web content, and creating mailboxes.

Resellers Guide - A guide for Virtualmin resellers, covering creation and management of virtual servers.

Mail and FTP Users - A guide for Virtualmin mailbox account holders, covering logging into Usermin, and basic usage of mail features.

Mail and FTP Users Guide

Using Usermin Webmail

To access the Usermin Webmail system, browse to port 20000 on your domain name, using the HTTPS protocol.

For example:

https://www.domain.tld:20000

Login using your mailbox username and password.

Navigating Usermin

Usermin provides a left-hand menu, and a right-hand content pane.

In the left-hand menu, there is a Mail tab and a Usermin tools tab. The Mail tab includes a list of available mail folders, a search box, and links for folder management, address book, mail preferences, change passwords, system information, and switch user.

The right pane displays either the active folder, mail message, or Usermin tool that has been selected in the left-hand menu.

Virtualmin Resellers Guide

A guide for Virtualmin Reseller account holders. Documents domain creation, editing, maintenance, and script installation.

Introduction

Virtualmin, combined with Webmin and Usermin, provides a complete virtual hosting administration system, allowing for four tiers of operation, "administrator", "reseller", "domain owner", "mail user". This guide is for the second, or reseller, tier of the system. The reseller account type has the ability to create, update and delete domains, manage email addresses within the domains under her control, and optionally install scripts and monitor bandwidth and disk usage. This guide covers only Virtualmin's extensive virtual hosting features that are available to Reseller account holders.

Navigating Virtualmin

Any web browser can be used with Virtualmin, though some themes use advanced browser features that work better in browsers with good CSS support (Firefox, Safari, Opera and Konqueror all fit this description, while Internet Explorer currently does not). It is even possible to use a text-mode browser like lynx or links to use Virtualmin.

To login to Webmin (because Virtualmin is part of Webmin, one logs into Webmin and browses to the Virtualmin module), browse to the address of your server using the HTTPS protocol on port 10000. For example, if your Virtualmin server was running on hostname hosting1.virtualmin.com, you would enter https://hosting1.virtualmin.com:10000 in the URL field of your browser.

Your administrator will provide you a username and password to use for logging in.

Online Help

Within most Webmin modules, there will be a help link in the upper left corner of the page. Clicking it will open a help window with documentation about the specific page you are on. Most options in Webmin can be clicked on to get a popup help window describing that specific option. The Virtualmin module has extensive online help in addition to this manual, so if any option or feature confuses you, you don't have to find the appropriate section in this guide. Clicking on it will popup the help window with help specific to the item you clicked.

Logging Out

At the bottom of the left-hand menu, you'll find a Logout link. Clicking this link will, obviously, log you out of Webmin.

Creating Your First Domain

To create a new virtual server, click the Create Server* menu heading in the left menu bar, and then click the *Create Virtual Server item.

A new page full of options will be displayed in the right content window. We'll assume that most default settings are appropriate for our domain for the sake of simplicity in this example, but later on we'll dive into the depths of custom Server Templates, skeleton directories and customization of the default settings for new domains. After a fresh install, Virtualmin has pretty reasonable defaults for the vast majority of environments, though, so we can create a domain easily and expect it to be useful right away.

image:images/first-domain.png["Screenshot of Virtualmin Create Domain page"]

In the above, I have filled in everything that is needed to create a domain with most features enabled. I only specified a few options: Domain name, Description, Contact email address, and Administration password. The rest I've left at their default values. If you aren't sure what a particular option means, click on the name of the option, and a help window will pop up to describe the option. Every option in Virtualmin has a popup help link, and most pages have a general overview help link in the upper left corner of the page.

Domain Name

You must always provide a domain name for a virtual server account (there are ways to create websites for users without domains using Virtualmin, but that is a much simpler problem and isn't the focus of Virtualmin).

Description

The description is simply a short description of the domain. It is free text, and does not impact any aspect of the virtual server, so it can be just about anything. It will appear as the "Real Name" of the domain user in the Users and Groups module.

Contact email address

Here, you select what email address should receive notifications about this domain, including the creation email that lists the available services, provides login instructions, etc. If you choose to generate the password later on, this may be the only way for the user to find out the password, so it may be appropriate to choose Other address.. and enter the users preferred address in the field provided.

Administration password

You can choose to have a password generated randomly, which is a good idea from a security standpoint. Virtualmin will generate a reasonably long (8+ characters) random password, which will be sent to the user via email. They can, of course, immediately change the password when they login.

Other options

All of the other options can generally be left alone. We'll discuss many of them in more detail later on, but for now, let's just assume that the defaults are perfect.

When you click the Create Server button, Virtualmin will spin into action...it will create the new user and group, add Apache virtual host configuration, add a zone and domain to BIND, add virtual domain configuration to Postfix, create new databases and users in MySQL and PostgreSQL, configure SpamAssassin and ClamAV for the domain, configure log rotation and Webalizer log reports, (woo! I'm getting tired just talking about it...that Virtualmin works hard so you don't have to) and configures any optional Virtualmin Plugin features, like Mailman mailing lists or SubVersion revision control repositories.

Now you can return to the Virtualmin main page and you'll see your new domain in the list of available domains. Clicking on the domain allows you to edit all of the options we just configured, so you can always return to the domain to alter the settings (be careful with that feature, however, as turning off a feature may delete user data...Virtualmin will warn you before destructive changes).

The domain owner can also login using the new domain account and the password you assigned (or that was randomly generated).

Bandwidth Monitoring

Bandwidth monitoring is a standard feature of Virtualmin, allowing the administrator to limit bandwidth usage or simply notify users and administrators when a domain is approaching and has surpassed their allotted network bandwidth.

To find out bandwidth usage of your domains, click the Bandwidth Usage link in the left-hand menu (if unavailable, bandwidth monitoring has not been enabled for your account).

Install Scripts

Virtualmin Professional provides the ability for domain owners, resellers, and administrators to easily install dozens of PHP and Perl scripts within a Virtualmin domain. It also allows for one or more scripts to be installed automatically on server creation, based on the selec ted Server Template for the new domain. New Script Installer scripts can also easily be writ ten using the Install Scripts to add support for internally developed applications.

To install a new script select the domain you'd like to install for in the dropdown menu at the top of the left-hand menu, and then click Install Scripts. Then, click the radio button next to the script you'd like to install, and optionally select a version (often both a stab le and development version are provided). Finally, scroll to the bottom of the page and clic k the Show Install Options button.

On this page, you'll be able to select the database to use from existing databases, optionally create a new database, and choose the name of the subdirectory to install the script under. Clicking Install Now will then install the script and setup the database with the appropr iate items. Some scripts don't need a database, and so the database-related option will be unavailable.

Virtualmin Virtual Server Owners Guide

Introduction

Virtualmin allows you, the domain virtual server account holder, to manage your website files, mailboxes, databases, DNS entries, and install scripts.

Getting Started

Logging in to Virtualmin

Virtualmin is the administrative interface, or control panel, you will use for most of the administrative functions you'd like to accomplish. You can open your account using any browser (modern browsers like Firefox, Safari, and Opera are recommended), by browsing to port 10000 on the server address using the HTTPS protocol.

For example, if your domain were virtualmin.com, you could access it at the URL: https://virtualmin.com:10000

Enter your username and password, as provided by your system administrator.

Navigating Virtualmin

When you login to Virtualmin, you'll see a left-hand menu bar and a right-hand content page, as shown in the diagram below:

image:/images/first-look.png

The left menu contains all of the options available for your domain. Some shown here might not be available in your menu, it depends on the options available for your domain.

The right content page opens with a summary of your virtual server data, such as number of domains, disk usage, mailboxes etc.

Uploading Files

There are several ways to upload content to your Virtualmin account. You can use any of them or all of them, based on your needs and skills.

SSH, SCP and FTP over SSH

The preferred method for sending many files, directories of files, or very large files, is the SSH protocol. SSH is a fast and secure protocol, that allows you to safely login, upload and download files, and manage existing files. SCP is the name for file transfer commands that work using the SSH protocol. Likewise, FTP over SSH (sometimes also called FISH, or SFTP) is a mechanism for providing FTP-like service over a secure link.

There are many graphical and textmode clients for the SSH protocol available for free and commercially.

We'll cover where to find SSH-capable clients for your Operating System, and we'll provide a few examples of using them to manage the files in your Virtualmin account.

Windows SCP Clients

pscp

The best free command line SCP client is called pscp.exe and it can be found at:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

It is related to PuTTY, which is a very nice free SSH client.

After you've placed the pscp.exe file into your system path, using it is quite simple. In a DOS shell, simply enter a command like the following:

C:\> pscp.exe myfile.htm user@domain.tld:/home/user/public_html

Then, enter your password at the prompt, and hit enter. This will copy the file "myfile.htm", located in the current directory, to the /home/user/public_html folder on the Virtualmin server.

Windows graphical FTP clients

Filezilla

A free graphical FTP client that supports FTP over SSH is Filezilla. http://filezilla.sourceforge.net/|Filezilla Home Page.

To Configure Filezilla:

  1. Download and Install Filezilla
  2. Run Filezilla
  3. File -> Site Manager ->
  4. Click "New Site" -> Give it a name such as "example"
  5. In the top right "Host" box fill in "example.com"
  6. In the "Servertype" box choose "SFTP using SSH2"
  7. "Logontype" choose "Normal"
  8. Fill in the "User" and "Password" boxes with the virtual server owner username and password respectively.
  9. In Virtualmin -> Webmin -> Servers -> SSH Server
  10. Access Control -> Only allow users -> add the above virtual server username
  11. Click "Save" -> Click "Apply Changes"

Your admin user will be able to use a graphical FTP style program or Dreamweaver to upload their pages now.

WinSCP

Another good free graphical FTP over SSH option is WinSCP:

http://winscp.net/eng/index.php|WinSCP Home Page

After installation, simply start it up. It will ask for your login information. Enter the details as provided by your system administrator for hostname, username, and password. Then click Login.

Now you'll see a window displaying the files in your Virtualmin account home directory. You can copy files into your public_html directory to make them accessible via the webserver, or into the cgi-bin directory, if the files are executable CGI scripts.

Mac OS X SCP Clients

scp

Mac OS X includes the free OpenSSH SCP client, called simply scp. Usage is just like Linux and UNIX scp clients. Open a Terminal and execute a command like the following:

$ scp myfile.htm user@domain.tld:/home/usr/public_html

After this hit enter, and then enter your password.

Cyberduck

Cyberduck is a popular Mac-native Open Source graphical FTP client that supports SCP, SFTP, FTP over SSL, WebDAV/SSL, and Amazon S3 secure connections.

It also integrates very cleanly with most favorite external OSX text editors, like SubEthaEdit, BBEdit, TextWrangler, Text-Edit Plus, TextMate, mi, Smultron, JeditX, CSSEdit, CotEditor and Tag, skEdit, and PageSpinner.

Download it for free from here:

[http://cyberduck.ch_ Cyberduck Home Page]

Linux SCP Clients

scp

Like Mac OS X, all Linux distributions include a complete SSH implementation, including the scp command. Run the following to copy a file named "myfile.htm" to the domain.tld server using the username "user":

$ scp myfile.htm user@domain.tld:/home/usr/public_html

After this hit enter, and then enter your password.

gftp

gftp is a popular Gnome-based graphical FTP client that also supports scp and FTP over SSH protocol connections.

Download it for free from here:

[http://gftp.seul.org/ gftp Home Page]

Or, preferably, simply install the package provided by your OS vendor. gftp is very popular and is available from the majority of Linux distributions, so you don't need to build it yourself.

WebDAV

FTP

Your FTP client should be configured to connect to yourdomain.tld, or, if DNS has not yet propagated, you could use the IP address or temporary hostname given to you by your administrator (which will be of the form youdomain.hostdomain.tld). You will use the domain account name and password given to you by your system administrator. Note that, by default, only the domain account has FTP access to the website data for your account, and additional users are only email users.

Webmin File Manager Applet

Amazon EC2 Instances

All of our products are available to run instantly on Amazon Web Services EC2 instances. The following documents cover starting instances of Virtualmin or Cloudmin on EC2.

Virtualmin GPL AMI - Virtualmin GPL, or Open Source virtual hosting control panel, running on CentOS 5.

Virtualmin Professional Paid AMI - Virtualmin Professional, our commerical virtual hosting control panel, running on CentOS 5 in an EC2 paid instance.

Cloudmin Paid AMI - Cloudmin, our cloud computing management control panel, running on CentOS 5 in an EC2 paid instance. Cloudmin can manage EC2 instances from within EC2.

Cloudmin Paid AMI

Cloudmin Paid AMI on EC2

Introduction to Paid AMIs

Amazon has recently launched a service called DevPay where commerical software like Virtualmin Pro can be purchased to run on their EC2 service. This means that instead of creating an EC2 instance and installing Cloudmin on it manually, you can instead use an image that has it pre-installed, and available for immediate use. We how have an AMI available that contains Cloudmin 2.6, with support for managing EC2 instances only.

Pricing

Subscribers to the paid AMI for Cloudmin are charged $25 per calendar month. In addition, regular EC2 per-instance-hour and per-megabyte charges apply. And any additional instances you create using it will be charged at normal rates.

Using the paid AMI

To use the Cloudmin paid AMI, the steps to follow are :

  1. Sign up for an Amazon EC2 account on their registration page.
  2. Follow Amazon's getting started instructions to install the needed tools, in particular the Prerequisites, Setting up an Account and Setting up the Tools pages.
  3. Purchase the Cloudmin AMI subscription, which will be charged to your Amazon account.
  4. Once you have the ec2 commands working, use the following command to list available Virtualmin AMIs :
    ec2-describe-images -o 541491349868

    You should see at least one in the available state.

  5. Setup an SSH key with the commands :
    ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair
    chmod 700 ~/.ssh/id_rsa-vgpl-keypair
  6. Start a new instance with the AMI for Virtualmin Pro with the command :
    ec2-run-instances ami-a5bf59cc -k vgpl-keypair

    This will output the new instance ID, which is like i-10a64379

  7. Check its status with the command :
    ec2-describe-instances

    You will need to wait until it is in the running state. You will then be able to see the public hostname, which looks like ec2-72-44-33-55.z-2.compute-1.amazonaws.com .

  8. Open the needed firewall ports with the commands :
    ec2-authorize default -p 22
    ec2-authorize default -p 25
    ec2-authorize default -p 10000
    ec2-authorize default -p 10001
    ec2-authorize default -p 10002
    ec2-authorize default -p 10003
    ec2-authorize default -p 10004
    ec2-authorize default -p 10005
    ec2-authorize default -p 10006
    ec2-authorize default -p 10007
    ec2-authorize default -p 10008
    ec2-authorize default -p 10009
    ec2-authorize default -p 53
  9. Try a test SSH login with the command :
    ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
  10. Connect to Webmin at the URL : https://ec2-WHATEVER.compute-1.amazonaws.com:10000/ . The initial login is root and password is changeme .
  11. Click on the Webmin link in the top-left, open the Webmin category, click on Change Language and Theme, and enter a new password!
  12. If some packages are not up to date, they will be displayed on the System Information page that appears after you login. Click the Install All Updates Now button to have them automatically fetched and installed.

Using Cloudmin on EC2

The version of Cloudmin that the paid AMI installs doesn't have all the features of the full version, such as the ability to manage Xen instances, Linux Vservers and Solaris Zones. Instead, it is limited to creating, managing and protecting EC2 instances.

Before you use Cloudmin to control EC2 instances, you must add at least one account with the following steps :

  1. Open the Amazon EC2 category on the left menu, and click on EC2 Accounts.
  2. Click on Add an EC2 account, and on the form that appears fill in at least your Account ID, Access key ID and Secret access key. If you want to create new AMIs from EC2 instances, fill in the X509 fields too. All of this information can be found at http://aws.amazon.com/ under Your Web Services Account.
  3. Click Create to add the new account. Cloudmin will display an error message if any of the details are invalid.

Cloudmin also needs at least one SSH key to login to EC2 instances it creates. To add one, do the following :

  1. Open the Cloudmin Settings category on the left, and click on SSH Keys.
  2. Click Add a new SSH key to bring up the key creation page.
  3. Assuming that you want to use your existing EC2 SSH key for additional EC2 instances, select the Import existing EC2 key option and choose your key from EC2 from the adjacent menu.
  4. Paste the private key text into the text box below, then click Create.

You can now create your first EC2 instance. Click reload in your browser to refresh the page, then open the New System category on the left and click Create EC2 instance. You should only need to select an AMI and enter a description, then click Create System to kick off the creation of the EC2 instance.

For the full Cloudmin documentation, see the Cloudmin Manual page. Ignore the sections related to Xen, Vservers and Zones, as they are not supported by this paid AMI.

Virtualmin GPL AMI

Virtualmin GPL AMI on EC2

Amazon's Elastic Computing Cloud (EC2) is a commercial service that provides virtual Linux systems running on Amazon's network, for which customers are charged by the hour. One of its useful features is the ability to launch a virtual system using a machine image (AMI) defined by another user, which could contain anything from a basic install of Linux up to a full application stack.

If you have an EC2 account, you can easily launch an image ( ami-7c1df915 ) containing Webmin, Virtualmin, Usermin and all the dependent programs like Apache, MySQL and Postfix, all running on CentOS. This lets you bring up a web hosting server in minutes, and either try out Virtualmin or start using it for real web hosting. The steps to do this are :

  1. Sign up for an Amazon EC2 account on their registration page.
  2. Follow Amazon's getting started instructions to install the needed tools, in particular the Prerequisites, Setting up an Account and Setting up the Tools pages.
  3. Once you have the ec2 commands working, use the following command to list available Virtualmin AMIs :
    ec2-describe-images -o 093590521311

    You should see at least one in the available state.

  4. Setup an SSH key with the commands :
    ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair
    chmod 700 ~/.ssh/id_rsa-vgpl-keypair
  5. Start a new instance with the AMI for Virtualmin GPL with the command :
    ec2-run-instances ami-7c1df915 -k vgpl-keypair

    This will output the new instance ID, with is like i-10a64379

  6. Check its status with the command :
    ec2-describe-instances

    You will need to wait until it is in the running state. You will then be able to see the public hostname, which looks like ec2-72-44-33-55.z-2.compute-1.amazonaws.com .

  7. Open the needed firewall ports with the commands :
    ec2-authorize default -p 22
    ec2-authorize default -p 25
    ec2-authorize default -p 10000
    ec2-authorize default -p 10001
    ec2-authorize default -p 10002
    ec2-authorize default -p 10003
    ec2-authorize default -p 10004
    ec2-authorize default -p 10005
    ec2-authorize default -p 10006
    ec2-authorize default -p 10007
    ec2-authorize default -p 10008
    ec2-authorize default -p 10009
    ec2-authorize default -p 20000
    ec2-authorize default -p 80
    ec2-authorize default -p 443
    ec2-authorize default -p 21
    ec2-authorize default -p 20
    ec2-authorize default -p 110
    ec2-authorize default -p 143
    ec2-authorize default -p 53
    ec2-authorize default -p 53 -P udp
  8. Try a test SSH login with the command :
    ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
  9. Connect to Webmin at the URL : https://ec2-WHATEVER.compute-1.amazonaws.com:10000/ . The initial login is root and password is changeme .
  10. Click on the Webmin link in the top-left, open the Webmin category, click on Change Language and Theme, and enter a new password!
  11. To ensure that all packages are up to date, click on System Information at the bottom of the left frame. If you are prompted to install any packages on the information page that appears on the right, do so.
  12. Click back on the Virtualmin link on the top-left, and click on Create Virtual Server to create your first domain.

Virtualmin EC2 Image in Europe

EC2 now has a separate European region, which has it's own set of machines and AMIs. To launch the Virtualmin image in Europe, follow the instructions above but use the AMI ami-dc1a32a8 instead.

Also, you will need to set the EC2_URL environment variable before using the command-line tools, with a statement like :

export EC2_URL=https://eu-west-1.ec2.amazonaws.com

Virtualmin GPL Debian Etch Image

An EC2 image now exists for Virtualmin GPL on Debian 4.0 (Etch). The instructions for starting this are exactly the same as above, but the image ID is ami-dd13f7b4 . So the command to start it would be :

ec2-run-instances ami-dd13f7b4 -k vgpl-keypair

Virtualmin Professional Paid AMI

Virtualmin Pro Paid AMI on EC2

Introduction to Paid AMIs

Amazon has recently launched a service called DevPay where commerical software like Virtualmin Pro can be purchased to run on their EC2 service. This means that instead of creating an EC2 instance and installing Virtualmin Pro on it manually, you can instead use an image that has it pre-installed, and available for immediate use. We how have an AMI available that contains Virtualmin Pro 3.56 and the full stack of related servers, like Apache, Postfix and MySQL.

Pricing

The pricing per EC2 instance using the Virtualmin Pro AMI is based on the regular EC2 per-hour price, with an additional fee to cover the Virtualmin license. This works out to about $20-25 per month. The exact fees for the different instance sizes are :

Price Size
$0.14 / hour Small instance
$0.45 / hour Large instance
$0.86 / hour Extra-large instance

For more details on the specs of different instance sizes, see this page from Amazon. For most people, the small instance is the most cost-effective, as you can split your domains across several of them.

Using the paid AMI

To use this new paid AMI, the steps to follow are :

  1. Sign up for an Amazon EC2 account on their registration page.
  2. Follow Amazon's getting started instructions to install the needed tools, in particular the Prerequisites, Setting up an Account and Setting up the Tools pages.
  3. Purchase the Virtualmin Pro AMI subscription, which will be charged to your Amazon account.
  4. Once you have the ec2 commands working, use the following command to list available Virtualmin AMIs :
    ec2-describe-images -o 541491349868

    You should see at least one in the available state.

  5. Setup an SSH key with the commands :
    ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair
    chmod 700 ~/.ssh/id_rsa-vgpl-keypair
  6. Start a new instance with the AMI for Virtualmin Pro with the command :
    ec2-run-instances ami-6d4ca904 -k vgpl-keypair

    This will output the new instance ID, which is like i-10a64379

  7. Check its status with the command :
    ec2-describe-instances

    You will need to wait until it is in the running state. You will then be able to see the public hostname, which looks like ec2-72-44-33-55.z-2.compute-1.amazonaws.com .

  8. Open the needed firewall ports with the commands :
    ec2-authorize default -p 22
    ec2-authorize default -p 25
    ec2-authorize default -p 10000
    ec2-authorize default -p 10001
    ec2-authorize default -p 10002
    ec2-authorize default -p 10003
    ec2-authorize default -p 10004
    ec2-authorize default -p 10005
    ec2-authorize default -p 10006
    ec2-authorize default -p 10007
    ec2-authorize default -p 10008
    ec2-authorize default -p 10009
    ec2-authorize default -p 20000
    ec2-authorize default -p 80
    ec2-authorize default -p 443
    ec2-authorize default -p 21
    ec2-authorize default -p 20
    ec2-authorize default -p 110
    ec2-authorize default -p 143
    ec2-authorize default -p 53
    ec2-authorize default -p 53 -P udp
  9. Try a test SSH login with the command :
    ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
  10. Connect to Webmin at the URL : http://ec2-WHATEVER.compute-1.amazonaws.com:10000/ . The initial login is root and password is changeme .
  11. Click on the Webmin link in the top-left, open the Webmin category, click on Change Language and Theme, and enter a new password!
  12. If some packages are not up to date, they will be displayed on the System Information page that appears after you login. Click the Install All Updates Now button to have them automatically fetched and installed.
  13. Click back on the Virtualmin link on the top-left, and click on Create Virtual Server to create your first domain.

Using Virtualmin Pro on in Europe

A European EC2 paid AMI also exists, with ID ami-3dc4ef49. You can create an EC2 instance from this by following the same instructions above, but using this AMI instead. Also, you will need to pass the flag -U https://eu-west-1.ec2.amazonaws.com to the various EC2 commands, to have them connect to Amazon's European servers.

Using Virtualmin Pro on EC2

Virtualmin on EC2 works exactly the same as it would on a regular system. For full documentation, see : http://www.virtualmin.com/documentation/

Cloudmin Documentation

First Things First

How to use the documentation - Start here. It provides a brief (about one page) overview of the conventions and organization of the Cloudmin documentation.

Getting Started

Installation Guides - Automatic and manual installation procedures for Cloudmin.

Upgrading Cloudmin Software - Upgrading Cloudmin and related software from within Cloudmin and from the command line.

Getting Started With Cloudmin - Machine and network configuration needed to run Cloudmin.

Creating IP Pools - Defining global IP ranges for assignment to virtual systems.

Replication - Setting up backup Cloudmin masters.

About Cloudmin - Basic introduction and feature list.

Cloudmin Glossary - Terms used in Cloudmin and its documentation.

Cloudmin GPL - Installing and using the free Xen-only version of Cloudmin.

Cloudmin Roadmap - Future plans for Cloudmin.

Virtualization

Introduction to Virtualization Concepts - Introductory coverage of virtualization concepts, types of virtualization, and how Cloudmin interacts with virtualized cloud servers.

Setting Up Linux Open Source Xen Virtualization - Using Cloudmin with Linux open source Xen virtualized systems.

Setting Up Citrix Xen Virtualization - Using Cloudmin with Citrix Xen virtualized systems.

Setting Up Linux OpenVZ Virtualization - Using Cloudmin with Linux OpenVZ virtual containers.

Setting Up KVM Virtualization - Using Cloudmin with Linux KVM instances.

Setting Up Solaris/OpenSolaris Zones Virtualization - Using Cloudmin with Solaris/OpenSolaris Zones.

Setting Up Linux VServer Virtualization - Using Cloudmin with Linux vserver virtual containers.

Setting Up LVM for Xen or KVM - How to store Xen or KVM disk images in LVM logical volumes

Multiple Interfaces for Xen - How to connect multiple host system interfaces to Xen systems

Xen Kernels - Booting a kernel from the virtual system with Xen

Empty Systems - Installing any operating system into an empty Xen or KVM instance

Location Groups - Simplifying host system allocation with location groups


Virtual Machine Management

Using Cloudmin - An introduction to various tasks in Cloudmin.

Downloading System Images - How to download Virtual Machine images for products such as Xen, VServers, and Zones.

Registering Host Systems - Preparing your server for virtualization.

Virtualmin Licenses - Setting up your Virtualmin licenses in Cloudmin.

Creating an Open Source Xen Virtual Machine - How to create a new Xen Virtual Machine.

Creating an Citrix Xen Virtual Machine - How to create a new Citrix Xen VM.

Creating a KVM Virtual Machine - How to create a new KVM Virtual Machine.

Managing Virtual Domains - Using the Cloudmin interface to create, find, and manage domains on your Virtual Machines.

Replicating Virtual Domains - Using Cloudmin to replicate Virtualmin domains and settings between systems.

Creating a VServers Virtual Machine - How to create a VServers Virtual Machine.

Creating a Solaris Zones Virtual Machine - How to create a Solaris Zones Virtual Machine.

Making Your Own Images - How to create your own images for Virtual Server products such as Xen, VServers, and Zones.

Cloning Systems - How to easily duplicate an existing virtual system.

Backup and Restore - Backing up Cloudmin systems on schedule.

Automatic Failovers - Creating failover groups to handle host system failures.

Cloudmin API and Development

Command Line API - Using the command line tools for managing Cloudmin instances.

Remote API - Using the remote API for managing Cloudmin instances.

Cloudmin API and Development FAQ - Have questions about API usage and Cloudmin development?

Amazon EC2

Adding an EC2 Account - Information on Amazon's EC2, and how to setup an EC2 account.

Creating an EC2 Virtual Machine - How to create an Amazon EC2 Virtual Machine.

Creating an EC2 Image - How to create an Amazon EC2 Machine Image (AMI).

EC2 Security Groups - Creating and managing EC2 firewall security groups.

EC2 Static IP Addresses - Creating and assigning EC2 static addresses.

EC2 Volumes - Creating and assigning EC2 elastic block volumes.


System Resources

Managing Virtual Disks - Creating additional disks for Xen and KVM systems.

Managing RAM Limits - Setting limits on RAM usage.

Managing CPU Limits - Setting limits on CPU usage and virtual CPU cores.

Managing Bandwidth Limits - Restricting total network traffic and bandwidth.

Managing Network Interfaces - Adding and changing IP addresses.

System Monitoring and Alerts - Setting up email notifications when systems go down or exceed thresholds.

System Owners and Plans

Account Plans - Defining limits on resource usage and functions.

System Owners - Accounts with limited access to Cloudmin.

Usage Accounting - Tracking total resource use by systems and owners.


Contributed Documentation

Running Windows under Xen - How to install Windows into a Cloudmin-managed Xen instance, by Scott Grayban.

Account Plans

Introduction to Plans

In Cloudmin, an account plan is a set of restrictions that can be applied to a system owner. Plans can limit the following :

  • Number of systems the owner can create
  • Total RAM assigned to virtual systems
  • Total disk space assigned
  • Total CPU assigned
  • Number of IP addresses assigned to virtual systems
  • Disk space used for backups created by the system owner
  • Combined bandwidth for virtual systems
  • Allowed actions, such as shutting down, creating systems and managing virtual disks
  • Allowed host systems
  • System images the owner can use

All limits apply to the total usage of all systems owned by the user the plan is applied to.

Creating and Managing Plans

Cloudmin comes with one default plan that is created when installed. To add your own plans, do the following :

  1. Open the Cloudmin Settings category on the left menu, and click on Account Plans.
  2. Click on Add a new account plan , and fill in the Plan name field.
  3. Enter any other limits you want, such as on disk space or RAM.
  4. If needed, take away some actions in the Plan restrictions section. Those selected by default are generally safe and reasonable.
  5. In the Host system restrictions section, choose hosts that owners on this plan should be able to use for new systems. You can also select the method via which a host is chosen.
  6. To prevent use of some images (such as those containing commerical software), limit the selection in the System images section.
  7. Click the Create button.

To edit a plan after it is created, go to the Account Plans page and click on its name. Any changes in limits or restrictions will be immediately applied to system owners on the plan.

To delete a plan, check the box next to its name in the Account Plans list, then hit the Delete Selected Plans button.

Applying Plans to Owners

Once a plan has been created, you can apply it to an owner as follows :

  1. Go to Cloudmin Settings -> System Owners, and click on an owner.
  2. Under Limits and restrictions, select your new plan.
  3. Make sure that other settings are set to From plan, so that the owner's individual limits will not be used.
  4. Click the Save button.

Adding an EC2 Account

EC2 is different from other virtualization systems supported by Cloudmin, as it is a hosted service run by Amazon on their machines. They charge by the hour of machine time, and also for storage of any machine images that you create and host on their S3 service.

Cloudmin can manage virtual systems running under EC2 in almost exactly the same way as it does for other virtualized systems. The biggest difference is that they cannot be shut down without losing the contents of the system, which makes them a little risky for web hosting, as Amazon gives no guarantees of the stability of EC2 instances. Fortunately, Virtualmin makes it easy to backup hosted domains to Amazon's S3 service, which is fast and cheap when accessed from EC2 instances.

Signing Up With Amazon

The first step in the process of using EC2 is to sign up for an account at Amazon's website, http://aws.amazon.com/ . You will need to provide credit card details for billing. If you already have an Amazon account, adding the EC2 service to it is simple.

Once you have an account, you will need to find out the account number, access key and secret key. This can be done by :

  1. Go to http://aws.amazon.com/ , and mouse over the Your Web Services Account button on the right. In the window that pops up, click on AWS Access Identifiers.
  2. The access key is shown under Your Access Key ID . The secret is shown under Your Secret Access Key, when you click the Show link.
  3. Mouse over Your Web Services Account again, and click on Account Activity.
  4. At the top of the page is your Account Number .

Adding Your Account to Cloudmin

Once you have found your EC2 account number, access key and secret key, the account can be registered with Cloudmin. The steps to do this are :

  1. On the left menu, open the Cloudmin Settings section and click on EC2 Accounts.
  2. Click on the Add an EC2 account link.
  3. On the page that appears, enter a short name for this account in the Account description field, such as Bob's EC2 service.
  4. Fill in the Account ID, Access key ID and Secret access key fields with the account details retrieved from Amazon.
  5. Click the Create button.

Assuming that the account details are correct, you will be returned to the list of registered accounts. At the same time, Cloudmin will contact the Virtualmin webserver to grant your account access to system images containing Virtualmin Pro.

Creating an SSH Key

Before you can create any EC2 instances, you must create and register at least one SSH key with EC2. Fortunately, Cloudmin makes this easy - the steps to follow are :

  1. Open the Cloudmin Settings section on the left menu, and click on SSH Keys.
  2. Click on Add a new SSH key, which will open the key creation form.
  3. In the Key description field, enter something like Amazon EC2 key.
  4. Select the Generate new EC2 key option.
  5. Click Create.

Assuming that Cloudmin is able to contact the EC2 servers successfully, a new key will be created and registered. When an EC2 instance is created you must select an SSH key that will be used to initially login to it, and this key must be one generated using this process. Existing keys imported from some other source cannot be used.

Automatic Failovers

Automatic Host Failovers in Cloudmin

Cloudmin's automatic failover feature provides protection against host system failures, by moving virtual systems off a down host to a new host with shared storage. The running state (memory contents and network connections) of virtual systems will be lost in this case, but they will be re-started on the new host with minimal interruption.

For failovers to work, your host systems must share the storage location for virtual system disk images or filesystems. This can be done via NFS, Cluster LVM, iSCSI, or other network filesystem technologies. Cloudmin's failover feature does not yet include automatic replication of disk images between host systems, and cannot setup shared storage for you.

Currently automatic failovers are supported only for Xen, OpenVZ and KVM virtual systems.

Failover Groups

A failover group is a collection of host systems that support some virtualization type, and share storage used for virtual systems. Some or all systems running on those hosts will be failed over to another host in the group if one goes down, assuming that there is enough free RAM available. Groups can contain an explicit list of hosts, members of some location group, or hosts in a Cloudmin system group.

The steps to create a new failover group are :

  1. Login to Cloudmin as root, and go to Host Systems -> Host Failover Groups
  2. Click the Add a new failover group link
  3. Select a virtualization type from the Virtual system type menu.
  4. Enter a name for the group in the Group description field.
  5. If you want Cloudmin to automatically perform failovers, set the Failover group enabled? to automatic mode. Otherwise you can select manual mode to trigger failovers manually when you detect a host system has gone down.
  6. In the Host systems in failover group section, select the hosts that will be part of this group.
  7. To limit automatic failovers to only certain virtual systems, select them in the Virtual systems to failover section. You might want to do this for only important systems, or those on shared storage.
  8. Click the Create button.

Once a group has been created, it can be edited or deleted at any time by clicking on its description on the *Host Failover Groups * page.

Failover Notification

When automatic failovers are enabled, they will be triggered by Cloudmin's regular status collection process. When it detects that a virtual system's host is down, it will wait for the Host downtime timeout set on the failover group page, and then attempt to move the virtual system to a new host.

Upon success or failure, email will be sent to the master administrator and possibly the owner(s) of a virtual system. If the virtual system was running before its old host failure, it will be re-started on the new host after the failover completes.

The move can fail for several reasons :

  • No hosts in the failover group share the storage for this virtual system.
  • No hosts have enough free RAM
  • All other hosts in the group are down
  • Any error occurred copying configuration files to the new host

Triggering a Manual Failover

If you have set a failover group to manual mode, Cloudmin will not automatically move virtual systems off down hosts in the group. However, you can force a failover at System Operations -> Force Failover. On this page you can optionally select a specific new host system, and decide if the virtual system should be started up on the new host or not.

A manual failover can also be done using the failover-system API command.

Backup and Restore

Introduction to Cloudmin Backups

Cloudmin allows the master administrator and system owners to create backups of virtual systems running under Xen, OpenVZ, Vservers or Solaris Zones. This provides protection against accidental deletion of files within the filesystem, for example by an accidental rm * command.

Backups can be either run manually or on a regular schedule, such as once per day. When a backup is taken the virtual system can be either shut down to ensure a consistent filesystem state, or left running to avoid downtime.

What is and is not Backed Up

Currently, backups only include the contents of the virtual system's filesystem or disk images. For Xen systems the backup contains a compressed copy of all virtual disks, while for other virtualization types it is just a TAR file of the filesystem.

When backing up a running Xen system using LVM logical volumes to store disk images, LVM snapshots are used to take an instantaneous copy of the filesystem while it is copied. Each will consume 10% of the space in the volume group as the underlying disk images, so make sure you leave some LVM space free.

Other configuration files and data are not included - so if a virtual system is completely destroyed, it must be first re-created before the backup can be restored.

Backup Destinations

Cloudmin can backup virtual systems to a variety of different destinations - via SCP, FTP or to any system it manages. In a typical Cloudmin setup a single system with plenty of disk space is chosen as backup destination, perhaps the master system itself. Backups are taken on the host systems and then transferred to this backup machine. Alternately, you can choose to store backups on the hosts themselves, to avoid the need to transfer large backup files over the network.

Each host system defines a default backup destination for its virtual systems. You can set this as follows :

  • Login to Cloudmin, open the Host Systems category and click on the link for your virtualization type, such as Xen Host Systems.
  • Click on the first of your hosts, and open the Default backup destination section.
  • Select a destination type and fill in the fields next to it - for example, in you have a dedicated backup system you could select Directory on system, choose it from the menu, and enter a path like /backup.
  • Click the Save button, then repeat the same steps for other host systems.

When a backup is made it will be saved to the specified directory in a file whose name is that of the virtual system with .tar.gz appended. Each subsequent backup of the same system to the same destination will overwrite that file.

Creating a Scheduled Backup

Once a default destination has been set, you can schedule a backup like so :

  • Open the Backup and Restore category on the left menu and click on System Backups.
  • Click the Add a new system backup link.
  • From the Systems to backup list select the virtual systems you want to include.
  • To have them shut down during the backup process, change Shut down systems? to Yes.
  • In the Backup destination, you can typically leave Default destination for host system selected unless you want the backup to be sent to an FTP or SSH server outside of Cloudmin's control.
  • Change Scheduled backup enabled? to Yes, and select a schedule in the When to backup field.
  • To be notified on backup failures, enter your address in the Email results to field.
  • Click the Create button.

It is possible to leave Scheduled backup enabled? set to No if you just want to define a backup that will always be run manually.

After a backup has been defined, you can edit or remove it by clicking on its entry in the System Backups list.

Running a Backup Manually

To kick off a backup, just click on it in the System Backups list and then hit the Backup Now button. Progress messages will be displayed as it runs, and a final summary of systems completed and backup sizes when it finishes. Depending on the sizes of the systems being backed up, it may take minutes or hours.

Testing a scheduled backup after creating it is strongly recommended. Also, you should create, backup and restore a test system that uses the same configuration and destination as your production systems to ensure that all steps in the process are working properly.

Backup Logs and Restoring Backups

Cloudmin logs all backups it performs, including their final status, systems included, disk used and possibly the complete progress report. To view logs, go to Backup and Restore -> Backup Logs, and enter a hostname or destination path into the Find backup logs box, then click Search.

The simplest way to restore a backup is to click on its destination in the search results, which will open a restore form. You can also restore some or all systems from a scheduled backup as follows :

  • Go to Backup and Restore -> System Backups, and click on a backup.
  • Click the Restore button.
  • Select the systems to restore - typically you only want one, instead of everything that was included.
  • Click Restore Now.

Cloning Systems

Introduction to Cloning

A clone is a copy of a virtual system that has the same disk contents, accounts, root password and number of network interfaces as the original. However, it is assigned a new hostname, IP address(es) and description.

Creating a clone is easier than imaging a system and then creating a new system from it, as it is done in a single operation. Cloning is also available to system owners, subject to limits on disk, RAM and CPU use, and assuming that the owner is allowed to create new systems at all.

Virtual systems using Xen, KVM, OpenVZ, Vservers and Citrix Xen can be cloned in Cloudmin versions 4.5 and later. The process is the same regardless of the virtual system type.

Cloning a System

The steps to follow to clone an existing system are :

  1. Select it from the left menu, then go to System Operations -> Clone System
  2. Enter a new system name into the New hostname prefix field. This typically only has to be a prefix, as the domain will be automatically appended.
  3. Enter a description for the new system.
  4. By default, Cloudmin will allocate new IP addresses for the clone in the same way that it does allocation for any new system. However, you can alternatively select Entered below in the IP addresses for clone and enter an address for each interface on the new system.
  5. Click the Create Clone button, and wait for the process to complete.

Cloning is generally faster than creating a new system, as there are fewer steps involved. However, if the system being cloned has large disks, it will take proportionally longer.

Cloning will be disallowed if the host system does not have enough free RAM or disk space, or if your usage is too close to the limits set in your plan.

Cloudmin GPL

Introduction to Cloudmin GPL

The GPL version of Cloudmin is a designed to manage Xen instances on only a single host system, rather than supporting multiple hosts and virtualization types as in the full (Pro) version. It lets users try out Cloudmin and virtualization concepts without having to purchase the full package.

Installing Cloudmin GPL

Cloudmin's installer can be used on CentOS, Redhat Enterprise, Debian and Ubuntu systems. It will both install Cloudmin and setup the system as a Xen host, by installing a Xen-capable kernel and associated tools.

You can download the install script for CentOS and Redhat from : http://cloudmin.virtualmin.com/gpl/scripts/cloudmin-gpl-redhat-install.sh

The install script for Debian and Ubuntu can be downloaded from : http://cloudmin.virtualmin.com/gpl/scripts/cloudmin-gpl-debian-install.sh

In either case, it needs to be copied to the system you plan to run Cloudmin on and then executed with a command like :

sh cloudmin-gpl-redhat-install.sh

Cloudmin can co-exist with Webmin or Virtualmin GPL on the same system. The installer uses YUM or APT to add the required packages, some from our repository and some from the repository provided by your distribution vendor.

Once installation is complete, you will need to reboot your system. Then go to https://yoursystem:10000 in your browser , download some system images, and type creating a Xen instance.

Differences between Cloudmin GPL and Pro

Features missing from the GPL version of Cloudmin include :

  1. Support for Xen, OpenVZ, KVM, VServers, Solaris Zones virtual systems.
  2. Can create and manage EC2 accounts, instances, images, addresses and storage volumes.
  3. The ability to manage multiple host systems (each of which can run multiple virtual systems) from a single interface.
  4. Support for managing multiple non-virtual systems, such as machines running Virtualmin.
  5. Live replication of settings from a Cloudmin master to one or more backup systems.
  6. Multiple locations for storing system images, to avoid repeated copies to distant datacenters.

Upgrading from Cloudmin GPL to Pro

Cloudmin can be upgraded to the Pro version without effecting any existing settings as follows :

  1. Go to the Virtualmin shop at http://www.virtualmin.com/catalog/43 and purchase a Cloudmin licence.
  2. Go to http://www.virtualmin.com/serial and note down your serial number and licence key. There is no need to download the new install script though.
  3. Login to your Cloudmin GPL install, and go to Cloudmin Settings -> Upgrade Cloudmin.
  4. Enter your new serial number and licence key, then click the Upgrade button.

The full version packages should then be downloaded and installed, and your APT or YUM configuration updated to use the correct repositories.

Cloudmin Glossary

Cloudmin and its documentation uses the following terms to refer to different types of systems and other objects :

  • System
    A machine with its own IP addresses, filesystems and accounts. This can either be an actual physical computer, or a virtual machine running under some virtualization technology such as Xen, OpenVZ, EC2, Vservers or Solaris Zones. Systems are the primary object managed by Cloudmin.

  • Virtual System
    A system that runs under some virtualization type, such as Xen or OpenVZ.

  • Real System or Physical System
    An actual computer with its own hardware.

  • Host System
    A real machine that can host virtual systems of some type(s).

  • Cloudmin Master
    The system on which the Cloudmin software is installed and runs. This may also be a host system, or in some rare cases a virtual system that it also controls. System images are also primarily stored here.

  • Server
    A process that provides some service, such as Apache or BIND.

  • Virtual Server
    A combination of services provided by several servers, typically associated with a domain name. Virtual servers are the object primarily managed by Virtualmin.

  • System Image
    A template from which virtual systems can be created, containing the contents of its filesystem.

  • System Owner
    An additional login to Cloudmin will access to a subset of systems and functions.

  • Account Plan
    A set of limits on disk, CPU, RAM and network use that can be applied to a system owner.

Command Line API

Explains how to use the command-line scripts included with Cloudmin to manage users, aliases, servers, databases and resellers.

Introduction

Cloudmin comes a script named cloudmin that can be run from the Unix shell to perform actions that are usually done from the web interface. In fact, almost all actions that can be done in a browser can also be done from the command line, or from shell scripts. This allows system, disk, image and owner creation and management to be done in a more automated function, such as from programs or scripts of your own creation.

The first parameter to the cloudmin command is the operation you want to perform, such as create-system. Depending on the operation, additional parameters may be needed, such as the name of the domain to create, password and so on. In almost all cases the parameters are given like --host myvps.

The cloudmin command must be run as root, as it needs access to system configuration files to create systems, copy files and so on. If you want to create and manage systems programatically as a different user (such as from your own CGI scripts), see the documentation on the Cloudmin Remote API instead.

All of the operations that make changes to the system output messages indicating their success or failure. Their exit status can also be checked to determine success - an exit status of 0 indicates that everything went OK, while a non-zero status indicates some problem.

All operations can be called with the --help command-line parameter to have them output details of the required and allowed parameters. Alternately, you can run cloudmin help to get a list of all available commands, or cloudmin help command to get information on what a particular command does.

Command Categories

Creating IP Pools

If you plan to have more that one host machine for virtual systems (like Xen instances or OpenVZ containers), we recommend defining the IP allocation range for those systems in a single place. This way the range only has to be created once, and can be changed in a single place.

The steps to create a common IP range are :

  1. Open the Host Systems category on the left menu, and click on IP Addresses.
  2. Go to the Common IP pools tab.
  3. In the first empty row, enter starting and ending IP addresses for your allocation range, such as 192.168.1.1 and 192.168.1.200.
  4. Enter a netwask for the range, like 255.255.255.0.
  5. If you have one, enter a description for this IP range.
  6. Click the Save button.
  7. To add another range, repeat the steps above.

Once the range has been created, it will be available when creating or editing host systems.

Creating a Citrix Xen Virtual Machine

Creation From a Cloudmin System Image

Once you have at least one system setup to host Citrix Xen instances and registered with Cloudmin, and have downloaded at least one Citrix Xen system image, you can create your first virtual system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create Citrix Xen VM. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the Xen host selected.
  3. In the System description field enter a short description, like Foo Corp's webserver.
  4. From the Initial system image menu, select the OS image to install. We provide images for CentOS and Debian.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. In the Webmin installation mode section you do not have to select anything if you have chosen to use an image with Virtualmin, as Webmin will be installed automatically.
  7. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  8. From the Citrix Xen hosting system menu, select the host on which this Xen system should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  9. If the new Xen system with run Virtualmin, you should increase the Memory allocated to instance field to 512 MB, or even more if the host system has enough RAM.
  10. By default, Citrix Xen VMs created from images with Virtualmin Pro have 2 GB filesystems, while those without it get 1 GB. In both cases, there is only about 500 MB free. To increase the size of the instance's filesystem, use the Disk space allocated to instance field.
  11. If the image contains Virtualmin Pro, you will need to select a license for it using the License for Virtualmin from image field. See the Virtualmin Licenses page for more details on aquiring and registering licenses, so that they can be easily allocated at system creation time.
  12. Finally, click the Create System button to start the creation process.

Because Xen instance creation involves the copying and uncompression of large filesystem images, the creation process may take up to 5 minutes. However, Cloudmin will display each step in the process as it is run, including copying the image file, un-compressing it, modifying the Xen filesystem to set the root password and IP address, and finally starting up the instance.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to rebooting, shut it down, start it up, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this Xen VM2, it can be completely removed with the Delete System link on the left menu.

Creation From a Xen Template

Citrix Xen also allows a virtual system to be created empty, and setup to boot the installer for some Linux distribution or other operating system. This allows you to create a new VM into which you install Debian, CentOS or even Windows. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create Citrix Xen VM. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the Xen host selected.
  3. In the System description field enter a short description, like New CentOS install.
  4. From the Initial system image menu, select From Citrix Xen template.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. From the Citrix Xen hosting system menu, select the host on which this Xen system should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  7. If the OS being installed needs more than the default of 128 MB of rAM, increase the Memory allocated to instance field.
  8. From the Citrix Xen template menu select a template for the OS you plan to install, such as Debian Lenny 5.0.
  9. In the Repository URL for template field enter the base URL appropriate for the selected Linux distribution. For Debian 5.0 this would be http://ftp.debian.org/ , while for CentOS 5 it would be like http://mirror.centos.org/centos-5/5.4/os/i386/ .
  10. Click the Create System button to start the creation process.
  11. Creation will be relatively quick, as only the installer for the new VM gets set up. Cloudmin will report the status as Ping failed, which is expected as networking has not been enabled yet.
  12. Open the System State menu category and then click on Graphical Console. This will allow you to complete the install process as though you were accessing a physical system at the console. Be sure to enter the same root password, hostname and IP address that you chose above, or else Cloudmin will be unable to manage the new system.

    When it comes to disk partitioning, we recommend creating a single partition that does not use LVM or RAID - otherwise Cloudmin will be unable to access files in the VM when it is shut down. If you must use swap, put the swap partition at the start of the disk so that the partition with the filesystem on it can be expanded later.

  13. Once installation is complete and the virtual system has been rebooted, click Refresh Status on the left menu - if all went well the status should show up as SSH.

Creating a KVM Virtual Machine

Once you have at least one system setup to host KVM instances and registered with Cloudmin, and have downloaded at least one KVM system image, you can create your first virtual system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create KVM instance. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the KVM host selected.
  3. In the System description field enter a short description, like Foo Corp's webserver.
  4. From the Initial system image menu, select the OS image to install.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. In the Webmin installation mode section you do not have to select anything if you have chosen to use an image with Virtualmin, as Webmin will be installed automatically.
  7. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  8. From the KVM hosting system menu, select the host on which this KVM system should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  9. If the new KVM system with run Virtualmin, you should increase the Memory allocated to instance field to 512 MB, or even more if the host system has enough RAM.
  10. By default, KVM instances created from images with Virtualmin Pro have 2 GB filesystems, while those without it get 1 GB. In both cases, there is only about 500 MB free. To increase the size of the instance's filesystem, use the Disk space allocated to instance field.
  11. If the image contains Virtualmin Pro, you will need to select a license for it using the License for Virtualmin from image field. See the Virtualmin Licenses page for more details on aquiring and registering licenses, so that they can be easily allocated at system creation time.
  12. Finally, click the Create System button to start the creation process.

Because KVM instance creation involves the copying and uncompression of large filesystem images, the creation process may take 5 to 10 minutes. However, Cloudmin will display each step in the process as it is run, including copying the image file, un-compressing it, modifying the KVM filesystem to set the root password and IP address, and finally starting up the instance.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to rebooting, shut it down, start it up, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this KVM instance, it can be completely removed with the Delete System link on the left menu.

Creating a Solaris Zones Virtual Machine

Once you have at least one system setup to host Solaris Zones and registered with Cloudmin, you can create your first virtual system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create Solaris Zone. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the Zones host selected.
  3. In the System description field enter a short description, like Foo Corp's webserver.
  4. From the Initial system image menu, select the OS image to install. Or you can select None - base OS only, which tells Cloudmin that the zone should be created by copying packages from the host system. If you do use an image, make sure you select one of the same architecture (X86 or Sparc) as the host system.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. In the Webmin installation mode section you do not have to select anything if you have chosen to use an image with Virtualmin, as Webmin will be installed automatically.
  7. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  8. From the Zones hosting system menu, select the host on which this zone should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  9. Finally, click the Create System button to start the creation process.

If you chose to create the zone from an image, the process will take 5 to 10 minutes, as the image needs to be transferred from the Cloudmin master and un-compressed on the host system. If you selected the base OS option it will take longer, as all packages that need to be copied from the host system. Either way, Cloudmin will display each step in the process as it is run, including copying the image file, un-compressing it, modifying the zones's filesystem to set the root password and IP address, and finally starting up the instance.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to rebooting, shut it down, start it up, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this zone, it can be completely removed with the Delete System link on the left menu.

Creating a VServers Virtual Machine

Once you have at least one system setup to host Linux VServer instances and registered with Cloudmin, you can create your first virtual system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create VServer. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the VServer host selected.
  3. In the System description field enter a short description, like Foo Corp's webserver.
  4. From the Initial system image menu, select the OS image to install. Or you can select None - base OS only, which tells Cloudmin that the VServer should be created by downloading and installing packages for the host system's Linux distribution.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. In the Webmin installation mode section you do not have to select anything if you have chosen to use an image with Virtualmin, as Webmin will be installed automatically.
  7. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  8. From the VServer hosting system menu, select the host on which this VServer should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  9. Finally, click the Create System button to start the creation process.

If you chose to create the VServer from an image, the process will take 5 to 10 minutes, as the image needs to be transferred from the Cloudmin master and un-compressed on the host system. If you selected the base OS option it will take longer, as all packages that need to be installed will be downloaded from the appropriate Linux distribution repository. Either way, Cloudmin will display each step in the process as it is run, including copying the image file, un-compressing it, modifying the VServer's filesystem to set the root password and IP address, and finally starting up the instance.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to rebooting, shut it down, start it up, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this VServer instance, it can be completely removed with the Delete System link on the left menu.

Creating a Xen Virtual Machine

Once you have at least one system setup to host Xen instances and registered with Cloudmin, and have downloaded at least one Xen system image, you can create your first virtual system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create Xen instance. This will open the Create New System page.
  2. In the System hostname field, enter a short hostname for the new instance. This does not need to include a domain name - it will be appended automatically based on the Xen host selected.
  3. In the System description field enter a short description, like Foo Corp's webserver.
  4. From the Initial system image menu, select the OS image to install. We recommend CentOS 5 with Virtualmin Pro.
  5. In the Root login mode section, select Using password and enter the root password to set for the new system into the adjacent field.
  6. In the Webmin installation mode section you do not have to select anything if you have chosen to use an image with Virtualmin, as Webmin will be installed automatically.
  7. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  8. From the Xen hosting system menu, select the host on which this Xen system should be created. It is generally a good idea to spread your instances across hosts to avoid putting too much load on a single system.
  9. If the new Xen system with run Virtualmin, you should increase the Memory allocated to instance field to 512 MB, or even more if the host system has enough RAM.
  10. By default, Xen instances created from images with Virtualmin Pro have 2 GB filesystems, while those without it get 1 GB. In both cases, there is only about 500 MB free. To increase the size of the instance's filesystem, use the Disk space allocated to instance field.
  11. If the image contains Virtualmin Pro, you will need to select a license for it using the License for Virtualmin from image field. See the Virtualmin Licenses page for more details on aquiring and registering licenses, so that they can be easily allocated at system creation time.
  12. Finally, click the Create System button to start the creation process.

Because Xen instance creation involves the copying and uncompression of large filesystem images, the creation process may take 5 to 10 minutes. However, Cloudmin will display each step in the process as it is run, including copying the image file, un-compressing it, modifying the Xen filesystem to set the root password and IP address, and finally starting up the instance.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to rebooting, shut it down, start it up, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this Xen instance, it can be completely removed with the Delete System link on the left menu.

Creating an EC2 Image

Introduction to EC2 Images

Unlike other virtual system types, EC2 images (called AMIs or Amazon Machine Images) are not stored on your Cloudmin master system. Instead they are stored as files inside Amazon's S3 storage service, and can be selected when creating a virtual system on EC2.

Each image has a unique ID, like ami-7c1df915, and a manifest path in S3 like centos-virtualmin-gpl-3.63/image.manifest.xml . An image can be either made available to everyone, or limited to certain EC2 accounts. Images can also be associated with production codes, indicating that customers must pay to use them.

Creating an EC2 Image

An image is created from a virtual system running on Amazon's EC2 service. The steps to make an image are :

  1. Select your EC2 system from Cloudmin's left menu, then go to System Operations -> Create EC2 Image.
  2. Enter a unique directory name for the image in S3 in the S3 bucket for image field. This should typically contain the operating system, version and purpose, such as //centos-5.3-webserver// .
  3. If you have multiple EC2 accounts, select the one who will own this image from the Save under S3 account menu.
  4. The size of an image determines the filesystem size of virtual systems create from it. The default is 5GB, but you can enter a larger size in the Size of image filesystem field. Make sure this is at least as big as the root filesystem on the system being imaged.
  5. If you want anyone to be able to use this image, change Make image publicly available? to Yes.
  6. If the bucket already contains an image and you want to replace it, change Overwrite AMI in same bucket? to Yes.
  7. Click the Create Image button.

Once started, Cloudmin will display the progress of the image creation process. This can take up to an hour depending on the size and speed of the system.

Once creation is complete, Cloudmin will display the new image's ID. You can select this on the Create New System page to generate a new EC2 instance that will be a duplicate of the one you imaged. In additional, if you made the AMI publicly available the ID can be shared with any other EC2 users to use.

Managing EC2 Images

You can see all EC2 images Cloudmin knows about at Amazon EC2 -> EC2 Images. By default this includes those you created, images provided by Amazon, and public images from selected other accounts. The accounts to show are set at Cloudmin Settings -> Module Config -> EC2 accounts to display AMIs from.

To change the permissions on an image you created, just click on its ID in the list. On the page that appears you will be able to select if it is public (with the Grant access to everyone checkbox), or only available to a list of EC2 account numbers that you enter.

To remove an image, check the box next to it in the image list and hit the Delete Selected Images button at the bottom of the page. On the confirmation page that appears you will have the option of removing the associated files from S3 too, which is generally a good idea as you are charged for S3 usage by disk space and time.

Creating an EC2 Virtual Machine

Once you have at least one EC2 account registered with Cloudmin and one EC2-generated SSH key, you can create your first EC2 system. The steps to do this are :

  1. On the left menu, open the Create System link and click on Create EC2 instance. This will open the Create New System page.
  2. In the System description field enter a short description, like Foo Corp's webserver.
  3. From the SSH key for root menu, select one of your keys. Typically you will only have one.
  4. If you have multiple EC2 accounts registered, select one from the EC2 account menu. At the time of writing, Amazon only allowed 20 active instances per account.
  5. From the EC2 image to start menu, select the image that defines the initial operating system and software stack for the instance. For webhosting you can use the virtualmin-pro image, or you can go with one of the base operating systems supplied by Amazon. Or if you have created your own EC2 images, you can select one of those.
  6. Because the selected image may include old packages, you should set the Update Virtualmin packages? field to Yes, so that Cloudmin will install all available updates after instance creation.
  7. Finally, click the Create System button to start the creation process.

Amazon is generally pretty fast to create new instances, and no data needs to be copied from the Cloudmin master to the new system. Typically this takes about 5 minutes, and Cloudmin will display each step taken in the system creation process.

Assuming that everything works, the new virtual system will be added to the left menu. You will be able to use Cloudmin to reboot it, update it, or create Virtualmin domains on it, just as you could for any real system. If you no longer need this zone, it can be completely removed with the Delete System link on the left menu.

Downloading System Images

A system image is effectively a file containing the entire filesystem of a virtual system, either in tar.gz or EXT3 format. When a virtual system is created by Cloudmin, it can use an image as the basis of the system's filesystem, rather than needing to download and install packages, or copy files from the host system.

Cloudmin customers have access to system images for a variety of operating systems and virtualization types, but by default none are included when it is installed. To download images that you can use to create systems, do the following :

  1. On the left menu under Cloudmin Settings click on New System Images.
  2. A page listing all available images will be displayed. Choose the ones you want based on the virtualization technology you prefer (such as Xen or Zones), and the Linux distribution that will run in the image.
  3. Check the boxes next to the ones you want to use, and click the Download Selected Images button.
  4. Depending on the speed of your network connection and the total size of those you choose, images may take minutes or hours to download. The progress of each download will be displayed.

You can now create virtual systems using the selected images, assuming that one or more host systems of the corresponding virtualization type have been registered.

If you are using Solaris Zones, only images for the architecture that matches the physical Solaris host systems will work. For Xen or VServers, I recommend selecting images of the same type as your host systems, just to keep management easier.

Some images include the full Virtualmin stack, such as Webmin, Apache, Postfix, BIND, MySQL, ProFTPd and so on. If you plan to create virtual systems for web hosting, we recommend using these images rather than manually installing Virtualmin on created systems - even though VM2 is capable of doing this for you.

VM2 does not limit you to provided images - once you have some virtual systems running, you can create your own, as documented on the Making Your Own Images page.

EC2 Security Groups

Introduction to Security Groups

An EC2 security group is basically a set of firewall rules that can be applied to EC2 instances. Each rule specifies a protocol (TCP or UDP), starting and ending port numbers, and an optional network. When a group is applied to a system, only traffic matching one of the rules will be allowed through. All other traffic will be dropped.

In addition, a security group can list other groups to allow traffic from, regardless of port or address. This will then match other EC2 systems using one of the selected groups. This feature is useful for allowing arbitrary connections between your own machines, while applying stricter restrictions on other systems.

By default every EC2 account has a security group named default that allows connections on a limited number of ports. Cloudmin will create a group named virtualmin when you create a system that allows all the ports typically used for web hosting, such as 110, 80, 443 and 25.

Editing a Security Group

If you want to change the rules for an existing group, the steps to take are :

  1. Go to Amazon EC2 -> EC2 Security Groups, and click on the group you want to edit.
  2. On the page that appears all current rules will be listed. You can change the port range, protocol or allowed addresses for some rule, or use the empty row at the bottom to add a new rule.
  3. To allow network traffic from systems on some other group (or this group), select an EC2 account in the Allowed security groups section and enter the group name in the adjacent field.
  4. Click the Save button to activate your changes.

To create a new group, go to the EC2 Security Groups page and click the Create group for link for the EC2 account you want to add it under. Then fill in rules form with protocols and ports to accept. Make sure you allow at least port 22 (for SSH) and port 10000 (for Webmin), or Cloudmin's access to systems using this security group may be blocked.

To delete a security group that is not in use, check the box next to it on the EC2 Security Groups page and hit the Delete Selected Security Groups button.

Applying a Security Group

A security group can be selected when creating a new EC2 system, using the EC2 security groups field under Advanced options. Actually, you can choose several groups, and traffic matching rules from any of them will be allowed. If you have multiple EC2 accounts in Cloudmin, only groups for the account selected to own the new system can be used though.

If no security group is chosen, just the default group will be used. If a group is changed after system creation (such as to add a new port), it will be immediately applied to all virtual systems using that group. There is no way to select different groups for a system after it is created though.

EC2 Static IP Addresses

IP Addresses on EC2

Every EC2 instance has two IP addresses - the real one on its eth0 interface (typically in the 10.0.0.0/8 network), and an external Internet-accessible address. The Amazon using NAT to foward all traffic to the external address to the internal one, and back again for outgoing connections.

Both addresses are dynamically assigned when a system is created. Because an EC2 instance may need to be destroyed and re-created, there is no guarantee that a replacement instance will get the same IP address that a previous system did, even one under the same account.

However, Amazon does allow EC2 accounts to request static IP addresses, which they call Elastic IPs. Each static IP can be associated with a single EC2 instance at a time, and can be moved between instances. This allows you to keep your external addresses consistent in the face of virtual system creation and deletion.

Creating and Managing Static Addresses

To request a new static EC2 address, follow these steps :

  1. Login to Cloudmin, and go to Amazon EC2 -> EC2 Static IP Addresses.
  2. Select an EC2 account from the menu at the bottom of the page (if you have more than one), and click the Allocate New Address button.
  3. If all goes well, the new IP will show up in the list on the same page.

Amazon bills for each static IP address associated with your access, so don't request too many of them!

To give back an address, check the box next to it and click the Return Selected IP Addresses button. Be careful doing this, as you will not be able to request the same address again. Only addresses not assigned to any system can be returned.

Assigning a Static Address

Once an address has been requested, you can assign it to an EC2 system as follows :

  1. Select the system from the left menu, and go to System Operations -> Assign EC2 Address.
  2. Select the address from the IP address to assign menu, and click Update IP Address.
  3. Wait for Cloudmin to detect that the new address has been applied. This may take several minutes.

You can also dis-associate an address from a system on the same page, by selecting <None> from the IP address to assign menu.

EC2 Volumes

Introduction to EC2 Volumes

EC2 Volumes (called Elastic Block Storage by Amazon) are essentially disk images that can be mounted on any system running on EC2, and continue to exist even if the system they were attached to is deleted. They are a more permanent place to store data than the filesystem of an EC2 instance, and more easily accessible than S3.

Each volume is typically formatted with a filesystem like EXT3, and is mapped to a device like /dev/sdb1 on the system it is connected to. It can then be mounted with the standard Linux mount command. The size of a volume is typically several GB, and is chosen at creation time. Amazon charges for volumes based on their size and the amount of time they exist.

EC2 Volume Snapshots

An EC2 volume snapshot is a copy of a volume taken at some point in time, and stored in S3. Once a snapshot has been created, additional volumes can be created from the data in that snapshot. They can be used for backup purposes, or to duplicate or fork the contents of a volume.

Snapshots are differential backups, meaning that only the blocks on the device that have changed since your last snapshot will be incrementally saved. This means that if you have a device with 100 GBs of data, but only 5 GBs of data has changed since your last snapshot, only the 5 additional GBs of snapshot data will be stored back to Amazon S3.

Creating and Managing EC2 Volumes

To create an EC2 volume in Cloudmin, do the following :

  1. Login to the UI as root and go to Amazon EC2 -> EC2 Volumes.
  2. In the New volume details form, choose your account from the EC2 account menu.
  3. Enter a size in the EC2 account field, or select a snapshot to copy this volume from.
  4. From the Availability zone menu, select the zone that your EC2 systems have been created in. A volume can only be attached to systems in the same zone.
  5. Click the Create button.

Once a volume has been created, it will appear in the list on the EC2 Volumes page. To remove it, check the box next to it's ID and click the Delete Selected Volumes button. Be careful, as the data on the volume will be lost forever (unless you made a snapshot first).

Creating and Managing EC2 Snapshots

Once you have at least one EC2 volume, Cloudmin will allow you to create a snapshot of it as follows :

  1. Go to Amazon EC2 -> EC2 Volumes, and click on the EBS Snapshots tab.
  2. In the New volume snapshot details section, select the volume to copy from the Copy from volume menu.
  3. Click the Create button.

Once a snapshot has been created, it can be used to create new volumes as explained above. Snapshots can be deleted on the EBS Snapshots* tab by checking the boxes next to their names and clicking the Delete Selected Snapshots button.

Assigning Volumes to Systems

Once a volume has been created, it can be attached to an EC2 instance as a block device, and typically mounted a filesystem. This can be done within Cloudmin like so :

  1. Select your system from the left menu, and go to Resources -> Attached EC2 Volumes.
  2. In the Volume attachment options form, select the volume from the Volume to attach menu.
  3. If this is a new volume that has not been mounted anywhere yet, change the Format with filesystem to EXT3. Otherwise, leave it set to Dont format to preserve existing data.
  4. To have Cloudmin attempt to mount the volume, enter a path in the Mount on directory field like /mnt/disk2 or /home.
  5. Click the Attach EC2 Volume button.

Once a volume has been attached and mounted, you can use it on your EC2 system however you wish. To detach a volume, go to the ttached EC2 Volumes page, check the box next to its ID and click the Detach Selected Volumes.

Empty Systems

Introduction to Empty Systems

Cloudmin uses the term "empty system" to refer to one that is created without any operating system initially installed on its virtual disk. Empty systems are always connected to a CD image or physical CD-ROM drive, from which any operating system can be installed. Once the install is complete, the formerly empty system can be managed like any other Cloudmin virtual machine.

The open-source Xen, KVM and Citrix Xen virtualization types all support the creation of systems that are initially empty. In the case of Xen, full hardware virtualization (HVM) is used, which has a performance overhead as compared to para-virtualization. However, HVM allows any operating system to be run inside the virtual system, such as OpenBSD, Windows or other Linux distributions.

Cloudmin will not be able to fully manage non-Linux virtual systems though, as it cannot access files inside their filesystems. This prevents Cloudmin from editing network interfaces unless the system is up and running Webmin, and from fully managing virtual disks.

Creating CD Images

Before creating an empty system, you should add the CD image that you plan to install it from to Cloudmin's system images list. This can be done as follows :

  1. Login as root and go to Cloudmin Settings -> New System Images.
  2. Click Create image for Xen (or whatever virtualization type you are using).
  3. In the Image file format field, select CD or DVD ISO.
  4. In the Image source field, enter the path or URL to the .iso file for the CD image.
  5. Enter a short name for the image in the Unique ID for image field, like xen-debian5-cd.
  6. Enter a longer description in the Description for image field.
  7. Change Compress image file to No.
  8. Click the Create button.

Depending on where the image file has to be fetched from and whether it is initially compressed or not, the creation process may take from seconds to minutes. Once it is complete, you should see it appear on the New System Images page.

Setting up DHCP

When Cloudmin creates an empty virtual system, the IP address that it selects for that system cannot actually be inserted into the appropriate configuration files until after the OS install is complete. Because the OS install is done manually, it is possible that the virtual system might be assigned a different IP address to what Cloudmin expects it to have, which will cause the status to be falsely shown as "Ping failed". This prevents the system from being fully managed by Cloudmin.

The best solution to this issue is to setup a DHCP server on your Cloudmin master system, which will then be automatically configured for each new virtual system so that systems can obtain the correct IP address. The steps to do this are :

  1. Login to Cloudmin at root , and go to Webmin -> Servers -> DHCP Server
  2. If the DHCP server is not installed yet, you may be prompted to have Webmin install it on that page. If this prompt doesn't appear, you will need to install it manually using whatever package or method is appropriate for your operating system.
  3. If the Start Server button appears at the bottom of the page, click it to start DHCPd.
  4. On the left menu, go to System -> Bootup and Shutdown, check the box next to the dhcpd or dhcp-server action, and click the Start on Boot button.
  5. Go to Cloudmin -> Cloudmin Settings -> Cloudmin Configuration -> DHCP settings and change Add DHCPd host for virtual systems? to Yes.

Once this is done, Cloudmin will add a DHCP host entry for each new virtual system it creates. However, this will only be actually used if your master system and Xen or HVM hosts are on the same subnet. If not, you will need to setup the appropriate firewall rules or router configurations to forward DHCP packets from other networks to your Cloudmin master.

Creating Empty Systems

The process of creating a new empty virtual system is mostly similar to that for creating a full system. The steps to follow are :

  1. Open the Create System category on the left menu, and click on Create Xen instance (or whatever virtualization type you want to use).
  2. Select the Create empty system tab.
  3. Enter a short name in the Internet hostname field, like gentoobox.
  4. Enter a longer description in the System description field, like Gentoo Linux install.
  5. In the *Installation CD image * field, either select a CD image that you added to Cloudmin as documented above, or enter the path to an ISO format CD or DVD file on the host system.
  6. If you entered a CD image page, make sure the correct host is selected in the Xen hosting system field.
  7. In the Resource limit options section, enter the size of the system's empty virtual disk in the Disk space allocated to instance field.
  8. Click the Create System button.

Creation should take less time than in would for a Cloudmin system created from an image. At the end of the process, you will have a virtual system whose status is Ping failed, which indicates that Cloudmin could not contact it on the assigned IP address. This is expected, as the system will be waiting for you to complete the OS install process as follows :

  1. Open the System State menu category, and click on Graphical Console.
  2. You should now see the initial installation screen of the operation system whose CD image you selected. Begin the install process, just as you would on a real system.
  3. When you reach the disk partitioning step, make sure that the virtual drive is given only a single partition which contains the root filesystem. Having multiple partitions may make it impossible for Cloudmin to expand the disk later.
  4. When prompted for the system's IP address and hostname, if they do not get correctly assigned by DHCP, make sure you enter the same IP and hostname that Cloudmin selected when the empty system was created.
  5. Complete the rest of the install process as normal. Keep a note of the root password that you select.
  6. Go to System State -> Change Boot Method , and set the boot device to Hard disk only.
  7. Click on Edit System, and in the Authentication options section change the SSH login mode to Using password and enter the password you chose during the install process.
  8. Shut down the virtual system, then start it up again.
  9. Make sure that Cloudmin now shows the system's status as SSH.

If the new system is not contactable by Cloudmin after rebooting, use the Graphical Console page to ensure that it has fully booted from the hard disk, and has the correct IP address.

Managing Empty Systems

Once an empty system has been fully installed, it can be managed by Cloudmin like any other virtual machine. However, Xen instances created this way will always use HVM virtualization, as will any clones created from them. If you create an image of an initially empty Xen instance and then create a new virtual system from that image, it will also use HVM.

Open source Xen systems that were initially created empty will use virtual disks that are in whole-disk format, rather than single-partition format. This generally has no impact on the user, but if the disk has more than one partition it may be impossible to expand its size if both partitions are mounted.

Getting Started With Cloudmin

Recommended Systems

Techically you can run Cloudmin on just a single system, which will be both the master that runs the UI and the host for your virtual systems. However, a more common setup has multiple host systems, one of which is typically also the Cloudmin master on which the install script is run.

If you have a choice of operating systems and are planning to host Xen or OpenVZ instances, we recommend running the latest version of CentOS if possible. The CentOS YUM repository includes a kernel with Xen support and all the needed Xen tools. For more details on how to setup each host system, see the Xen documentation.

If you plan to host OpenVZ containers, a kernel for CentOS that supports them is available from the OpenVZ website. The same website has a kernel that can run both Xen and OpenVZ on the same host, which is fully supported by Cloudmin.

Regardless of the virtualization type you choose, your host systems should have plenty of RAM - a typical Xen instance will consume at least 512MB of RAM, while OpenVZ containers are usually assigned 256MB or more. For Xen hosts, we recommend 4-8 GB RAM and plenty of CPU cores. Running a 64-bit distribution is not generally needed for systems with less than 4GB of RAM, and can actually be counter-productive due to the increased RAM use.

SSH Key Configuration

Once Cloudmin is installed, the first thing you should do is add an SSH key that can be used to login to your host systems as root. The steps to do this are :

  1. Go to Cloudmin Settings -> SSH Keys, and click on Add a new SSH key.
  2. Fill in the Key description field, and enter the path to the private key file into the In existing file box, such as /root/.ssh/id_rsa
  3. Change the Add to root's authorized keys field to Yes.
  4. Click the Create button.

Alternately, you can have Cloudmin generate a new key or use one that you paste in on that same form.

DNS Configuration

Cloudmin adds all newly created virtual systems to a DNS zone hosted on the master system. If your company's domain is example.com, you might name this xen.example.com, and add an NS record to the example.com zone for this sub-domain.

To create this DNS zone on your Cloudmin master, do the following :

  1. Go to Webmin -> Servers -> BIND DNS Server, and click on Create master zone.
  2. Enter the name you chose into the Domain name field, such as xen.example.com.
  3. In the Master server field, enter the externally resolvable name for your Cloudmin master system, such as cloudmin.example.com.
  4. Enter your email addresss in the Email address field.
  5. Click the Create button, then the Apply Configuration link in the top-right corner of the page.

Adding Host Systems

Before you can use a real system to host virtual systems (like Xen or OpenVZ containers), it must be added to Cloudmin. For a host other than the Cloudmin master, the steps to follow are :

  1. Go to Add System -> Add physical system .
  2. Fill in the Internet hostname field with the resolvable hostname or IP address of the machine.
  3. Fill in the SSH login mode section, possibly selecting the key you added above.
  4. If the system already has Webmin installed, fill in the Webmin login mode section.
  5. Click the Add System button.
  6. Assuming the details you entered were correct, the new system should appear on Cloudmin's left menu.
  7. If the system doesn't have Webmin installed yet, select it from the left menu, then go to System Operations -> Install Webmin.

To enable this system for hosting virtual machines, you should first ensure that it has the kernel and tools installed for the virtualization type you are using. Then follow these steps :

  1. Open the Host Systems category on the left menu, and click on the link for the VPS type that you want to host, such as Xen Host Systems.
  2. Click the Register a system for Xen hosting link, and select it from the System hosting Xens menu.
  3. In the IP address allocation range section, select an IP range that you defined earlier. Alternately, you can enter a starting and ending IP address to assign to Xen instances. This should be on the same subnet as the host system's primary network interface. This is typically supplied by your ISP or hosting company.
  4. Select the DNS domain you created earlier from the Add Xen systems to DNS domain field.
  5. If your host system has plenty of disk space, open the System image cache section and fill in the Maximum image cache size field. A cache of 5 to 10 GB is generally enough.
  6. If your host system has LVM setup, we recommend using it for storing Xen disk image due to the performance benefits. Enter the volume group name in the LVM volume group field.
  7. Finally, click the Register button.

If Cloudmin does not detect any problems with the host system, it can now be used to host new virtual instances.

Downloading Images

Cloudmin comes with pre-created images for creating virtual systems of all the supported types. However, they must be first downloaded to your master system before they can be used, as follows :

  1. Go to Cloudmin Settings -> New System Images, and check the boxes next to the images you want.
  2. Click the Download Selected Images button at the bottom of the page, and wait for the downloads to complete.

For each virtualization type (such as Xen and OpenVZ), images are available with CentOS and either Debian or Ubuntu Linux, plus possibly other distributions. For each Linux variant, an image containing just the base operating system is available, plus images containing Virtualmin GPL and Pro.

Creating Your First System

Once all the steps above are complete, you can create a new virtual system as follows :

  1. Open the Create System menu category, and click on the link for the VPS type that you want to create.
  2. Enter a short hostname for the new system in the System hostname field, such as myvps.
  3. Select the image for the new system from the Initial system image menu.
  4. Enter a root password in the SSH login mode field.
  5. Optionally enter memory and disk limits in the Resource limit options section.
  6. Click the Create System button.

How to use the Cloudmin documentation

Organization

Documentation is divided into a few categories, such as "Virtualization", "Installation", and "Administrative and User Accounts", which covers the common types of service you'll be managing with your Cloudmin installation. Within each category you'll find a few types of document, such as "FAQ", "Troubleshooting", and specific task guides.

Pages labeled "FAQ" or "Frequently Asked Questions" are intended primarily for common questions new users, or potential users, ask about Cloudmin and the machines it manages. For example, the FAQ for Xen includes a brief, non-technical, description of the Xen virtualization layer and how Cloudmin interacts with it. The FAQs are generally non-technical in nature, and do not generally provide solutions to problems. They are conceptual and broad, merely to describe the way Cloudmin does things.

Pages labeled "Troubleshooting" are intended to help you solve specific problems. If you are receiving an error message from a service or Cloudmin, the troubleshooting section for that particular area may have solutions. Troubleshooting pages are specific and technical, and are intended to help you solve problems.

Search

You can also search just the documentation by opening the search form and using the Advanced Search form to search within content "Only of the type(s)" and choosing "Book page".

The search page, by default, searches all of the content on Virtualmin.com, including forums, issues, and documentation. This may, or may not, be what you want, depending on the questions you have.

Installing Cloudmin

Cloudmin can be installed in a number of ways, including an automated install script which uses the standard package management features of your OS, and software repositories containing our software in native package formats. We strongly recommend that you use the automated install script to install Virtualmin, if at all possible.

Automated Cloudmin Installation - Installation of the full Cloudmin stack using our automated install script. This is the recommended way to install Cloudmin.

Manual Cloudmin Installation - Installation of Cloudmin and related packages manually. This is the method recommends for systems that are not currently supported by the automated install script.

Installation Troubleshooting - Troubleshooting common problems encountered during installation.

Uninstalling Cloudmin - Uninstallation of Cloudmin and selective removal of packages.

Automated Cloudmin Installation

The simplest way to install Cloudmin is to use the install script on the serial numbers page that matches your system. The steps to follow are :

  1. Pick a system that will be your Cloudmin master. Ideally this should be a freshly installed machine with just the basic operating system. We recommend CentOS, but Debian, Ubuntu and Solaris are also supported.
  2. Download the correct install script for your OS from the serial numbers page.
  3. Upload the script to your Cloudmin master system, then SSH in as root and run it

From this point on, installation should be fully automated. Cloudmin packages, Webmin and other tools will be download from the appropriate repositories using APT or YUM.

Once the installation is complete, you can login via the URL https://mastersystem:10000/ . See the Getting Started with Cloudmin page for what to do next.

Manual Cloudmin Installation

At the time of writing, Cloudmin does not have an automated installation process for very many platforms like Virtualmin. However, it is relatively simple to install, as it has far fewer dependencies. A yum repository is provided for RPM-based distributions, as well as a Webmin compatible wbm repository for updates via the Webmin update system.

To install on a CentOS, Redhat Enterprise or Fedora Core system, the steps to follow are :

  1. Install Perl, using the command :
    yum install perl
  2. If you want access to Cloudmin to be encrypted, install SSL support with the commands :
    yum install openssl openssl-devel
    perl -MCPAN -e 'install Net::SSLeay'
  3. Install the latest version of Webmin in RPM format from www.webmin.com . The command to do this is :
    rpm -U http://www.webmin.com/download/rpm/webmin-current.rpm
  4. If you plan to use Cloudmin to manage Amazon EC2 instances, several Perl modules need to be installed. These can be added to your system with the commands :
    perl -MCPAN -e 'install Params::Validate'
    perl -MCPAN -e 'install LWP::UserAgent'
    perl -MCPAN -e 'install MIME::Base64'
    perl -MCPAN -e 'install Digest::HMAC_SHA1'
    perl -MCPAN -e 'install XML::Simple'
    perl -MCPAN -e 'install HTTP::Date'
  5. Install the RPM packages containing the Cloudmin module and Virtualmin theme with the command :
    rpm -U wbm-server-manager-*.rpm wbt-virtual-server-theme-*.rpm
  6. Put the license and serial numbers into the license file. Edit the file:
    /etc/server-manager-license
    And put your licensing information in using the following format:
    SerialNumber=NNNN
    LicenseKey=XXXXXXXXXXX
    

Assuming that all of the above steps succeeded, you are done! Open a web browser, and go to http://yourserver:10000/ to login (replace yourserver in the URL with the IP address or hostname of the Cloudmin master system). If your system has a root password, you will be able to login as root - if not, you can typically login as a user who has permissions to sudo to root).

Once you are logged in, see the Getting Started with Cloudmin page for what to do next.

Uninstalling Cloudmin

Since Cloudmin is built on top of Webmin, un-installing it is simply a matter of removing Webmin and some additional modules. The commands for this on CentOS, Fedora or Redhat Enterprise are :

rpm -e webmin wbm-server-manager wbt-virtual-server-theme wbt-virtual-server-mobile wbm-security-updates
rm /etc/yum.repos.d/cloudmin

Or on Debian or Ubuntu, run :

dpkg --remove webmin-server-manager webmin-virtual-server-theme webmin-virtual-server-mobile webmin-security-updates
grep -v cloudmin.virtualmin.com /etc/apt/sources.list >/etc/apt/sources.list.tmp && mv /etc/apt/sources.list.tmp /etc/apt/sources.list

In both cases, any virtual systems created by Cloudmin will continue to run un-changed.

If you ever decide to re-install, systems that it used to manage can be re-imported using links under Add System on the left menu.

Installation Troubleshooting

This page lists common installation issues and recommended solutions :

  • Install script fails The most common cause of installation failures is problems downloading packages. If this happens, check the following :

    1. Can you Cloudmin master system access cloudmin.virtualmin.com to download packages via HTTP? If it is blocked by a firewall, the install will fail.
    2. Is your system's YUM or APT configuration file up to date? If /etc/yum.repos.d is missing files or /etc/apt/sources.list is in-complete, some required packages may not be found.
  • Cannot Login as root This can happen if your system doesn't have a root password set, perhaps because authentication is done via an SSH key. To set a password on CentOS, Fedora or Redhat Enterprise, use the command :

    /usr/libexec/webmin/changepass.pl /etc/webmin root mynewpassword

    Or on Debian or Ubuntu, run :

    /usr/share/webmin/changepass.pl /etc/webmin root mynewpassword

  • Perl module install fails If the install script reports that a Perl module has failed to install, try it manually from the shell with a command like :

    perl -MCPAN -e 'install Net::SSLeay'

    Assuming Net::SSLeay was the module that failed. The cause may be missing dependencies such as C development libraries that Cloudmin cannot automatically install.

Introduction to Virtualization Concepts

What is Virtualization?

In Cloudmin, virtualization refers to running a virtual system that appears from the inside to be a real computer, but is actually being emulated on a real machine. The terms "virtual machine" and "VPS" are also used to refer to these, as are type-specific terms like "Xen guest", "OpenVZ container" and "EC2 instance". There are several different technologies that can be used to implement virtualization, which varying support for different operating systems, resource isolation and resource overheads.

Why Use Virtualization?

The most common case is to provide customers or users with what appears to be their own system on which they have full root access and control of all services, but without the overhead of maintaining an actual physical machine. For example, a hosting company might sell virtual systems to customers which in turn use them for web hosting, database hosting or email.

A single physical machine can host multiple virtual systems, each of which is granted a slice of its memory, disk space and CPU time. Each virtual system is protected from others on the same host system. Because many applications or customers do not require the full CPU, RAM or disk capacity of a real systems, virtualization can be used to safely host several on a single physical system, thus saving resources.

Another advantage of Virtualization is the ability to easily move virtual systems between hosts without interruption or the need to re-install applications. If a hardware problem is detected on a host system, all virtual machines on it can be moved to a new host without changing their IP addresses or other settings, and possibly without even interrupting running processes.

Virtualization Types

Not all virtualization technologies are created equal - some (like Xen) provide more isolation between systems but at the cost of additional CPU and RAM overhead, while others (like OpenVZ) can be used to host more virtual systems per physical system, but with more chance of cross-system disruption.

Virtualization types can be generally separated into two categories :

  • Separate Kernels
    Examples : Xen, KVM, Amazon EC2
    These types run a separate kernel for each virtual system, and typically store system files within a disk image or logical volume instead of on the host system's filesystem. RAM used is higher due to the need to run a copy of the kernel for each system, and free disk space and RAM cannot be used by other systems. However they provide more protection and isolation between systems, allow different kernels to be used, and provide more flexibility in filesystem and disk usage within the virtual systems.

  • Shared Kernel
    Examples : OpenVZ, Vservers, Solaris Zones
    These types run under the host system's kernel, which provides filesystem and process isolation between systems. Typically each system's files are stored under some directory on the host, possibly with common files like binaries being shared. They offer less isolation and force use of the same kernel, but the per-virtual-system RAM, CPU and disk overhead is lower. Also, RAM and disk space can potentially be over-committed to make better use of host system resources.

Which Virtualization Type to Use?

If you are running Solaris systems, you really only have one choice - Solaris Zones.

On Linux, your choice depends on the level of isolation you want and how much RAM and CPU overhead you are willing to tolerate. Given the ample CPU and RAM on most modern systems, we recommend using Xen as the overhead is usually tolerable unless you plan to run a large number of small virtual systems. In that case, OpenVZ is the best solution. KVM is similar to Xen in its resource use, but tends to have more overhead as it does not support paravirtualization.

Cloudmin also supports Linux Vservers, but this appears to be poorly maintained and offers no advantages over OpenVZ.

Amazon EC2 is different from other virtualization types in that the virtual systems don't actually run on your own machines - instead, they are hosted by Amazon for an hourly cost. It is worth using if your needs are highly variable, for example if you plan to run a hundred systems for a few hours a day then shut them down.

Location Groups

Introduction to Location Groups

A location group contains a set of host systems, typically in the same physical location. When a virtual system is created you can select a location group instead of a specific host, and Cloudmin will choose a host from that group based on some selection method. The selection may be random, or based on free memory or disk space.

Location groups are most useful when you have a large number of host systems in different locations, and want to avoid selecting an appropriate one manually for each new virtual system. It is quite possible to have just a single location group if all your host systems are in the same datacenter and treated equally for allocation purposes.

Creating a Location Group

To add a new location group, do the following :

  1. Login to Cloudmin and go to Host Systems -> Location Groups.
  2. In the first empty row check the box in the Active column.
  3. Enter a name for the group in the Description column.
  4. Select an allocation method from the Host selection method column. We recommend Most free RAM, as that is the resource likely to run out first.
  5. Click the Save button.

Once a group has been created, you can assign a host system to it as follows :

  1. Open the Host Systems category on the list menu and click on the link for your host system type, such as Xen.
  2. Click on the host you want to assign.
  3. Select the group from the Location group menu, then click Save.

Once at least one running host system is in a group, you will be able to select it on the Create System page.

Making Your Own Images

Images for Xen, VServers or Zones

A Cloudmin image is really just a compressed copy of the contents of a virtual system's filesystem, which means that it is quite possible to create your own images to supplement those that are available for download. This can be useful if you want to create multiple systems with your own customized configuration or special software installed, or if you just want to clone an existing server.

The first step to creating an image is getting a virtual system (running on Xen, VServers or Zones) setup the way you want. We recommend againsts creating any Virtualmin domains on a system to image though, as they would be duplicated on all new systems you create from it, which is likely to cause confusion or clashes. Also, configuration files that contain the IP address of the system will not be updated when a new system is created from the image, except for /etc/hosts and network config files like /etc/sysconfig/network-scripts/ifcfg-eth0 .

Once your source system has been prepared, the steps to create an image from it are :

  1. In the left frame, select the system from the drop-down menu.
  2. Click on Create System Image, which will open the creation form.
  3. In the Unique ID for image field, select New image and enter an ID like xen-centos5-lamp. The Cloudmin standard is for the image ID to be made up of three parts, separated by - characters :
    • The virtual system type, like xen
    • The linux distribution or OS in the image, like centos5
    • The software installed, like base or virtualmin or lamp
  4. Alternately, you can select Overwrite old image and choose an existing image of the same type that you want to replace from the adjacent menu.
  5. In the Description for image field, enter a short title for your image, like CentOS 5 with Apache and MySQL
  6. If you are replacing an image, in the Version number field enter a new version for the image you will be creating. Versions are a useful way of tracking images with the same ID if you are running multiple Cloudmin servers, but are not mandatory.
  7. Click the Create Image Now button.

Image creation can take several minutes, but Cloudmin will show you the progress as it proceeds. If the virtual system was running before you started imaging, it will be shut down (so that the filesystem can be safely copied), and then started up again after the process is complete.

If the source system has Virtualmin Pro installed, any licence information in /etc/virtualmin-license or other repository-related files will be replaced before the image is created. When a new system is created from the image, the correct Virtualmin serial number and key will be put back into those files.

Images are by default stored on the Cloudmin master system in the /var/webmin/server-manager directory. Make sure that this is on a filesystem with plenty of disk space, as an image with the full Virtualmin stack can consume up to 500 MB. Each image is stored in a 2 or more files whose names start with the ID you entered, and you can copy images to other Cloudmin master systems simply by transferring those files.

Image Storage Locations

Cloudmin allows you to customize the locations in which images are stored, instead of just using the default directory on the master system. This can be useful if the master is low on disk space, or if you have geographically distributed host systems and want to avoid copying every image across the country when creating new virtual systems.

To change the default image storage location, the steps to follow are :

  1. Open the Cloudmin Settings category on the left menu, and click on Image Storage Locations
  2. Click on the Default location entry.
  3. To use a different directory on the host, enter it in the Directory on Cloudmin master field.
  4. To store images elsewhere, select Directory on system , choose a system from the menu, and enter a path.
  5. Click the Save button.
  6. Any images already on the Cloudmin master will remain there - this new setting only applies to images created or downloaded from now on.

To add an additional image storage location, the steps to follow are :

  1. Open the Cloudmin Settings category on the left menu, and click on Image Storage Locations
  2. Click the Add a new image storage location link.
  3. Enter a name for the location in the Location description field.
  4. Check the Directory on system radio button, choose a system from the menu, and enter a path with plenty of free space.
  5. If you want this storage location to be used only by systems in some location groups, select them in the For location groups field.
  6. Click the Save button.
  7. To copy some existing images to this new location, click on New System Images on the left menu.
  8. Check the boxes next to the images you want copied, then click the Copy Selected To All Storage Locations button.

Images for EC2

Amazon's EC2 service also supports images, also know as AMIs. Unlike images for virtual system types such as Xen, these are not stored on your Cloudmin master system - instead, they are stored in the Amazon S3 file storage space for one of your EC2 accounts.

Cloudmin supports the creation and management of EC2 images just as it does for regular images, but with a few small differences. To create an image, you must first have a running EC2 instance that has been setup the way you want, from which the image will be made.

Once your source system has been prepared, the steps to create an image from it are :

  1. In the left frame, select the system from the drop-down menu.
  2. Click on Create EC2 Image, which will open the creation form.
  3. In the S3 bucket for image field, enter a unique directory name for the image data files, such as centos5-virtualmin.
  4. From the Save under S3 account menu select the EC2 account that will own this image.
  5. In the Size of image filesystem field enter the size of the root filesystem for virtual systems that will be created from this image. This should be large enough to store the domains that you want to host on created systems - but remember that Amazon charges for S3 storage by the megabyte, so creating a huge image could be costly.
  6. If you want the image to be available to other EC2 users, change Make image publicly available? to Yes. This should not be done for images containing commercial software like Virtualmin Pro.
  7. Click the Create Image button.

Image creation can take several minutes, but Cloudmin will show you the progress as it proceeds. The source EC2 system will not be shut down during imaging, but you should minimise use of it in order to avoid inconsistencies in the filesystem state.

If the source system has Virtualmin Pro installed, any licence information in /etc/virtualmin-license or other repository-related files will be replaced before the image is created. When a new EC2 system is created from the image, the correct Virtualmin serial number and key will be put back into those files.

Managing CPU Limits

Virtual System CPU Limits

Xen, OpenVZ and Vserver virtual systems can have limits imposed that restrict the amount of CPU they can consume on the host system. This limit is typically expressed as a percentage, where 100% means the right to use a full CPU core. On a multi-core host system, a limit could thus be set to more than 100%. It is also possible to turn off the CPU limit for a virtual system completely, which allows it to consume as much of the host's resources as it wants.

CPU limits can be used to prevent a single virtual system from overwhelming others on the same host. For example, you might want each customer to be limited to 50% CPU, meaning that 8 such systems could run on a 4-core host without impacting each other. CPU can also be over-committed, which is typically safe as most systems use CPU in bursts.

Setting Limits in Cloudmin

The CPU limit for a new system can be set on the creation form, in the Resource limit options section. After creation it can be modified at Resources -> Resource Limits, and takes effect immediately without the need for a reboot.

Xen systems also support setting a CPU weighting, which determines how much CPU it is granted when the host system is over-committed. A system with a weight of 200 will get twice as much CPU as one with a weight of 100, but only if the total CPU percentages granted to running systems exceeds the host's capacity.

Xen CPU Pinning

Xen also supports multiple virtual CPU cores within a system, each of which can be mapped to a core on the host. This can be configured at Resources -> Manage Virtual CPUs. It can be useful for separating Xen systems by assigning each to a different core on the host, so that there is no possibility of contention.

CPU Limits and System Owners

Account plans can be used to define a total CPU limit for system owners, which applies to the sum of all limits applied to systems belonging to the owner. For example, if an owner has a limit of 80% CPU he could assign 40% to one system, and 40% to another. Or he could create just a single system with a 80% limit. In no case will he be allowed to set a virtual system to unlimited CPU though.

Managing Network Interfaces

Introduction to Network Interfaces

Each virtual system managed by Cloudmin has at least one network interface / IP address, which the system's hostname typically resolved to in DNS. On the virtual machine this usually appears as eth0 - how it appears on the host system differs depending on the type of virtualization being used.

It is possible for virtual system to have multiple network interfaces. For Xen and KVM instances on host systems with more than one bridge, the virtual machines can have one ethN interface per bridge. Typically each is connected to a different physical network or VLAN on the host system.

Cloudmin lets you add extra IP addresses to a virtual system, although these will usually be virtual interfaces like eth0:5. This is useful if you want a VPS to host multiple SSL-protected websites, each of which needs its own IP address.

System owners can be either completely denied access to page for managing network interfaces, or limited in how many IP addresses they can use across all their virtual machines. This can be done either at the plan level, or on an owner-by-owner basis.

Cloudmin can manage network interfaces on any system running Webmin, or with a Debian-based or Redhat-based Linux distribution installed. It can even manage interfaces on a down system, assuming it is running Debian, Ubuntu, RHEL, Fedora or CentOS. This allows you to fix networking errors even if a system is in-accessible, by first shutting it down and then using Cloudmin to edit interfaces.

Adding a Virtual Network Interface

To create a new network interface, the steps to follow are :

  1. Select the system from the left menu, open the System Configuration category and click on Network Interfaces.
  2. Underneath the list of existing interfaces, click the Add a virtual interface link.
  3. If the virtual system has more than one bridged interface, select the one you want to add a virtual interface to from the Real interface menu.
  4. Either enter an IP for the new interface from the IP address menu, or select Allocate automatically to have Cloudmin pick one from the allocation range you have specified for its host system.
  5. Change the netmask if needed - but typically the default will work fine.
  6. Click the Create button.

The new IP address should be immediately activated and pingable, and will be added to both the networking configuration files on the virtual system, and any virtualization config files on the host system.

Adding a Real Network Interface

Xen and KVM virtual systems also support creation of non-virtual interfaces, which appear like eth1 on the virtual machine. If the host system has multiple network bridges you can select which bridge each new real interface is connected to - it is also possible to have multiple real interfaces bridged to the same real interface on the host.

To create a new real network interface, the steps to follow are :

  1. Select the system from the left menu, open the System Configuration category and click on Network Interfaces.
  2. Underneath the list of existing interfaces, click the Add a real interface link.
  3. The Network interface name field can generally be left un-changed, as Cloudmin will pick the next free ethN device on the virtual system.
  4. If the virtual system has more than one bridge, select the one you want from the Network bridge on host menu.
  5. Either enter an IP for the new interface from the IP address menu, or select Allocate automatically to have Cloudmin pick one from the allocation range you have specified for its host system.
  6. Change the netmask if needed - but typically the default will work fine.
  7. Click the Create button.

The new IP address should be immediately activated and pingable, and will be added to both the networking configuration files on the virtual system, and any virtualization config files on the host system.

Editing and Deleting Interfaces

To change or remove an interface, do the following :

  1. Select the system from the left menu, open the System Configuration category and click on Network Interfaces.
  2. Click on the address for the interface you want to manage.
  3. If it is a virtual interface (like eth0:5) or a real interface other than the first, you can click the Delete button to remove it.
  4. Otherwise, change any of its details such as the IP, netmask or MAC address, and click Save.

Again, all changes will be activated immediately with the exception of a change in the MAC address. That will only take effect when the virtual system is shut down and started up again. Only Xen and KVM systems can have their MAC addresses changed, and only for non-virtual interfaces.

Changing the Default Gateway

Cloudmin can edit the default router on a running system with Webmin installed, or a down system with a support Linux distribution (Redhat or Debian based). The steps to do this are :

  1. Select the system from the left menu, open the System Configuration category and click on Network Interfaces.
  2. Below the list of interfaces is a Default gateway options form.
  3. Change or clear the gateway in the Gateway IP address field.
  4. Click Save.

Be careful doing this on a running virtual system though, as you may cut off access to the Cloudmin master.

DHCP and MAC Addresses

Cloudmin can be configured to setup the DHCP server on your master system to supply virtual machines with IP addresses. This can be useful if you want to use system images for operating systems that Cloudmin cannot configure the network on directly, such as Windows or FreeBSD.

The steps to setup a DHCP server are as follows :

  1. Make sure the ISC DHCPd software is installed. On Redhat or CentOS systems, this can be done with the command : yum install dhcp On Debian or Ubuntu, the command is : apt-get install dhcp3-server
  2. In Cloudmin, go to Webmin -> Servers -> DHCP Server , and add a subnet for the IP network that your virtual systems will be on.
  3. Make any other configuration changes to the DHCPd settings that you want, such as on the Edit Client Options page. Here you can set default nameservers and gateways for your virtual systems.
  4. Click the Start Server or Apply Changes button, and verify that DHCPd starts OK.
  5. Go to Cloudmin -> Cloudmin Settings -> Module Config -> DHCP settings.
  6. Change the Add DHCPd host for virtual systems option to Yes.
  7. In the Add DHCPd hosts to subnet field, enter the IP address of the subnet that you added in step 2 above.
  8. Click Save.
  9. Create a new KVM or Xen virtual system, and ensure that it successfully adds a DHCP host entry during the creation process.

Managing RAM Limits

Virtual System RAM Limits

For Xen, OpenVZ and Vserver virtual systems, Cloudmin can define a limit on the amount of RAM the virtual system can consume. This prevents a single system from consuming all the RAM on the host, and allows you to parcel out memory based on how much a customer pays or what an application requires.

OpenVZ and Vserver systems can also be configured with no RAM limit, which allows them to potentially consume all RAM on the host. Memory that is not actually used by processes running within the system is potentially available to other virtual systems or processes on the host, which means that RAM can potentially be over-committed.

Xen systems always have a fix RAM limit, and do not allow that block to be shared with other systems while the Xen instance is running. Thus there is no possibility of over-committing RAM.

Setting Limits in Cloudmin

When you create a virtual system, the initial RAM limit can be set in the Resource limit options section of the creation form. After creation, it can be adjusted at Resources -> Resource Limits. In most cases, RAM available can be changed without needing to reboot the virtual system. However, setting it lower than the amount actually consumed by the kernel and running processes may cause the system to crash.

In all cases the new RAM limit will be saved in the appropriate config file for the virtual system, and re-applied if it is rebooted.

RAM Limits and System Owners

Account plans can be used to define a total RAM limit for system owners, which applies to the sum of all limits applied to systems belonging to the owner. For example, if an owner has a limit of 1GB RAM he could assign 512M to one system, and 512M to another. Or he could create just a single system with a 1GB limit. In no case will he be allowed to set a virtual system to unlimited RAM though.

Managing Virtual Disks

Virtual Disks on Xen and KVM

Cloudmin currently only supports management of virtual disk images for Xen and KVM systems, as other virtualization types use a directory on the host filesystem to store files instead of images.

Each open source Xen system has one or more files or devices on the host system (like /xen/mysystem.img mapped to devices on the virtual system (like /dev/sda1). The disks on the host can be regular files, LVM logical volumes, or actual disk partitions. In the virtual system, these are typically mapped to partitions, but can be an entire disk.

When Cloudmin creates a new Xen system, it will also build at least one virtual disk whose contents are a copy of the selected system image. If you select to enable swap as well, another disk will be created for the swap file. These will be mapped to /dev/sda1 and /dev/sda2 on the virtual system respectively.

For KVM, files or devices on the host system (like /kvm/mysystem.img) are mapped to entire disks on the virtual system (like /dev/hda). This disk image then contains one or more partitions, which can be mounted as filesystems on the virtual machine, or used for LVM or RAID.

When Cloudmin creates a new KVM system, it will create a disk image typically with a single partition. This is then mounted as the root filesystem on the virtual machine. In some cases, there may be an additional partition that is used for the /boot filesystem.

Citrix Xen virtual systems also use whole-disk images, on which Cloudmin creates partitions. However, the underlying storage is managed entirely by the Citrix Xen API, so you never need to select a filename or LVM volume group for a new disk.

Expanding a Virtual Disk

The most common operation to perform on a disk image is expanding it when the filesystem is full. The steps to do this are :

  1. Login to Cloudmin, and select the system from the left menu.
  2. If the system is running, shut it down. A virtual system's filesystem cannot be modified while it is running, unless it is a non-root filesystem that is not currently in use.
  3. Go to Resources -> Manage Disks .
  4. Click on the appropriate disk, which is typically mapped to SCSI device A partition 1 for the root filesystem.
  5. Increase the Disk file size , then click Save.
  6. After the resize is complete, start the system up again if needed.

This process is identical for disk images stored in regular files or logical volumes. In both cases, the size increase will fail if the underlying host filesystem or volume group does not have enough free space.

This same procedure can be used to shrink a disk, assuming that the filesystem on is not using more space than the new disk size. However, Citrix Xen does not support the shrinking of disk images.

For KVM and Citrix Xen whole-disk images, expansion of a disk is only possible if there is a single partition or if the final partition contains the filesystem being expanded.

Unsafe Disk Resizes

Cloudmin attempts to work out what filesystem is on a virtual disk by looking at the /etc/fstab file on the virtual system. It then uses this information to properly expand the filesystem.

However, if the filesystem type cannot be worked out then Cloudmin will warn you about possible data loss before resizing a disk. After expanding a disk you will need to login to the virtual system and possibly expand partitions and filesystems on the disk, or create a new partition in the empty space. Disks used for RAID, LVM or by un-supported operating systems like Windows or BSD cannot have their filesystems expanded by Cloudmin.

Scheduled Disk Expansion

Because expanding the size of a disk typically requires a virtual system be shut down, you may want to schedule this for a time when the system is not being heavily used, like 3 AM. This can be done as follows :

  1. Login to Cloudmin, and select the system from the left menu.
  2. Go to Resources -> Manage Disks .
  3. Click on the appropriate disk, which is typically mapped to SCSI device A partition 1 for the root filesystem.
  4. In the Scheduled disk resize section, enter a new size and select a time for it to take effect - the default is 3 AM tomorrow morning.
  5. Click the Add Scheduled Change button.

When the selected time arrives, the system will be shut down if needed, the selected disk resized, and then the system started up again. Only one scheduled change can be created at a time for each disk on each system. Once created, a change can be cancelled before it takes effect on the same page.

Creating a Virtual Disk

You might want to add a disk to a system for use as virtual memory, or to move some files onto. The steps to do this are :

  1. Login to Cloudmin, and select the system from the left menu. It does not have to be shut down.
  2. Go to Resources -> Manage Disks , and click on Create a new virtual disk.
  3. In general, the disk file and device fields will be automatically filled in with reasonable defaults. All you need to enter is the New disk file size.
  4. To have Cloudmin create a filesystem on the disk, select it from the Filesystem to create menu. You can also choose to mount it somewhere on the virtual system by entering a path in the Mount new disk as field.
  5. Click the Create button.

A reboot of the virtual system will be needed before the new disk is available.

Deleting Virtual Disks

If a virtual system no longer needs a disk, you can remove it as follows. All data on the disk will be lost though! Removal of the disk for the system's root filesystem is not possible.

  1. Login to Cloudmin, and select the system from the left menu.
  2. If the system is running, either shut it down or kill any processes on the system using the disk.
  3. Go to Resources -> Manage Disks , and click on the disk.
  4. Click the Delete button.

OpenVZ Disk Limits

OpenVZ virtual systems can limit disk usage in a different way - instead of using fixed-size virtual disks, each system can have an optional limit on the amount of disk space its filesystem can consume. This can be set on the Create New System page in the Resource limit options section, or modified later on the Resource Limits page.

Virtual Disks and System Owners

Account plans can be used to define a total disk limit for system owners, which applies to the sum of all disks on all systems belonging to the owner. For example, if an owner has a limit of 10GB of disk he could create a virtual system with two 3GB disks, and other with 1 2GB disk.

For OpenVZ systems, the disk space limit is counted towards the owner's total disk space. If an owner has a disk limit, he will not be allowed to create an OpenVZ system without a limit.

Managing Virtual Domains

Once you have systems registered with Cloudmin that run Virtualmin, you can use the Cloudmin interface to create, find and manage domains on those systems. In a company with many real and virtual systems, this makes domain management much easier than logging into every one of your Virtualmin hosts individually to find a domain.

Creating Domains

Cloudmin can create new domains, with some restrictions - it only supports new top-level domains (not sub-servers), using the default template on the target system. In addition, many of the lesser-used options on the regular virtual domain creation page are not available.

To create a domain, the steps to follow are :

  1. On the left menu, open the Cloudmin Settings category and click on Virtualmin Domains.
  2. On the page that appears, click on the Create new Virtualmin domain link to display the new domain form.
  3. Fill in the Domain name field with the new virtual server name, like foo.com .
  4. Enter the owner of the domain into the Description field, such as Foo Corporation .
  5. Enter the administration password in the Password field.
  6. From the Create on system menu, select the Cloudmin system on which you want it to be created. There are also options in that menu have Cloudmin choose a system automatically based on free disk space, CPU load and number of domains.
  7. In the Enabled features section, select the features that you want the new domain to have.
  8. In the domain needs a private IP address for an SSL website, in the Assign virtual IP address field select either allocate automatically or with address. In the latter case, you will need to enter an IP into the adjacent text field.
  9. Click the Create Virtual Server button.

If there are no mistakes on the form, Cloudmin will contact the selected Virtualmin system to begin the domain creation. Any errors or progress output from the remote system will be displayed.

IP Address Allocation

When creating domains on systems running under VServers or Solaris Zones, the allocate automatically option tells Cloudmin to select a virtual IP address from the range specified for the virtual system's host. It will also add a virtual interface with that IP, as these virtualization types do not allow systems to manage their own network interfaces.

Similarly, the IP entered when with address is selected will be activated by Cloudmin. Make sure you enter an IP on the same network as the Virtualmin system, or else it is unlikely to be reachable.

When creating on a real system or one running under Xen, virtual IP creation is done by the virtual system itself. In this case, the options to allocate or specify a private IP address are passed directly to Virtualmin on the selected system.

Finding Domains

If you have many systems running Virtualmin, finding a domain that might be hosted on any one of them could be a slow process - unless you are using Cloudmin, which fetches the list of domains from each managed system as part of its automatic status check. To search for and manage domains, follow these steps :

  1. On the left menu, open the Cloudmin Settings category and click on Virtualmin Domains.
  2. On the page that appears, enter part or all of the domain name into the Find domains containing field, and click Search.
  3. If any domains match your search, they will be displayed in a table. You can manage a domain on its host system by clicking on its name, which will open a new browser window logged into the Virtualmin system automatically. Or you can manage the system hosting the domain by clicking on its hostname in the list.

Another way to find domains is to select a system from Cloudmin's left frame, then click on the Domains link below the menu. This will open a page with all its hosted domains listed, on which you can click on a domain name to manage it. Domains can also be disabled, deleted and moved from this page just as they can be from the global domain search results.

Deleting and Disabling Domains

As well as creating domains, Cloudmin can be used to delete, disable and enable them. The steps to do this are :

  1. On the left menu, open the Cloudmin Settings category and click on Virtualmin Domains.
  2. Use the search form to find the domain or domains you want to delete.
  3. Check the boxes next to each domain. When deleting it is only necessary to select the parent - sub-servers will be automatically removed.
  4. Click the Delete Selected button. A confirmation page will be shown asking if you really want to remove them.
  5. Cloudmin will contact the Virtualmin systems that host the selected domains, and display any error messages or progress output from the deletion process.

When deleting a domain with a virtual IP interface that was created by Cloudmin (on a Zones or VServers system), the interface will be automatically shut down as part of the deletion process.

Disabling and enabling domains is similar, except that you use the Disable Selected and Enable Selected buttons respectively. Domains that are already disabled are shown in italics in the domain list.

Moving Domains

Cloudmin has the ability to move a Virtualmin domain between systems, which can be useful if you are planning to retire an old system, or want to move a high-load domain to a more powerful server. Moving is done using Virtualmin's backup and restore features - the domain is backed up on the source machine, transferred to the Cloudmin master and then to the destination, deleted from the source, and finally restored from the backup file.

We recommend moving domains between systems running the same OS and software versions where possible, as in some cases a domain may contain files or configuration options that are specific to a particular OS. The most common example of this is PHP scripts - if the domain has installed scripts that require PHP 4 but the destination does not support this version, then they are almost certain to fail.

To move a domain or domains, the steps to follow are :

  1. Use the domain search form to find the ones you want to move, and check the boxes next to their names.
  2. Click the Move Selected button at the bottom of the list, which will bring you to a page for selecting the destination machine.
  3. Choose the new host from the Destination system menu.
  4. If you want the domains to be completely removed from their original hosts, change the Delete from source systems? option to Yes. This is almost always what you want, but is slighly risky as there is a chance of the domain being lost if it cannot be restored on the target.
  5. By default, Cloudmin will not move a domain to a system that does not have the same Virtualmin features as the source, as this will lead to some of its functions being broken. To override this, change the Move even if features are missing? setting to Yes.
  6. Finally, click the Move Now button. Cloudmin will display each step of the move as it runs, and inform you of the final success or failure of the operation.

In almost all cases, you will need to make some DNS changes once a domain has been moved, as it will now be on a new IP address (the shared IP of the new host system). If the DNS domain is hosted by Virtualmin, the upstream registrar will need to be updated with the new system's DNS server IP address. If DNS hosting for the domain is done on a completely different system, any records for the domain that use the old system's IP will need to be changed to the new one.

When a domain with a private IP address is moved, Virtualmin will use the same IP on the new system. This will generally work fine, as long as both systems are on the same network. However, you should choose the delete the domain from the source machine when moving, as it is not generally possible to have to systems with the same IP address active at once.

Configuring Default Features

By default when creating a domain, Cloudmin will have features available by default on any managed Virtualmin system checked. If you want more control over which features are active by default, the steps to follow are :

  1. On the left menu, open the Cloudmin Settings section and click on Default Virtualmin Features.
  2. On the page that appears, select the Selected below radio button.
  3. From the list of features, check the boxes next to the ones you want enabled by default. For each feature you can see which registered Virtualmin systems support it.
  4. Click the Save button.

Multiple Interfaces for Xen

Why Use Multiple Interfaces?

On a simple Xen host system there is only one network interface (such as eth0), typically connected to the Internet. All Xen systems have their own virtual eth0 interface which is bridged to the host system via Xen's xenbr0 interface.

However, you may want to configure host systems with two interfaces, one connected to the Internet and one on a private network for transfers between host or virtual systems. This involves adding an additional bridge (usually xenbr0) to the Xen configuration on the host, and configuring Cloudmin to create new Xen systems with a second interface this is connected to the bridge.

Configuring Xen on the Host System

This configuration must be done manually, as Cloudmin does not yet support managing the xend configuration file on a host. The steps to follow are :

  1. SSH into the host system as root, and create the file /etc/xen/scripts/multiple-bridge with the following contents :
    #!/bin/sh
    dir=$(dirname "$0")
    "$dir/network-bridge" "$@" vifnum=0 netdev=eth0 bridge=xenbr0
    "$dir/network-bridge" "$@" vifnum=1 netdev=eth1 bridge=xenbr1
  2. Make the file executable with the command chmod +x /etc/xen/scripts/multiple-bridge
  3. Edit the file /etc/xen/xend-config.sxp and find the line like (network-script network-bridge) line, and change it to (network-script multiple-bridge)
  4. Restart Xen with the command /etc/init.d/xend restart
  5. Verify that the xenbr1 bridge has been created with the ifconfig -a command.

If you have multiple host systems, these steps must be performed on each of them.

Configuring Cloudmin

Once the additional bridge is active on the Xen host, you can configure Cloudmin to use it as follows :

  1. Go to Host Systems -> Xen Host Systems, and click on the host.
  2. In the Bridges on host system for Xen interfaces field, select both xenbr0 and xenbr1.
  3. In the IP address allocation range table, add a row with a range of IPs to use on your internal network, such as 192.168.1.1 to 192.168.1.254, with CIDR set to 24. Select your new xenbr1 bridge in the For interface column.
  4. Click the Save button.

How you can create a new Xen virtual system, and it should be configured with two network interfaces, with eth1 connected to eth1 on the host system, and an IP assigned from the 192.168.1 range.

Registering Host Systems

Before a system can be used to host Xen instances, Solaris Zones or Linux VServers, Cloudmin must be informed that is will be used for this purpose, and must verify that needed software and kernel support is installed. The steps to do this are similar for the various virtualization types, but they all start with the registration of the host system itself, documented on the Using Cloudmin page.

Setting up DNS

When a virtual system is created by Cloudmin, it will be assigned an IP address and a hostname. To allow this hostname to be used by other systems, it must be added to the DNS so that it can be resolved - otherwise, only the IP can be used to connect.

Fortunately, Cloudmin can make use of Webmin's BIND DNS Server module to add these DNS records automatically. For this to work, the Cloudmin master system must be running a name server, and it must have at least one DNS domain configured, as explained below :

  1. On the master system, click on the Webmin link at the top of the left menu, open the Servers category and click on BIND DNS Server.
  2. If BIND is not installed yet, Webmin will inform you and offer to automatically install it from YUM, APT or Blastwave, if your operating system supports one of those repositories. You should click on the link to install it, which if successful will return you to the BIND module.
  3. If you want to create a new DNS domain for virtual systems (recommended), click on the Create master zone link above the list of existing domains.
  4. In the Domain name / Network field, enter the new domain name. If your company's domain is yourcompany.com , we recommend a domain like xen.yourcompany.com .
  5. If the Email address field is empty, enter your email address.
  6. Click the Create button.
  7. Click the Apply Changes button below the list of domains.

Unless the Cloudmin master system is already the primary nameserver for the yourcompany.com domain, you will need to add an NS record in that domain for xen.yourcompany.com with the hostnmae of the Cloudmin master system. Using Webmin, the steps to do this are :

  1. Login to Webmin on your primary DNS server, and open the BIND DNS Server module under the Servers category.
  2. Click on your company's primary DNS domain, like yourcompany.com .
  3. Click on the Address icon.
  4. Unless the Cloudmin master system is already in your DNS, use the Add Address Record form to add it. In the Name field you could enter cloudmin, and in the Address field the IP of the Cloudmin system. Then click Create.
  5. Return to the Edit Master Zone page, and click on Name Server.
  6. In the Add Name Server Record form, enter xen.yourcompany.com for the Zone Name, and the hostname of the Cloudmin master in the Name Server field, such as cloudmin.yourcompany.com . Then click Create.
  7. Return to the main page of the BIND module, and click the Apply Changes button at the bottom of the page.

Registering a Xen Host

The steps to add a system for Xen hosting are :

  1. Make sure the system is configured for Xen as explained on the Setting up a Xen Host System page.
  2. Open the Cloudmin Settings section on the left menu, and click on Xen Host Systems.
  3. Click on the Register a system for Xen hosting link.
  4. Select the host system from the System hosting Xens menu.
  5. In the Base directory for virtual systems field, enter an existing directory on the system under which Xen images will be created. This should be on a filesystem with plenty of disk space, and ideally using fast disks and/or RAID.
  6. From the Add Xen systems to DNS domain menu, select the local DNS domain to which new instances hostnames' should be added.
  7. In the textboxes next to IP address allocation range, enter the starting and ending IP addresses for a range that will be allocated to new Xen instances. These should be on the same network as the system's primary ethernet interface.
  8. Click the Register button. If Virtualmin can contact the selected system and verifies that Xen kernel support and commands are available, you will be returned to the list of Xen hosts.

Once at least one system has been registered, you will be able to create Xen instances using Cloudmin.

Registering a VServer Host

The steps to add a system for Linux VServers hosting are :

  1. Make sure the system is configured for VServers as explained on the Setting up a VServers Host System page.
  2. Open the Cloudmin Settings section on the left menu, and click on VServer Host Systems.
  3. Click on the Register a system for VServer hosting link.
  4. Select the host system from the System hosting VServers menu.
  5. In the Base directory for virtual systems field, enter an existing directory on the system under which VServer filesystems will be created. This should be on a filesystem with plenty of disk space, and ideally using fast disks and/or RAID.
  6. From the Add VServer systems to DNS domain menu, select the local DNS domain to which new instances hostnames' should be added.
  7. In the textboxes next to IP address allocation range, enter the starting and ending IP addresses for a range that will be allocated to new VServer instances. These should be on the same network as the system's primary ethernet interface.
  8. If you will not be using Cloudmin images to create VServers, the Distribution to install on VServers field can be used to enter a distribution code like fc6 or edgy or sarge .
  9. Because VServer systems created without images are often missing important packages by default, the Packages to install on VServers section can be used to select some that you may want installed.
  10. Click the Register button. If Virtualmin can contact the selected system and verifies that VServers kernel support and commands are available, you will be returned to the list of VServers hosts.

Once at least one system has been registered, you will be able to create VServers instances using Cloudmin.

Registering a Solaris Zones Host

The steps to add a system for Zones hosting are :

  1. Open the Cloudmin Settings section on the left menu, and click on Solaris Zones Host Systems.
  2. Click on the Register a system for Solaris Zones hosting link.
  3. Select the host system from the System hosting zones menu. Naturally, this must run Solaris.
  4. In the Base directory for zones field, enter an existing directory on the system under which zones filesystems will be created. This should be on a filesystem with plenty of disk space, and ideally using fast disks and/or RAID.
  5. From the Add systems in zones to DNS domain menu, select the local DNS domain to which new instances hostnames' should be added.
  6. In the textboxes next to IP address allocation range, enter the starting and ending IP addresses for a range that will be allocated to new zones. These should be on the same network as the system's primary ethernet interface.
  7. Click the Register button. If Virtualmin can contact the selected system and verifies that they run Solaris, you will be returned to the list of zones hosts.

Once at least one system has been registered, you will be able to create Solaris Zones using Cloudmin.

Remote API

Cloudmin Remote HTTP API

Even though a command-line API exists for managing Cloudmin objects such as systems, domains and interfaces, this may not be appropriate or usable in all circumstances. Because the commands need to be run as root, they cannot be called from PHP or CGI scripts invoked by a web server, which typically run as a less-privileged Apache user. Also, they must be run on the server running VM2, which makes them difficult to call from another system.

For this reason, an alternate method exists for running these programs via HTTP requests. A special URL in the Cloudmin web interface exists to be called by other programs, and to then pass its parameters on to one of the command-line scripts. This URL can be requested from any system, and by processes running as any Unix user.

Before reading this documentation, you should be familiar with the Cloudmin Command Line API documentation, even if you never use those commands directly.

The Remote API

All remote calls must be made through the CGI /server-manager/remote.cgi . The full URL for this will be https://yourserver:10000/server-manager/remote.cgi , where 'yourserver' is the full hostname or IP address of the system running the VM2 master.

This URL must be provided with at least one parameter named 'program', whose value must be the name of the command-line program to invoke, without the .pl extension. So a possible URL to request would be :

https://yourserver:10000/server-manager/remote.cgi?program=list-systems

Because most command-line programs require additional parameters, these must be included in the URL. Every CGI parameter is converted to a command-line parameter, with the value of the parameter appended if given. For example, to create a mail alias, you could invoke the URL :

https://yourserver:10000/server-manager/remote.cgi?program=reboot-system&host=xencentos.home

To specify a parameter that does not have anything after it, just add a CGI parameter with no value. For example, to list systems in detailed form, you could call :

https://yourserver:10000/virtual-server/remote.cgi?program=list-systems&multiline=

Both GET and POST format HTTP requests can be used. If your VM2 master server is not running in SSL mode, use http:// instead of https:// in the URL.

Reading Output

The page returned by the remote.cgi URL will always be plain text, and will contain the output produced by the command-line program. One additional line will be appended though - the words 'Exit status:' followed by the numeric Unix exit status of the command. A status of 0 means that the program was successful, while a non-zero status indicates some error. The cause of the error can be determined from the command's output.

JSON and XML Output

If you would prefer JSON format output, add the json=1 parameter to the remote API call. Alternately, you can select XML format with the xml=1 parameter. Finally, Perl format can be selected with the perl=1 parameter.

Authentication

Because the remote API is part of the Cloudmin web interface, it is password-protected using the same authentication system as you would normally use to login via a web browser. Any Webmin user with access to the module can also access the API. As of Cloudmin 4.1, system owners can also be granted access to the API with the same permissions and capabilities as they would have when using the web UI.

When calling the remote API from your own programs, the HTTP request must have the necessary HTTP authentication headers. All HTTP libraries and programs have options to set the username and password - for example, the wget command uses --http-user and --http-passwd , so you could fetch a list of domains from a remote VM2 server with a command like :

wget --http-user=root --http-passwd=smeg 'https://yourserver:10000/server-manager/remote.cgi?program=list-systems'

Replicating Virtual Domains

Introduction to Domain Replication

If you use Cloudmin to manage one or more systems running Virtualmin, you can have it replication domains and global Virtualmin settings (like plans and templates) from a source system to multiple destinations. This can be useful for :

  • Distributing common settings like plans, styles and custom scripts to multiple Virtualmin systems to avoid having to create them manually.
  • Creating a hot-spare system that gets a copy of one or more domains on a regular basis, so that it can serve if the primary system goes goes.
  • Replicating websites for load-balancing purposes, so that multiple machines can serve the content for a single website.

Domain replication is most useful when the systems share home directories via NFS and possibly connect to a remote MySQL database, so that dynamic content is always up to date. In this case, Cloudmin should be configured to not replicate home directory and database content.

To limit replication to just some Virtualmin features, open the Advanced replication settings section when adding or editing and select them from the Virtualmin features to replicate field. For example, you may want to select everything except home directory content and MySQL databases if they are stored on a separate system used by both the source and destinations.

Setting Up Domain Replication

To configure Cloudmin to replicate one or more virtual servers from a source system to one or more destinations, follow these steps :

  1. On the left menu, go to Virtualmin Settings -> Virtual Server Replication.
  2. Click on Add a new replication configuration.
  3. Choose the machine to copy from in the Source system menu.
  4. Select the machines to copy to in the Destination systems field, by using the right-arrow button to move them to the right-hand list.
  5. Select the virtual servers to copy from the Virtualmin domains to replicate. Only those on the source system can be selected.
  6. Assuming you want replication to happen automatically on schedule, change the Replication enabled? field to Yes.
  7. Select a schedule in the When to replicate field.
  8. Enter an email address to notify about failures in the Send email on failure to field.
  9. Click the Create button.

One replication has been setup, you can change what gets copied and to where by clicking on an entry in the Virtual Server Replication list. Replication configurations can also be deleted and started manually on the same page.

Setting Up Global Configuration Replication

To instead copy global settings like plans between systems running Virtualmin, follow these steps :

  1. On the left menu, go to Virtualmin Settings -> Virtual Server Replication.
  2. Click on Add a new replication configuration.
  3. Choose the machine to copy from in the Source system menu.
  4. Select the machines to copy to in the Destination systems field, by using the right-arrow button to move them to the right-hand list.
  5. Open the Advanced replication settings section, and check the boxes for the global settings you want copied.
  6. Assuming you want replication to happen automatically on schedule, change the Replication enabled? field to Yes.
  7. Select a schedule in the When to replicate field.
  8. Enter an email address to notify about failures in the Send email on failure to field.
  9. Click the Create button.

Replication

Cloudmin replication allows you to setup one or more additional systems as backup replicas, which can take over management of all your other systems if the primary master fails. It is only available in Cloudmin 4.0 or later, and each replica must also be running Cloudmin 4.0 or above.

What Gets Replicated

When replication is enabled, Cloudmin will copy the following to all replicas :

  1. The details of all managed systems, such as their hostnames, IPs, current status and login information.
  2. Global settings like plans, bandwidth monitoring, alerts, backup schedules, Virtualmin replication configurations and module configuration.
  3. System owner accounts and all associated statistics.
  4. Any system images stored on the Cloudmin master.

Replication is done by default every 5 minutes, just after the status of all managed systems is collected. It is always done in the background, so any delay sending changes to replicas does not effect the Cloudmin user interface.

Replication does not include the status of the Cloudmin master system itself, as it makes no sense to replicate this to backup masters which will be collecting their own status. It also does not include any system images that are not stored on the master.

If the Cloudmin master is also acting as a host for virtual systems, they will not be included in replication - except for their status.

Setting Up a Replica

The process for setting up a new Cloudmin replica is :

  1. Choose a system to be the backup replica, and install Cloudmin 4.0 or later on it. Either an empty system or one running Virtualmin can be used.
  2. Login to Cloudmin on the replica, and go to Cloudmin Settings -> Cloudmin Replication.
  3. Select the Replica of another system option, and click Save.

From this point on, the system will be switched to a read-only replica state, and will wait for replication connections from the master you setup in the next section. You can still use Cloudmin on the replica to view the details of all managed systems and global settings, but will not be able to change anything.

Setting Up the Master

To configure a system to copy settings to one or more Cloudmin replicas, the steps to follow are :

  1. Make sure the replicas are already on the list of managed systems - if not, add them first.
  2. Login to Cloudmin, and go to Cloudmin Settings -> Cloudmin Replication.
  3. Select Replicate configuration to, and choose the replica systems from the list to the right.
  4. Click Save.

After saving, all replicas will be checked to ensure that they are reachable and are setup as replicas. An initial replication of all settings will then be done - this may take several minutes or more if the current master has a large number of system images stored locally, as they will need to be sent to all replicas.

Dealing With Master Failure

If your original Cloudmin master system fails and you have a single replica, it can be switched to become the new master as follows :

  1. Login to Cloudmin, and go to Cloudmin Settings -> Cloudmin Replication.
  2. Select Stand-alone Cloudmin system, and click Save.

The system should now be a fully usable Cloudmin replica, with all global settings and system state from the last replication sync from the old master.

If you had multiple replicas to start with, in the case of master failure the steps are :

  1. Pick one replicate to be the new master, and login to Cloudmin on it.
  2. Go to Cloudmin Settings -> Cloudmin Replication.
  3. Select Replicate configuration to, and make sure only the other replicas are selected. Then click Save.

Running Windows under Xen

This documentation was contributed by Scott Grayban ( sgrayban @ gmail.com ). They are specific to Debian, and may need modification for other Linux distributions :

  1. Pre-Requisites for Installing a Windows Xen Guest

    A XEN kernel must be installed and running at boot time.

    Make sure you have HVM/VMX enabled in the bios - if you don't have this you can't run windows

    In console type xm dmesg | grep VMX

    You should see...

    (XEN) HVM: VMX enabled

    If you don't you will need to restart the server and get into the BIOS and look for an option related to virtualization support.

    If your BIOS does not have this you can not run any HVM guests, that means you can not run any version of Windows.

  2. Turn off VNC for all xen linux guests and restart them.

  3. Run vi /etc/xen/scripts/qemu-ifup and enter :

    #!/bin/sh
     
    echo -c 'config qemu network with xen bridge for '
    echo $*
     
    ifconfig $1 0.0.0.0 up
    brctl addif eth0(your bridge) $1
     

  4. Change to the xen directory for the rest of the steps with cd /xen/

    Create blank 80GB disk image with : dd if=/dev/zero of=xenwin.img bs=1024k seek=81920 count=0

    apt-get install libcdio-utils

    Get cd/dvd info and make sure its the right one cd-info /dev/(s|h)da

    Create the WindowsXP ISO dd if=/dev/(s|h)da of=Windows.iso

  5. Run vi xenwin.cfg and enter :

    kernel = "/usr/lib/xen-default/boot/hvmloader"
    builder = 'hvm'
    vif = [ 'type=ioemu,bridge=eth0,ip=assigned-ip,mac=22:61:34:00:00:01' ] MAC address has to start with 22:61:34 or 00:16:3e
    address = 'assigned-ip'
    netmask = '255.255.255.XXX'
    memory = 1024
    shadow_memory = 8
    name = "xenhvm" # domain prefix name
    cdrom = 'file:/xen/Windows.iso' # name of iso image you created above
    disk = [ 'file:/xen/xenwin.img,hdc,w', 'file:/xen/Windows.iso,hdb:cdrom,r' ]
    device_model = '/usr/lib/xen-default/bin/qemu-dm'
     
    # boot on floppy (a), hard disk (c) or CD-ROM (d)
    # default: hard disk, cd-rom, floppy
    #### boot must be dc to install windows after that you change it to c or cd
    boot = "dc"
    #boot = "c"
     
    vnc = 1 # use VNC to insall and setup windows after that is done you can disable this
    vncconsole = 0
    vncpasswd = 'password'
    vncviewer = 1
    vncunused = 1
    vnclisten = 'Domain-0 IP'
    vcpus = 2 # number of cpu's to assign
    stdvga = 0
    serial = 'pty'
    usbdevice = 'tablet' # Required for USB mouse
    on_reboot = 'restart'
    on_crash = 'restart'
     

  6. Run the next 2 commands at the console

    xm create xenwin.cfg

    brctl show

    Make sure that the tapX interface is assign to ethX you set in bridge= vif setting

  7. Type the next command at the console :

    vncviewer assigned-ip

    and continue with the windows install and setup

  8. Setup your windows networking using the correct IP/mask/gateway/dns Setup remote desktop access if you need/want it

  9. Turn VNC off in the xenwin.cfg file by setting vnc = 0

    This step has to be done because XEN/qemu-dm will force the port to be 5900 and it will interfere with the other xen linux vnc guests.

  10. Re-enable vnc for the xen linux guests if you turned them off in Step 2 and restart the guests.

  11. Import the windows instance into Cloudmin at Add System -> Add Xen instance

  12. You're done.

    You should be able to access the windows server via RDP(remote desktop) as Administrator and start/stop/reboot and manage the windows guest as a normal windows server.

    That means you can run the updates or install any windows apps that you might need.

    Note - The default passwords for Administrator and new user is temp1234 if you are using the paid version of my WindowsXP img file that is fully functional and ready to use.

    YOU MUST HAVE already bought WindowsXP and have a valid license to get the XEN img file, at order time you will have to electronically sign that agreement. Cloudmin might offer a free Windows ISO at some point.

    For information above pricing of Xen Windows images, see http://www.borgnet.net/clients/knowledgebase/13/Debian-Lenny-WindowsXP-H...

Setting Up Citrix Xen Virtualization

Citrix Xen (formerly from XenSource) is a commercial variant of Xen that uses the same underlying concepts and kernel as open source Xen, but a completely different set of command-line tools. Cloudmin supports Citrix Xen as a virtualization type, but treats it differently from regular Xen due to differences in the disk format used, API and capabilities.

Installing a Citrix Xen Host System

Citrix provides an ISO image for a Linux installer that can setup a new system as a Xen host, which can be downloaded from http://www.xensource.com/ . As far as I know, they do not have an installer which works on existing Linux systems, so you will need to dedicate one or more physical systems to Xen hosting.

Once a host system has been setup for Citrix Xen, you can configure Cloudmin to manage it as follows :

  1. Login to Cloudmin and go to Add System -> Add physical system , and add the new Citrix Xen host. You will need to enter the SSH password you selected when the host was setup.
  2. Go to Host Systems -> Citrix Xen Host Systems and click on Register a system for Citrix Xen hosting.
  3. Select the host you added in step 1, and select a DNS zone to add new VMs to in the Add Citrix Xen systems to DNS domain menu.
  4. Under Network options select or enter the IP ranges you want to assign to VMs on this host.
  5. Click the Save button.
  6. Go to Cloudmin Settings -> New System Images and download at least one Citrix Xen image.
  7. You should now be able to create new virtual systems at Create System -> Create Citrix Xen VM

Adding an Existing Citrix Xen Host System

If you are already using Citrix Xen on your network, you can have Cloudmin take over management of existing VMs as follows :

  1. Login to Cloudmin and go to Add System -> Add physical system , and add the existing Citrix Xen host. You will need to enter the SSH password you selected when the host was originally setup.
  2. Go to Host Systems -> Citrix Xen Host Systems and click on Register a system for Citrix Xen hosting.
  3. Select the host you added in step 1, and select a DNS zone to add new VMs to in the Add Citrix Xen systems to DNS domain menu.
  4. Under Network options select or enter the IP ranges you want to assign to any future VMs on this host.
  5. Click the Save button.
  6. Go to Add System -> Add Citrix Xen VM.
  7. In the Internet hostname field, enter either the IP address or a resolvable hostname for the VM being added.
  8. In the SSH login mode section, enter the root password for Linux on the VM.
  9. From the Citrix Xen VM menu select the name of the VM you want to import.
  10. Click the Add System button.
  11. Repeat steps 6 to 10 for each system you want to import.

Setting Up KVM Virtualization

KVM virtualization is included in the 2.6 Linux kernel, so all recent distributions support it without the need to install a custom kernel. However, it depends on the CPU supporting either the Intel VT or AMD-V virtualization extensions in order to run virtual systems at a reasonable speed.

On some systems, these extensions are disabled in the BIOS by default. Enabling them requires booting the system from the console, entering the BIOS menu and finding the option to turn on virtualization extensions. In some cases the system must then be fully shut down and started up again for this change to take effect.

For KVM instances to access the host system's network, you must setup a network bridge. These instructions assume that your host system has only one network interface, and it is eth0 .

Setting up a Fedora, CentOS or Redhat Host System

To setup a Redhat-based system to host KVM instances, the steps to follow are :

  1. SSH in as root and install the KVM packages with the command yum install kvm qemu qemu-img parted
  2. In the /etc/sysconfig/network-scripts directory, copy ifcfg-eth0 to ifcfg-br0.
  3. Edit the new file and change the DEVICE line to DEVICE=br0.
  4. Edit the ifcfg-eth0 file, and at the bottom add the line BRIDGE=br0
  5. Apply the network settings with the command service network restart . This should be done at the console, as it will break network access to the host system if anything goes wrong.

Setting up a Debian or Ubuntu Host System

  1. SSH in as root and install the KVM packages with the command apt-get install kvm qemu parted
  2. Edit the /etc/network/interfaces file and change it to be like :
    auto eth0 lo br0
     
    iface lo inet loopback
     
    iface eth0 inet manual
     
    iface br0 inet static
       address 192.168.1.1
       netmask 255.255.255.0
       broadcast 192.168.1.255
       network 192.168.1.0
       gateway 192.168.1.10
       bridge_ports eth0
       bridge_fd 9
       bridge_hello 2
       bridge_maxage 12
       bridge_stp off
  3. Apply the network settings with the command /etc/init.d/networking restart or by rebooting . This should be done at the console, as it will break network access to the host system if anything goes wrong.

Adding a New Host System

  1. Install Webmin on the host system, if it isn't already.
  2. Create a directory for storing KVM instance image files, typically /kvm . This can be located anywhere on the system though.
  3. Add the host system to Cloudmin at Add System -> Add physical system, if it isn't already.
  4. Go to Host Systems -> KVM Host Systems, click the Register a system for KVM hosting link and select your new host machine.
  5. Enter the directory you want to use for storing KVM instances, an IP range to allocate to virtual systems, and a DNS domain to add new systems to.
  6. Click the Register button.

Setting Up LVM for Xen or KVM

Why Use LVM?

Cloudmin supports storing Xen and KVM disk images in LVM logical volumes, instead of regular files. This has the speed advantage of avoiding the overhead of going through the filesystem layer on the host system, and can also make adding disk space for virtual systems easier. However, the downside is increased management complexity, as disk images in LVs cannot be easily managed with Linux tools like mv and scp.

Host System Requirements

For a Xen or KVM host system to use LVM, it must either have been installed with its filesystems on LVM already, or have free disks that can be used to create an LVM volume group. If a volume group already exists, it must have some free space for new logical volumes.

For increased reliability, we recommend running LVM on top of RAID. For example, a system with 4 disks could have them combined into a Linux software RAID 5 group, which is then used as the underlying physical volume for an LVM volume group. If this ever fills up, 4 more disks could be installed as another RAID 5 set and then added to the volume group as other physical volume.

For Cloudmin to make use of LVM on a host system, it must have Webmin installed. The simplest way to do this is to select the host from the left menu, then go to System Operations -> Install Webmin. Once Webmin is installed on the host, you can use its LVM and RAID modules under the Hardware category to setup volume group.

In the simplest case where you have two extra empty disks and want to add them to a new volume group, you could do the following in Webmin on the host system :

  1. Go to Hardware -> Partitions on Local Disks, and click on the first new disk.
  2. If any partitions exist already, delete then. Then create a new primary partition that spans the whole disk with the Type menu set to Linux LVM.
  3. Do the same for the second and any other disks.
  4. Go to Hardware -> Logical Volume Management.
  5. If a volume group already exists, click the Physical volumes tab, then click Add a physical volume and add the disk you setup above. Then do the same for any other disks.
  6. If no volume groups exist yet, click the Add a new volume group link. Enter a name like "xenvg" and select the first of your new disks, then click Create. Once the creation is done, add any other disk to the volume group.

Host System Configuration

Once a volume group has been created, you can configure Cloudmin to use it as follows :

  1. Login to the Cloudmin master system, and go to Host Systems -> Xen Host Systems (or KVM Host Systems) , and click on the host you just setup LVM on.
  2. From the LVM volume group for disk images menu, select the new volume group, then click Save.
  3. Create a test Xen or KVM system on this host, and make sure it works properly. Once it is done, go to Resources -> Manage Disks, and you should see the first virtual disk stored in a logical volume.

Setting Up Linux Open Source Xen Virtualization

While many different Linux distributions include packages for Xen, this page focuses on CentOS 5 and Redhat Enterprise 5, which we have found to be well supported and easy to setup. To make full use of Xen, you should be running one of these distributions on a machine with plenty of RAM (2 GB or more), enough disk space for all the filesystems of instances you want to host, and a CPU that supports either Intel's VTI extensions or AMD Pacifica.

This documentation relates to the open source version of Xen only - the commercial variant supported by Citrix is treated separately by Cloudmin, and is covered on the Citrix Xen page.

Cloudmin GPL

The Cloudmin GPL install script should install a Xen-capable kernel and all other required packages
on the system it is run on, so none of the steps here are needed. All you need to do is reboot the system
after running the installer, and then verify that the kernel includes Xen support by running uname -r .

CentOS 5

Once you have a freshly installed system running CentOS 5, the steps to set it up for Xen hosting are :

  1. Login as root via SSH or at the console.
  2. Install the Xen kernel with the command
    yum install kernel-xen kernel-xen-devel
  3. Once the new kernel has been installed, an entry for it will be automatically added to /boot/grub/menu.lst like :
    title CentOS (2.6.18-8.1.4.el5xen)
            root (hd0,2)
            kernel /xen.gz-2.6.18-8.1.4.el5
            module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
            module /initrd-2.6.18-8.1.4.el5xen.img
  4. Edit /boot/grub/menu.lst and change the default= line to use the newly added Xen kernel, which will typically be the first one in the file (numbered 0).
  5. Install the Xen commands package with the command
    yum install xen
  6. Disable the virbr0 Qemu network interface with the command
    cat /dev/null >/etc/libvirt/qemu/networks/default.xml
  7. Make sure SElinux is disabled by editing /etc/sysconfig/selinux and changing the SELINUX line to SELINUX=disabled .
  8. Reboot the system with the reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.
  9. Verify that Xen is working with the command :
    xm list

    If you see a line starting with Domain-0, then all is good.

  10. Create the /xen directory, which Cloudmin uses by default for Xen system images, with the command
    mkdir /xen

And that's it! You can now register this system as a Xen host in Cloudmin.

Redhat Enterprise 5

If your RHEL 5 system has the yum command installed and working, you can follow the exact same steps above. If not, use Redhat's up2date command instead :

  1. Login as root via SSH or at the console.
  2. Make sure all packages are up to date and your Redhat Enterprise subscription is working by running the command :
    up2date -u
  3. Install the Xen kernel with the command
    up2date kernel-xen kernel-xen-devel
  4. Once the new kernel has been installed, an entry for it will be automatically added to /boot/grub/menu.lst like :
    title Redhat Enterprise (2.6.18-8.1.4.el5xen)
            root (hd0,2)
            kernel /xen.gz-2.6.18-8.1.4.el5
            module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
            module /initrd-2.6.18-8.1.4.el5xen.img
  5. Edit /boot/grub/menu.lst and change the default= line to use the newly added Xen kernel, which will typically be the first one in the file (numbered 0).
  6. Install the Xen commands package with the command
    up2date xen
  7. Disable the virbr0 Qemu network interface with the command
    cat /dev/null >/etc/libvirt/qemu/networks/default.xml
  8. Make sure SElinux is disabled by editing /etc/sysconfig/selinux and changing the SELINUX line to SELINUX=disabled .
  9. Reboot the system with the reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.
  10. Verify that Xen is working with the command :
    xm list

    If you see a line starting with Domain-0, then all is good.

  11. Create the /xen directory, which Cloudmin uses by default for Xen system images, with the command
    mkdir /xen

Ubuntu Linux 8.04

  1. Login as root via SSH or at the console.
  2. Update your package database with the command :
    apt-get update
  3. Install the Xen capable kernel and support packages with the command :
    apt-get install ubuntu-xen-server libc6-xen xen-tools xen-utils-3.2 xen-hypervisor-3.2
  4. Edit /boot/grub/menu.lst and change the default= line to use the newly added Xen kernel, which will typically be the first one in the file (numbered 0).
  5. Reboot the system with the reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.
  6. Verify that Xen is working with the command :
    xm list

    If you see a line starting with Domain-0, then all is good.

  7. Create the /xen directory, which Cloudmin uses by default for Xen system images, with the command
    mkdir /xen

Debian Linux 4.0 / 5.0

  1. Login as root via SSH or at the console.
  2. Update your package database with the command :
    apt-get update
  3. Install the Xen capable kernel and support packages with the command :
    apt-get install xen-linux-system libc6-xen xen-tools xen-utils-3.2-1 xen-hypervisor-3.2-1-i386

    On a 64-bit system, replace the xen-hypervisor-3.2-1-i386 package above with xen-hypervisor-3.2-1-amd64.

  4. Edit /boot/grub/menu.lst and change the default= line to use the newly added Xen kernel, which will typically be the first one in the file (numbered 0).
  5. Reboot the system with the reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.
  6. Verify that Xen is working with the command :
    xm list

    If you see a line starting with Domain-0, then all is good.

  7. Create the /xen directory, which Cloudmin uses by default for Xen system images, with the command
    mkdir /xen

Setting Up Linux OpenVZ Virtualization

Installing the OpenVZ Kernel

The simplest Linux distribution to setup OpenVZ hosting support for is CentOS, as a kernel and packages are supplied by the OpenVZ developers at http://wiki.openvz.org/Main_Page . The steps to install the kernel are on a CentOS 5 system are :

  1. Setup the OpenVZ YUM repository with the commands :
    cd /etc/yum.repos.d
    wget "http://download.openvz.org/openvz.repo"
    rpm --import "http://download.openvz.org/RPM-GPG-Key-OpenVZ"
  2. Install the kernel with the command yum install ovzkernel . Or if you want a kernel that can host both Xen and OpenVZ, use yum install ovzkernel-xen .
  3. Edit /boot/grub/menu.lst and make sure the default= line refers to the new OpenVZ-capable kernel section - typically this will need to be set to default=0
  4. Edit /etc/sysctl.conf and append the following lines :
    # On Hardware Node we generally need
    # packet forwarding enabled and proxy arp disabled
    net.ipv4.ip_forward = 1
    net.ipv6.conf.default.forwarding = 1
    net.ipv6.conf.all.forwarding = 1
    net.ipv4.conf.default.proxy_arp = 0
     
    # Enables source route verification
    net.ipv4.conf.all.rp_filter = 1
     
    # Enables the magic-sysrq key
    kernel.sysrq = 1
     
    # We do not want all our interfaces to send redirects
    net.ipv4.conf.default.send_redirects = 1
    net.ipv4.conf.all.send_redirects = 0
  5. Edit /etc/sysconfig/selinux and change the SELINUX= line to SELINUX=disabled
  6. Reboot the system, and verify that it boots into the new kernel.

Installing OpenVZ Utilities

Once you have the kernel on the host system, other needed utilities can be installed as follows :

  1. Install the OpenVZ tools with : yum install vzctl vzquota
  2. Start the OpenVZ daemon with : /etc/init.d/vz start
  3. Run the command vzlist -a to verify that the tools are working and kernel support is usable.

Once this is done, you can add this system as an OpenVZ host in Cloudmin at Host Systems -> OpenVZ Host Systems .

Setting Up Linux VServer Virtualization

Kernel Installation

Linux VServers require kernel support in the host system that can only be provided by a kernel patch. Unfortunately this does not appear to be included in any of the kernels available from mainstream distribution vendors. However, a pre-compiled kernel package for Fedora Core 5 is available, and can be installed by following the steps below :

  1. Disable SELinux by editing /etc/selinux/config and changing the SELINUX line to :
    SELINUX=disabled
  2. Make sure all packages are up to date by running
    yum upgrade
  3. To prevent the custom kernel we are going to install from being replaced, edit the file /etc/yum.repos.d/fedora-updates.repo and in the updates-released section add the line exclude=kernel kernel-smp yum . The section should end up looking something like :
    [updates-released]
    name=Fedora Core $releasever - $basearch - Released Updates
    #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/
    mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc$releasever
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
    exclude=kernel kernel-smp yum
  4. Create the file /etc/yum.repos.d/dhozac.repo containing :
    [dhozac-vserver]
    name=Daniel Hokka Zakrisson's packages for Fedora $releasever - $basearch - vserver
    baseurl=http://rpm.hozac.com/dhozac/fedora/$releasever/vserver/$basearch
      http://muh.at/dhozac/fedora/$releasever/vserver/$basearch
    gpgkey=http://rpm.hozac.com/fedora/conf/keys/RPM-DHOZAC-GPG-KEY
    enabled=1
  5. Install the kernel with VServers support with the command yum install kernel , or if you are using an SMP system yum install kernel-smp . The reboot with the reboot command.
  6. To validate that the VServers kernel is now running, make sure the file /proc/virtual/info exists. It should contain something like
    VCIVersion:     0002:0001
    VCISyscall:     273
    VCIKernel:      03000016
  7. Install the VServers support programs with the command :
    yum install util-vserver util-vserver-core util-vserver-lib util-vserver-sysv util-vserver-build

Mandriva Install

Use URPMI

urpmi kernel-vserver-latest kernel-vserver-source-latest util-vserver util-vserver-build util-vserver-core util-vserver-sysv util-vserver-lib

For other distributions, you will almost certainly need to compile a patched kernel manually. The official VServers website at http://linux-vserver.org/Documentation has more details.

Binding Ports to Primary IP Address

One limitation of VServers network is that a server listening on some port on all interfaces on the host will prevent that port from being used within VServer instances. For example, if Apache is using port 80 on all interfaces (as it does by default), then no systems running within VServers will be able to run Apache!

The suggested solution to this problem is to run only a minimal set of services on the host system, such as SSH and Webmin. All others like Apache, Sendmail, Postfix, BIND and ProFTPd should be shut down or un-installed.

To use Webmin to configure itself and SSH to listen only on the host system's primary interface, follow these steps :

  1. Login to Webmin on the VServers host system.
  2. Go to the Network Configuration module in the Networking category, click on Network Interfaces and note the IP address of the primary interface, typically eth0. For the sake of these instructions, let's say it is 192.168.10.10.
  3. Open the Webmin category and click on Webmin Configuration, then on the Ports and Addresses icon.
  4. Under Bind to IP address select Only address.. from the menu, and enter the IP (192.168.10.10) into the text box next to it.
  5. Click the Save button.
  6. Open the Servers category and click on SSH Server, then on the Networking icon.
  7. In the Listen on addresses table select Entered below .., and in the Address field enter 192.168.10.10. Then click Save.
  8. Back on the main page of the SSH server module, click the Apply Changes button.

To use Webmin to shut down other services that may use ports needed by Virtualmin in VServers, do the following :

  1. Login to Webmin, open the System category and click on Bootup and Shutdown Actions.
  2. Check the boxes next to actions with names like apache , httpd , sendmail , postfix , named , proftpd , vsftpd , dovecot and mysql .
  3. At the bottom of the page, click the Disable Now and On Boot button.

Setting Up Solaris/OpenSolaris Zones Virtualization

Solaris versions 10 and above on both X86 and Sparc hardware come with support for Zones installed as standard. Therefore, the steps to configure a system as a Zones host for use by Cloudmin are relatively simple :

  1. Download and install the latest version of Webmin from http://www.webmin.com/download.html . The commands to do this are :
    cd /tmp
    wget http://www.webmin.com/download/webmin-current.pkg.gz
    gunzip webmin-current.pkg.gz
    pkgadd -d webmin-current.pkg WSwebmin
    
    
  2. Login to Webmin at http://yourserver:10000/ as root with your system's root password, to make sure that it is running.
  3. Create the directory that Cloudmin will use for Zones filesystems, with the command
    mkdir /zones

System Monitoring and Alerts

Introduction to Alerts

A Cloudmin system alert monitors one or more managed systems, and checks if variables such as free memory, CPU load or free disk space are above or below some threshold. If so, it can send email to the master administrator, system owners or other addresses.

Alerts can be used to detect overloaded systems, lack of resources, or system crashes. They can be limited to a sub-set of the hosts managed by Cloudmin, either selected explicitly or by group membership, virtualization type or owner. This allows alert thresholds to be tailored based on the systems be monitored.

Alerts can be found under the System Monitoring category on the left menu, on the System Alerts page. They are only available in Cloudmin versions 3.7 and later though.

Creating a New Alert

Before you create a new alert, you need to decide which system variable(s) it is going to monitor, what thresholds it will trigger at, and for how long it must be exceeded. For example, you might want to check if CPU load exceeds 1.0 for 30 minutes, or free memory is under 64M for 1 hour.

To create an alert, follow these steps :

  1. Open the System Monitoring category on the left menu, and click on System Alerts .
  2. Click the Add a new system alert link to bring up the alert creation page.
  3. In the Systems to monitor for this alert section, choose the hosts that you want to monitor. They can be chosen by hostname, group, owner or type, or you can select to monitoring all systems. 1 The Exclude down or un-managable systems box can be checked to ignore systems that have been intentionally shut down. This should not be used if you are creating an alert to actually fire when a system is down though.
  4. In the Conditions to trigger alert section, you can enter one or more rules that will be checked when this alert is evaluation. Each rule has the following columns :
    • Variable - The data point collected from each system that the rule will compare
    • Comparison - Set this to Over to have the rule trigger if the variable is over some limit (ie. CPU load), or Under to trigger if below (ie. Memory free).
    • Value - The threshold at which the rule will match. You can use suffixes like MB and GB for rules matching memory or disk space.
    • Time period - How long the variable must be over or under the threshold value for this rule to trigger. Don't enter anything less than the Cloudmin status collection interval of 5 minutes, or the rule will never match.
    • Minimum systems - The number of hosts on which this rule must match for the alert to fire.
  5. By default all conditions must be true for the alert to trigger. However, you can select Trigger alert when any condition is true to change this.
  6. In the Alert notifications, select who will receive email notifications when the alert fires. The default is to only email the Cloudmin master administrator, whose address is set on the Email Settings page.
  7. To limit the rate at which email is sent if the alert continues to fire, fill in the Interval between messages field.
  8. Click the Create button.

Once the alert is created, it will appear in the list of alerts, with its current status shown in the right-hand column.

When creating an alert rule that matches if a system is down (using the System up variable), the comparison should be set to Under and the value to 1. Cloudmin uses the value 0 to indicate a system is completely down, 0.5 when it is up by not contactable via SSH, and 1 for a fully operational host.

Managing Alerts

To edit an alert, just click on it in the System Alerts page. All the same settings that you entered when creating it originally can be modified.

To remove one or more alerts, check the boxes next to them on the System Alerts page, and click the Delete Selected Alerts button.

When any rule on any alert matches at least one system, it will be displayed in the Firing alerts section of the System Alerts page - even if not enough systems or rules match to cause the alert to email. You can view the history of the variable that caused it to fire by clicking the Graph link in the right-most column.

Silencing Alerts

To stop an alert from sending email without actually deleting it, check the box next to it on the System Alerts page, and click the Silence Alerts button. Similarly, to remove the silence use the Un-Silence Alerts button. This can be useful when you are creating or debugging a new alert and don't want it sending out spurious email notifications.

System Owners

Introduction To System Owners

A system owner in Cloudmin is an additional account who is granted limited access to some virtual systems. They are typically created for customers of a VPS hosting business, and given permission to manage only their own systems. Owner accounts can also be granted the right to expand, delete and move virtual systems, up to limits defined by a plan.

Cloudmin also supports the creation of new virtual systems by owners, if enabled on their plans. You can define an upper limit on the number of systems each owner can create, and any additional disk, RAM or CPU use will count towards plan limits. A VPS hosting company can then create an owner account for each customer and leave the actual creation and deletion of systems up to the owners.

Creating and Managing Owner Accounts

To create a new system owner account, do the following :

  1. First create or edit a plan that contains the limits you want applied to this owner, as documented on the Account Plans page.
  2. Go to Cloudmin Settings -> System Owners , and click Add a new system owner.
  3. Fill in the Login username field with a unique username, like "joe".
  4. Fill in the Login password field.
  5. Enter the customer's email address in the Contact email address field.
  6. To allow the new owner to manage some existing systems, select them the Systems that can be managed list.
  7. Under Limits and restrictions, select the account plan the defines the limits for this owner.
  8. Click the Create button.

Once an owner has been created, he will appear in the list on the System Owners page. Click on his name to edit him, or check the box next to his username and click Delete Selected Owners to remove him.

Owner accounts can also be temporarily disabled or enabled on the same page, such as for non-payment. To disable, check the boxes next to the names of accounts to turn off and click the Disable Selected Owners button. Use the Enable button to turn the accounts back on. Disabling an owner has no effect on his running virtual systems.

System Owners and Backups

Cloudmin has backup and restore capabilities to save the filesystem contents of virtual systems. System owners can also be allowed to create their own backups, either to a central storage location defined by the master administrator or remote SSH and FTP servers.

To allow owners to create their own backups, do the following :

  1. Make sure that each of your host systems has a default backup location set, as documented on the backup and restore page.
  2. Go to the Account Plans page and click on a plan whose owners you want to allow.
  3. Fill in the Maximum space for backups field with the amount of disk space each owner should be able to consume for backups on central storage.
  4. In the Plan restrictions section, check the Backup and restore systems box.
  5. Click Save and Apply.

System owners will now see the backup and restore category on the left menu when they login.

When backing up to the destination defined by the host system, a sub-directory will be created for each owner to avoid over-writing of each others files. Each owner can create his own scheduled backups for his systems, and will be notified via email if they fail. Owners can also find, restore and delete old backups using the Backup Logs page.

Usage Accounting

Cloudmin keeps track of the uptime, CPU and RAM used by each virtual system over time, and can summarize it for the current accounting period (such as the current week or month). For example, if an owner had two systems with 512MB RAM and 1GB of disk each that were up for 2 and 3 days respectively over the week and used 10% CPU on average, his usage would be :

  • Uptime : 2 x 24 + 3 x 24 = 125 hours
  • Memory used : 2 x 24 x 512MB + 3 x 24 x 512MB = 62.5 GB hours
  • CPU used : 2 x 24 x 10% + 3 x 24 x 10% = 125 percent hours
  • Disk allocated : 2 x 24 x 7 = 336 GB hours

To see usage for an owner, click on his name in the System Owners list and open the Usage by all owned systems section. This is also available from the list-owners API command. How you use this information is up to you, but it could be used for usage-based billing for VPS hosting customers.

The accounting period is the same as that set for Bandwidth Monitoring, at Cloudmin Settings -> Bandwidth Monitoring.

API Access By System Owners

If the Call remote API action is allowed for a system owner or his plan, the owner will be able to call the Cloudmin API via HTTP to manage his systems. Owners will only be able to perform the same actions on the same systems via the API that they would be able to do via the web interface, so there is no additional security risk to enabling this. In Cloudmin 4.1 and later, it is turned on by default.

For more documentation on the API, see http://www.virtualmin.com/documentation/cloudmin/devel/remote

Upgrading Cloudmin Software

Upgrading via the Cloudmin UI

In a standard install of Cloudmin using our scripts, upgrades are typically done using APT or YUM. When a new version is available, you will see a message on the System Information page after logging in like :

Other packages may be listed too, depending on what is available to be updated. To install, just click the Install All Updates Now button.

Upgrading from the command line

Alternately, you can install the same packages from the command line on the master system as root. On CentOS or Redhat Enterprise, the command to use will be like :

yum install wbm-server-manager

On Debian or Ubuntu, you could use :

apt-get install webmin-server-manager

Usage Accounting

What is Usage Accounting?

Cloudmin checks the state of all virtual systems every 5 minutes and collects their status (up or down), assigned RAM, CPU limit, CPU load and disk space. Each sample is recorded in an internal database, and can be used to generate usage totals over an accounting period (such as a week or month). This can then be used to charge customers based on the actual resources used by their system or systems.

The accounting period over which usage is display is the same one used for bandwidth monitoring, set at Cloudmin Settings -> Bandwidth Monitoring. The default is the current month, but it can be changed to the current day, week, or any number of days in the past. In the latter case, the period is actually a sliding window of time instead of fixed non-overlapping blocks.

Usage Accounting Examples

Imagine a virtual system that has 512MB of RAM, 1 GB of disk and a CPU limit of 50%, which has been up for 1 hour a day over the last month, and used an average of 10% CPU during that time. Cloudmin would calculate its resource usage as follows :

  • System uptime : 30 hours
  • Memory used : 512MB x 30 hours = 15 GB hours
  • CPU allocated : 50% x 30 hours = 1500 percent hours
  • CPU used : 10% x 30 hours = 300 percent hours
  • Disk allocated : 1GB x 24 hours x 30 days = 720 GB hours

Note that disk use is still counted even when the system is down, as the space is still consumed on the host system. For Xen systems Cloudmin considers the disk space assigned and used to be the same, as free space on a disk image cannot be used by other systems. For OpenVZ containers it tracks the disk limit and disk usage separately.

Extracting Usage Information

The simplest place to see usage for a virtual system is on the Edit System page, in the Resource usage section. If you need to extract this for billing purposes, you can use the list-systems API call with the multiline parameter, which will include the current accounting period's usage in the output. To select a previous period, use the period-ago parameter following the a number of weeks or months in the past.

To get individual usage samples for a system, use the list-usage API command. For example, you could call this from the command line like so :

# vm2 list-usage --host xencentos.home
xencentos.home
 Start              End                Up?  Memory     CPU    Load   Disk
 17/Oct/2009 23:50  18/Oct/2009 00:40  Yes  768 MB     100%   8%     11 GB
 18/Oct/2009 00:40  18/Oct/2009 00:45  Yes  768.17 MB  100%   40%    11 GB
 18/Oct/2009 00:45  18/Oct/2009 11:00  No   -          -      -      -
 18/Oct/2009 11:00  18/Oct/2009 11:50  Yes  768 MB     100%   21%    11 GB

It takes start and end parameters to select a specific date range to display samples for. Sample are aggregated by Cloudmin where possible, so a long period of downtime or consistent CPU load will appear as a single row possibly spanning many hours.

Accounting and System Owners

Cloudmin combines the usage for all virtual systems each owner manages and computes a total usage for each owner. For example, if an owner had two systems with 512MB RAM and 1GB disk each that were up for 2 and 3 days respectively over the week and used 10% CPU on average, his usage would be :

  • Uptime : 2 x 24 + 3 x 24 = 125 hours
  • Memory used : 2 x 24 x 512MB + 3 x 24 x 512 = 62.5 GB hours
  • CPU used : 2 x 24 x 10% + 3 x 24 x 10% = 125 percent hours
  • Disk allocated : 2 x 24 x 7 = 336 GB hours

To see usage for an owner, click on his name in the System Owners list and open the Usage by all owned systems section. This is also available from the list-owners API command. How you use this information is up to you, but it could be used for usage-based billing for VPS hosting customers.

Using Cloudmin

Introduction to the User Interface

Once Cloudmin is installed, you can login to it by opening a web browser and going to the URL http://mastersystem:10000/ , where mastersystem is the hostname or IP address of the machine on which it is installed. This should bring up a web page with a menu on the left frame, and a display of information about the master system on the right.

The Cloudmin interface is in many ways similar to Virtualmin - managed systems can be selected from a drop-down menu on the left, below which is a list of links for performing various operations on those systems. Below this are menu categories labelled Create System, Add System and Cloudmin Settings. These contain further links for creating new virtual systems, bringing existing virtual or real systems under Cloudmin's control, and editing settings that apply to all managed machines.

At the bottom is the List Managed Systems link, which opens a list of all systems under Cloudmin's control, showing details such as their hostname, current status and virtualization system type. By default, the only registered system will be the machine you are running Cloudmin on.

System Status

Every system managed by Cloudmin has a status, which is determined from either an automatic check (done every 5 minutes), or a manual check triggered by the Refresh Status link. The status can be seen on the left menu directly under the hostname. Possible statuses are :

  • Down The virtual system has been shut down, or a physical system is not responding to pings.
  • Parent host is down For a virtual system, the machine that hosts it is down.
  • No SSH The virtual system appears to be up, but SSH connections fail or timeout.
  • SSH login failed The system and SSH are running, but the <tt>root</tt> login credentials known to Cloudmin are incorrect.
  • No Webmin The system is up and running, but Webmin is not installed.
  • Webmin Down The system is up and Webmin is installed, but it is not running.
  • Webmin Login Failed The system is up and Webmin is running, but the credentials for it known to Cloudmin are incorrect.
  • Webmin but no Virtualmin The system is up and Webmin is installed and running, but the Virtualmin module is missing.
  • Webmin and Virtualmin The system is up, and both Webmin and Virtualmin are installed and available.

The master system will most likely have the status Webmin but no Virtualmin, unless you are also using it to host domains with Virtualmin.

Adding Systems

If you have several running physical systems on your network and want to control them using Cloudmin, they can be added to its list of managed systems as follows :

  1. On the left menu, open the Add System category and click on Add physical system.
  2. In the form that appears, enter the DNS-resolvable hostname or IP address into the Internet hostname field.
  3. In the System description field, enter a short description of the system, such as Primary Virtualmin webserver.
  4. If the system has a root password and root logins via SSH are allowed, in the Root login mode section select Using password and enter the password into the adjacent textbox.
  5. If Webmin is installed on the system to add, in the Webmin login mode field you can typically select Login as root with same password as Unix. If the Webmin login differs from the one you use for SSH, you will need to select Login as instead and enter a valid username and password.
  6. If Webmin runs in SSL mode (meaning that at https: URL is needed to connect), select the Use SSL to connect to Webmin checkbox.
  7. Finally, click the Add System button. If the system can be contacted and Cloudmin can login using the credentials you provided, you will be returned to the list of all managed systems.

Once a system has been added, it can be used to host Virtualmin domains, or virtual systems using Xen or VServers if it has the needed software installed.

Managing Systems

To view the full details of a managed system, click on the Edit System link below its hostname on the left menu. This will bring up a page showing the software versions it runs, current status and login details. If it runs Virtualmin, hosted domains and more detailed system status will also be shown in collapsed sections. If it is a virtual system that Cloudmin can manage network interfaces on, a section listing interfaces will also be available.

For systems that are currently up, you can use the Reboot System and Shutdown System links on the left menu to reboot or turn them off, respectively. Similarly, a virtual system that is down can be started up using the Startup System link. If a system has been rebooted or changed manually since the last Cloudmin automatic check, you can use the Refresh Status link to have Cloudmin fetch the current status.

Connecting to a Managed System

If a managed system has Webmin installed and running, you can connect to it using the Open Webmin link on the left menu. This will open a new browser window which will be automatically logged into the system, with all HTTP requests tunnelled through the Cloudmin master. This is a little slower that connecting directly (by opening the URL for Webmin on that system in your browser), but is more convenient and avoids any connectivity issues that may block access to the system.

Managed systems that are up and can be contacted via SSH can have commands executed on them via the Cloudmin interface by clicking on the Run Commands link on the left menu. This will open a page for entering a shell command, which will display the output from that command when it is run. However, only non-interactive programs can be run - you cannot invoke something like vi or yum which expects user input.

Changing Passwords

To update the root password for SSH or Webmin on a managed system, you can use the Change Password link on the left menu. This will open a form for entering one or both new passwords, which when submitted will update /etc/shadow and /etc/webmin/miniserv.users on the selected machine to make the changes. Cloudmin's authentication information for the system will also be updated to match.

If you have created a virtual system for a customer, changing the root password when you are ready to hand it over is a good idea. Be aware that for Xen systems, if the password is changed on the system directly (perhaps using the passwd command), Cloudmin will be no longer able to login via SSH to change it, or even to check the system's status.

Updating Multiple Systems

Once you have several systems registered, it becomes convenient to perform operations on more than one at once. This can be done as follows :

  1. On the left menu, click on the List Managed Systems link.
  2. Select the checkboxes next to one or more hostnames.
  3. Click on the buttons at the bottom of the list, such as Startup, Shutdown or Refresh Status. For virtual systems, you can use the Delete button to completely destroy them, which will result in any Virtualmin domains they host or other data on their filesystems being lost.
  4. If any systems have package updates available, you can install those updates on all systems in parallel with the Update Packages button.

Virtualmin Licenses

Before you can use Cloudmin to create a virtual system with Virtualmin installed, you must have at least once license that can be used for Virtualmin on that system. Fortunately, Cloudmin has a built-in license management and registration tool, which makes it easy to add and use the licenses you have purchased.

Registering Licenses

To aquire a new Virtualmin license and add it to Cloudmin, follow these steps :

  1. Go the Virtualmin website and purchase a license at http://www.virtualmin.com/shop/ . If you intend to run several virtual systems, it is best to purchase one that can be used on several machines, such as the 10+10 Multi-Pack.
  2. In Cloudmin, open the Cloudmin Settings left-side menu, and click on Virtualmin Licenses.
  3. In the Add Virtualmin license form, enter the serial number and key for the license you just purchased.
  4. Click the Add License button. Cloudmin will validate the serial and key you entered, then return you to the list of registered licences. The number of domains and systems that it is valid for will be displayed.

If you need to add many licenses at once, they can be pasted into the text box at the bottom of the Virtualmin Licenses page. Each should be on a separate line, with the serial number and key separated by a space.

Using Licenses

Once a license has been registered, it can be used when creating a virtual system from an image with Virtualmin, or when installing Virtualmin on a managed system. This is done in the Virtualmin options section of the creation form, using the License for Virtualmin from image field. Assuming that you have at least one registered license with free systems, you can select the Allocate from license pool option to make use of it.

In some cases, your Cloudmin license may also include the rights to be used on one or more Virtualmin installs. In this case, you can select Same as Cloudmin license on the system creation or Virtualmin installation form.

Xen Kernels

Xen Kernel Booting

In a default Cloudmin install, all Xen virtual systems are setup to boot from a kernel file on the host system, typically in the /xen directory and named like vmlinuz-vm2-xenU. However, you may want to use a kernel from within the virtual system instead - this allows different systems to run different kernels, and for the kernel to be upgraded from within the Xen instance.

Xen uses with PyGrub or Pv-Grub to run grub , which in turn reads the /boot/grub/menu.lst file from within the Xen system. The Grub config file contains the path the kernel and other related files, which is then booted when the system is started.

Cloudmin will configure a Xen system to use the newer Pv-Grub bootloader if available, and fall back to PyGrub otherwise. Pv-Grub is recommended as it runs entirely within the virtual system, while PyGrub runs on the host system and thus is considered less secure.

Booting a Xen System From its own Kernel

To create a new Xen virtual system that boots from its own kernel, you will first need a system image that contains a kernel and Grub configuration file. The latest CentOS and Debian images provided by Virtualmin include these - if you have already downloaded images for those distributions, make sure you have version 1.7 or later, and if not re-download them.

Once you have an image that includes a kernel, you can create a system that uses it as follows :

  1. On the left menu, go to Create System -> Create Xen instance.
  2. Fill in the form as you would normally, making sure to select an image that contains a kernel.
  3. Under Advanced options, change the Kernel for Xen instance option to Use kernel from Xen system.
  4. Click the Create System button.

If all goes well, you will see a line in the creation output like setup to boot Xen system's kernel with PyGrub .

If you are creating a system from using the API and want to use the virtual system's kernel, add the --xen-pygrub true command line flag, or xen-pygrub=true URL parameter.

Booting an In-System Kernel By Default

If you want Cloudmin to always setup virtual systems to boot from their own kernels without having to select this at creation time, do the following :

  1. Go to Cloudmin Settings -> Module Config.
  2. Choose Xen settings from the menu.
  3. Change the Default Xen kernel source to From Xen system using PyGrub or Pv-Grub.
  4. Click Save.

This will also effect systems created using the API. You can force the host kernel to be used instead with the --xen-pygrub false command line flag.

Database Management

MySQL

PostgreSQL

SQLite

Oracle

Databases in Virtualmin FAQ - Have questions about database support in Virtualmin?

Database troubleshooting - Troubleshooting common problems with databases in Virtualmin

Databases

All Virtualmin virtual servers with database features enabled can have several MySQL and PostgreSQL databases associated with them. These can be created and deleted from the web interface, or using the following programs.

Developer Documentation

Virtualmin

Command Line API - Command line tools for managing Virtualmin.

Remote API - Remote access to the Virtualmin API.

Writing Virtualmin Plugins - Building Webmin modules that interact with Virtualmin.

Creating Install Scripts - Making applications easily installable with the Virtualmin Install Scripts interface.

Creating New Content Styles - Creating new content styles for the Virtualmin website editor, or converting existing templates for use in Virtualmin.

Cloudmin

Command Line API - Command line tools for managing Cloudmin.

Remote API - Remote access to the Cloudmin API.

Contributing to Virtualmin or Cloudmin

Documentation - Contributing new documentation, commenting on, or editing existing documentation.

Patches - Guidelines for contributing patches to Webmin, Usermin, Virtualmin, and Cloudmin.

Subversion Access - Regular trusted contributors to Webmin, Usermin, and Virtualmin may be granted access to our Subversion revision control repositories. This document covers the basics of using a Subversion checkout of these projects.

Command Line API

Explains how to use the command-line scripts included with Virtualmin to manage users, aliases, servers, databases and resellers.

Introduction

Virtualmin comes a script named virtualmin that can be run from the Unix shell to perform actions that are usually done from the web interface. In fact, almost all actions that can be done in a browser can also be done from the command line, or from shell scripts. This allows virtual server, user and alias creation and management to be done in a more automated function, such as from programs or scripts of your own creation.

The first parameter to the virtualmin command is the operation you want to perform, such as create-domain. Depending on the operation, additional parameters may be needed, such as the name of the domain to create, password and so on. In almost all cases the parameters are given like --domain foo.com.

The virtualmin command must be run as root, as it needs access to system configuration files to create users, set up web sites and so on. If you want to create servers, users and aliases programatically as a different user (such as from your own CGI scripts), see the documentation on the Virtualmin Remote API instead.

All of the operations that make changes to the system output messages indicating their success or failure. Their exit status can also be checked to determine success - an exit status of 0 indicates that everything went OK, while a non-zero status indicates some problem.

All operations can be called with the --help command-line parameter to have them output details of the required and allowed parameters. Alternately, you can run virtualmin help to get a list of all available commands, or virtualmin help command to get information on what a particular command does.

Command Categories

Creating Install Scripts

Script Installers

A Virtualmin script installer is a small program that contains the information needed to install a web application into a virtual server's home directory, and configure it to run with that server's permissions and using its database. Most script installers are for PHP programs like phpMyAdmin, Drupal and SugarCRM, but it is possible to write an installer for Perl, Python or Ruby or Rails applications too.

Virtualmin Pro ships with a large number of built-in installers, which domain owners can add to their websites using the Install Scripts link on the left menu. However, there are many applications that are not covered yet, simply because we don't have time to implement installers for them or they are judged too rarely used or too specific. For this reason, Virtualmin provides an API for adding your own script installers.

Script Installer Files and Directories

Each script installer is a single file containing a set of Perl functions. Those that ship with Virtualmin Pro can be found in the virtual-server/scripts directory under the Webmin root, which is usually /usr/libexec/webmin or /usr/share/webmin . If you open up one of those files (such as phpbb.pl) in a text editor, you will see a series of funtions like :

sub script_phpbb_desc
{
return "phpBB";
}

sub script_phpbb_uses
{
return ( "php" );
}

sub script_phpbb_longdesc
{
return "A high powered, fully scalable, and highly customizable Open Source bulletin board package.";
}

Your own script installers will be in files if a similar format - the major difference will be the script ID, which appears in each function name after the word script_ .

Script installers that are local to your Virtualmin installation are stored in the /etc/webmin/virtual-server/scripts directory. In most cases, each script is just a single .pl file, but it is possible for other source or support files to be part of the script too. In general though, most script installers download the files they need from the website of the application that they are installing.

Script Installer IDs

Every script installer has a unique ID, which must consist of only letters, numbers and the underscore character. The ID determines both the installer filename (which must be scriptid.pl), and the names of functions within the script (which must be like script_scriptid_desc).

The same ID cannot be used by two different installers on the same system, even if one is built-in to Virtualmin and one is custom. For this reason, when writing an installer you should select an ID that is unlikely to clash with any that might be included in Virtualmin in the future. Starting it with the first part of your company's domain name (like foocorp_billingapp) would be a good way to ensure this.

The Lifetime of a Script

Virtualmin allows multiple instances of a single script to be installed, either on different domains or in different directories of the same domain. The installer defines the steps that must be taken to setup a script in some directory - in object-oriented coding parlance, it is like a class, while installed scripts are objects.

When a script is installed via the web interface, Virtualmin performs the following steps :

  1. Checks if all required dependencies are satisfied, such as required commands, a database and a website.
  2. If the script uses PHP, checks that the versions it supports are available on the system.
  3. Displays a form asking for installation options, such as the destination directory and database.
  4. Parses inputs from the form.
  5. Checks if the same script is already installed in the selected directory.
  6. Configures the domain's website to use the correct PHP version.
  7. Downloads files needed by the script, such as its source code.
  8. Installs any needed PHP modules, Pear modules, Perl modules or Ruby Gems.
  9. Calls the script's install function. This typically does the following :
    1. Creates a database for the script, if needed and if requested.
    2. Creates the destination directory.
    3. Extracts the downloaded source into a temporary directory.
    4. Copies the source to the destination directory.
    5. Updates any config files used by the application being installed, so that it knows how to connect to the database and which directory it runs in.
  10. Records the fact that the script has been installed.
  11. Configures PHP for the domain, to set any options that the script has requested.
  12. Restarts Apache.

Script Installer Implementation

In this section, the functions that each script installer must implement will be covered. Not all functions are mandatory - some deal with PHP dependencies that make no sense if your script does not use PHP, or if it has no non-core module or Pear dependencies. The example code for each function is taken from the Wordpress Blog installer, in wordpress.pl. This is a PHP application whose installation process is relatively simple, yet common to many other PHP programs.

In your own script, you would of course replace scriptname with the script ID you have selected.

script_scriptname_desc

This function must return a short name for the script, usually a couple of words at most.

sub script_wordpress_desc
{
return "WordPress";
}

script_scriptname_uses

This must return a list of the languages the script uses. Supported language codes are php, perl and ruby. Most scripts will return only one.

sub script_wordpress_uses
{
return ( "php" );
}

script_scriptname_versions

Must return a list of versions of the script that the installer supports. Most can only install one, but in some cases you may want to offer the user the ability to install development and stable versions of some application. The version the user chooses will be passed to many other functions as a parameter.

sub script_wordpress_versions
{
return ( "2.2.1" );
}

script_scriptname_category (optional)

This function should return a category for the script, which controls how it is categorized in Virtualmin's list of those available to install. At the time of writing, available categories were Blog, Calendar, Commerce, Community, Content Management System, Database, Development, Email, Guestbook, Helpdesk, Horde, Photos, Project Management, Survey, Tracker and Wiki.

sub script_wordpress_category
{
return "Blog";
}

script_scriptname_php_vers (PHP scripts only)

Scripts that use PHP must implement this function, which should return a list of versions the installed application can run under. At the time of writing, Virtualmin only supports PHP versions 4 and 5. On systems that have more than one version of PHP installed, Virtualmin will configure the website to use the correct version for the path the script is installed to.

sub script_wordpress_php_vers
{
return ( 4, 5 );
}

script_scriptname_php_modules (PHP scripts only)

If the application being installed is written in PHP and requires any non-core PHP modules, this function should return them as a list. Any script that talks to a MySQL database will need the mysql module, or pgsql if it uses PostgreSQL. Virtualmin will attempt to install the required modules if they are missing from the system.

sub script_wordpress_php_modules
{
return ("mysql");
}

script_scriptname_pear_modules (PHP scripts only)

Pear is a repository of additional modules for PHP, which some Virtualmin scripts make use of. If the application you are installing requires some Pear modules, this function can be implemented to return a list of module names. At installation time, Virtualmin will check for and try to automatically install the needed modules.

sub script_horde_pear_modules
{
return ("Log", "Mail", "Mail_Mime", "DB");
}

script_scriptname_perl_modules (Perl scripts only)

For scripts written in Perl that require modules that are not part of the standard Perl distribution, you should implement this function to return a list of additional modules required. Virtualmin will try to automatically install them from YUM, APT or CPAN where possible, and will prevent the script from being installed if they are missing.

sub script_twiki_perl_modules
{
return ( "CGI::Session", "Net::SMTP" );
}

script_scriptname_python_modules (Python scripts only)

For scripts written in Python that require modules that are not part of the standard distribution, you should implement this function to return a list of additional modules required. Virtualmin will try to automatically install them from YUM or APT where possible, and will prevent the script from being installed if they are missing.

sub script_django_python_modules
{
return ( "setuptools", "MySQLdb" );
}

script_scriptname_depends(&domain, version)

This function must check for any dependencies the script has before it can be installed, such as a MySQL database or virtual server features. It is given two parameters - the domain hash containing details of the virtual server being installed into, and the version number selected.

sub script_wordpress_depends
{
local ($d, $ver) = @_;
&has_domain_databases($d, [ "mysql" ]) ||
        return "WordPress requires a MySQL database" if (!@dbs);
&require_mysql();
if (&mysql::get_mysql_version() < 4) {
        return "WordPress requires MySQL version 4 or higher";
        }
return undef;
}

As of Virtualmin 3.57, this function can return a list of missing dependency error messages instead of a single string, which is more user-friendly as they are all reported to users at once.

script_scriptname_dbs(&domain, version)

If defined, this function should return a list of database types that the script can use. At least one of these types must be enabled in the virtual server the script is being installed into.

sub script_wordpress_dbs
local ($d, $ver) = @_;
return ("mysql");
}

Only Virtualmin 3.57 and above make use of this function.

script_scriptname_params(&domain, version, &upgrade)

This function is responsible for generating the installation form inputs, such as the destination directory and target database. When upgrading (indicated by the upgrade hash being non-null) these are fixed and should just be displayed to the user. Otherwise, it must return inputs for selecting them. The functions return value must be HTML for form fields, generated using the ui_table_row and other ui_ functions.

The example below from Wordpress is a good source to copy from, as most PHP scripts that you would want to install will need a target directory and a database. The ui_database_select function can be used to generate a menu of databases in the domain, with an option to have a new one created automatically just for this script.

sub script_wordpress_params
{
local ($d, $ver, $upgrade) = @_;
local $rv;
local $hdir = &public_html_dir($d, 1);
if ($upgrade) {
        # Options are fixed when upgrading
        local ($dbtype, $dbname) = split(/_/, $upgrade->{'opts'}->{'db'}, 2);
        $rv .= &ui_table_row("Database for WordPress tables", $dbname);
        local $dir = $upgrade->{'opts'}->{'dir'};
        $dir =~ s/^$d->{'home'}\///;
        $rv .= &ui_table_row("Install directory", $dir);
        }
else {
        # Show editable install options
        local @dbs = &domain_databases($d, [ "mysql" ]);
        $rv .= &ui_table_row("Database for WordPress tables",
                     &ui_database_select("db", undef, \@dbs, $d, "wordpress"));
        $rv .= &ui_table_row("Install sub-directory under <tt>$hdir</tt>",
                             &ui_opt_textbox("dir", "wordpress", 30,
                                             "At top level"));
        }
return $rv;
}

script_scriptname_parse(&domain, version, &in, &upgrade)

This function takes the inputs from the form generated by script_scriptname_params, parses them an returns an object containing options that will be used when the installation actually happens. If it detects any errors in the input, it should return an error message string instead.

As in the example below, when upgrading the options are almost never changed, so it should return just $upgrade→{'opts'}, which are the options it was originally installed with. Otherwise, it should look at the hash reference in which will contain all CGI form variables, and use that to construct a hash of options. The most important keys in the hash are dir (the installation target directory) and path (the URL path under the domain's root).

sub script_wordpress_parse
{
local ($d, $ver, $in, $upgrade) = @_;
if ($upgrade) {
        # Options are always the same
        return $upgrade->{'opts'};
        }
else {
        local $hdir = &public_html_dir($d, 0);
        $in{'dir_def'} || $in{'dir'} =~ /\S/ && $in{'dir'} !~ /\.\./ ||
                return "Missing or invalid installation directory";
        local $dir = $in{'dir_def'} ? $hdir : "$hdir/$in{'dir'}";
        local ($newdb) = ($in->{'db'} =~ s/^\*//);
        return { 'db' => $in->{'db'},
                 'newdb' => $newdb,
                 'multi' => $in->{'multi'},
                 'dir' => $dir,
                 'path' => $in{'dir_def'} ? "/" : "/$in{'dir'}", };
        }
}

script_scriptname_check(&domain, version, &opts, &upgrade)

This function must verify the installation options in the opts hash, and return an error message if any are invalid (or undef if they all look OK). Possible problems include a missing or invalid install directory, a clash with an existing install of the same script in the directory, or a clash of tables in the selected database. As the example below shows, the find_database_table function provides a convenient way to search for tables by name or regular expression - for most applications, all tables used will be prefixed by a short code, like wp_ in the case of WordPress.

If you are wondering why these checks are not performed in script_scriptname_parse, the reason is that when a script is installed from the command line, that function is never called. Instead, install options are generated using a different method, and then validated by this function.

sub script_wordpress_check
{
local ($d, $ver, $opts, $upgrade) = @_;
$opts->{'dir'} =~ /^\// || return "Missing or invalid install directory";
$opts->{'db'} || return "Missing database";
if (-r "$opts->{'dir'}/wp-login.php") {
        return "WordPress appears to be already installed in the selected directory";
        }
local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
local $clash = &find_database_table($dbtype, $dbname, "wp_.*");
$clash && return "WordPress appears to be already using the selected database (table $clash)";
return undef;
}

script_scriptname_files(&domain, version, &opts, &upgrade)

This is the function where the script installer indicates to Virtualmin what files need to be downloaded for the installation to go ahead. Most scripts need only one, which contains the source code - but it is possible to request any number, even zero.

The function must return a list of hash references, each of which should contain the following keys :

  • name A unique name for this file, used later by the script_scriptname_install function.
  • file A short filename for the file, to which it will be saved in /tmp/.webmin after being downloaded.
  • url The URL that it can be downloaded from.
  • nocache Optional, but can be to 1 to force a download even if the URL is cached by Virtualmin.

In most cases, the ver parameter is used in the URL and filename to get the correct source archive. WordPress (shown below) is an exception, as it has only a single download URL which always serves up the latest version.


sub script_wordpress_files
{
local ($d, $ver, $opts, $upgrade) = @_;
local @files = ( { 'name' => "source",
           'file' => "latest.tar.gz",
           'url' => "http://wordpress.org/latest.zip",
           'nocache' => 1 } );
return @files;
}

script_scriptname_commands

If your script installer requires any commands to do its job that may not be available on a typical Unix system, this function should return a list of them. In most cases, it just returns the programs needed to un-compress the tar.gz or zip file containing the source.

sub script_wordpress_commands
{
return ("unzip");
}

script_scriptname_install(&domain, version, &opts, &files, &upgrade, username, password)

This function is where the real work of installing a script actually happens. It is responsible for setting up the database, un-compressing the downloaded source, copying it to the correct directory, modifying configuration files to match the domain and database, and returning a URL that can be used to login. If anything goes wrong, it must return an array whose first element is zero, and the second is an error message.

Upon success, it must return an an array containing the following elements :

  • The number 1 (indicating success)
  • An HTML message to display to the user. This should include a link that can be used to access the script.
  • A description of where it was installed, usually formatted like Under /wordpress using mysql database yourdomain.
  • The URL that can be used to access the script.
  • The initial administration login, if any.
  • The initial administration password.

If given, the username and password parameters should be used to set the initial administrative login for the script. If not, it should default to the domain's login and password.

The code snippets below show each step of the install process, taken from the standard WordPress installer. The first part simply parses the database connection options and creates a new DB for the script, if one was requested :

sub script_wordpress_install
{
local ($d, $version, $opts, $files, $upgrade) = @_;
local ($out, $ex);
if ($opts->{'newdb'} && !$upgrade) {
        local $err = &create_script_database($d, $opts->{'db'});
        return (0, "Database creation failed : $err") if ($err);
        }
local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d);
local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1);
local $dbphptype = $dbtype eq "mysql" ? "mysql" : "psql";
local $dbhost = &get_database_host($dbtype);
local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass);
return (0, "Database connection failed : $dberr") if ($dberr);

The next step is to extract the downloaded source code, and then copy it to the created destination directory. This is done by calling the unzip and cp commands as the Virtualmin domain owner, so that there is no risk of files that he is not supposed to have access to being over-written. The source code temporary file can be found from the files hash reference in the source key, which was defined by the script_scriptname_files function.

Note how the code checks for expected files after extracting and copying the source, to make sure that the commands called actually succeeded.

# Create target dir
if (!-d $opts->{'dir'}) {
        $out = &run_as_domain_user($d, "mkdir -p ".quotemeta($opts->{'dir'}));
        -d $opts->{'dir'} ||
                return (0, "Failed to create directory : <tt>$out</tt>.");
        }

# Extract tar file to temp dir
local $temp = &transname();
mkdir($temp, 0755);
chown($d->{'uid'}, $d->{'gid'}, $temp);
$out = &run_as_domain_user($d, "cd ".quotemeta($temp).
                               " && unzip $files->{'source'}");
local $verdir = "wordpress";
-r "$temp/$verdir/wp-login.php" ||
        return (0, "Failed to extract source : <tt>$out</tt>.");

# Move html dir to target
$out = &run_as_domain_user($d, "cp -rp ".quotemeta($temp)."/$verdir/* ".
                               quotemeta($opts->{'dir'}));
local $cfileorig = "$opts->{'dir'}/wp-config-sample.php";
local $cfile = "$opts->{'dir'}/wp-config.php";
-r $cfileorig || return (0, "Failed to copy source : <tt>$out</tt>.");

Most scripts or applications have a configuration file of some kind that defines where to access the database, what domain they are running under, the URL path, and possibly an initial login and password. The script installers is responsible for creating or modifying this file to use the database connection details supplied by the opts paramater, as shown in the code snippet below.

Be careful when upgrading, as in general the existing configuration file will be valid for the new version. This means that it doesn't need to be re-created, and should be preserved during the upgrade process if necessary.

# Copy and update the config file
if (!-r $cfile) {
        &run_as_domain_user($d, "cp ".quotemeta($cfileorig)." ".
                                      quotemeta($cfile));
        local $lref = &read_file_lines($cfile);
        local $l;
        foreach $l (@$lref) {
                if ($l =~ /^define\('DB_NAME',/) {
                        $l = "define('DB_NAME', '$dbname');";
                        }
                if ($l =~ /^define\('DB_USER',/) {
                        $l = "define('DB_USER', '$dbuser');";
                        }
                if ($l =~ /^define\('DB_HOST',/) {
                        $l = "define('DB_HOST', '$dbhost');";
                        }
                if ($l =~ /^define\('DB_PASSWORD',/) {
                        $l = "define('DB_PASSWORD', '$dbpass');";
                        }
                if ($opts->{'multi'}) {
                        if ($l =~ /^define\('VHOST',/) {
                                $l = "define('VHOST', '');";
                                }
                        if ($l =~ /^\$base\s*=/) {
                                $l = "\$base = '$opts->{'path'}/';";
                                }
                        }
                }
        &flush_file_lines($cfile);
        }

In some cases, a script will come with a file of SQL statements that can be used to create and populate tables in its database. Others like WordPress do this automatically when they are first accessed. If the application you are installing needs SQL to be run as part of its setup process, you can use code like the fragment below, which was taken from the WebCalendar installer :

if (!$upgrade) {
        # Run the SQL setup script
        if ($dbtype eq "mysql") {
                local $sqlfile = "$opts->{'dir'}/tables-mysql.sql";
                &require_mysql();
                ($ex, $out) = &mysql::execute_sql_file($dbname, $sqlfile, $dbuser, $dbpass);
                $ex && return (0, "Failed to run database setup script : <tt>$out</tt>.");
                }

The final part of the script_scriptname_install function is returning information to Virtualmin about how to access the new script, and where it is installed. In some cases, a script will have two URLs - the one for administration (which should be references in the second element of the returned array), and the one for general use (which should be in the 4th element).

local $url = &script_path_url($d, $opts).
             ($upgrade ? "wp-admin/upgrade.php" : "wp-admin/install.php");
local $userurl = &script_path_url($d, $opts);
local $rp = $opts->{'dir'};
$rp =~ s/^$d->{'home'}\///;
return (1, "WordPress installation complete. It can be accessed at <a href='$url'>$url</a>.", "Under $rp using $dbphptype database $dbname", $userurl);
}

script_scriptname_uninstall(&domain, version, &opts)

This function is responsible for cleaning up all files and database tables created by the install code. It is only called when the user deletes a script from a domain, not when upgrading. If most cases, determining which tables to remove is simple, as they all start with some prefix (like wp_ in the case of WordPress). But if a script has created a tables that cannot be automatically identified, your installer will need to have this list hard-coded. See the oscommerce.pl installer for an example.

If the installer has created any cron jobs, server processes, custom Apache configuration entries or email aliases, they must also be removed by this function. On success, it should return a two-element array whose first element is 1, and the second a message to display to the user. On failure, it should return 0 and an error message explaining what went wrong.

sub script_wordpress_uninstall
{
local ($d, $version, $opts) = @_;

# Remove the contents of the target directory
local $derr = &delete_script_install_directory($d, $opts);
return (0, $derr) if ($derr);

# Remove all wp_ tables from the database
local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
if ($dbtype eq "mysql") {
        # Delete from MySQL
        &require_mysql();
        foreach $t (&mysql::list_tables($dbname)) {
                if ($t =~ /^wp_/) {
                        &mysql::execute_sql_logged($dbname,
                                "drop table ".&mysql::quotestr($t));
                        }
                }
        }
else {
        # Delete from PostgreSQL
        &require_postgres();
        foreach $t (&postgresql::list_tables($dbname)) {
                if ($t =~ /^wp_/) {
                        &postgresql::execute_sql_logged($dbname,
                                "drop table $t");
                        }
                }
        }

# Take out the DB
if ($opts->{'newdb'}) {
        &delete_script_database($d, $opts->{'db'});
        }

return (1, "WordPress directory and tables deleted.");
}

script_scriptname_passmode(&domain, version)

Most scripts that setup an initial login and password use those from the virtual server the script is being added to. However, Virtualmin can prompt the user for alternative authentication details if you implement this function. All it has to do is return one of the following numeric codes :

  • 1 - Script needs a username and password
  • 2 - Script only needs a password
  • 3 - Script only needs a username

The custom login and password entered by the user will be passed to the script_scriptname_install function. If your script installer doesn't setup an initial login at all, you can either omit this function or have it return 0.

sub script_wordpress_passmode
{
return 1;
}

Other Installation Methods

The style of installation code above will work for most scripts that you want to install, but in some cases a slightly different approach is needed. This section covers two of them - scripts with their own configuration generators that cannot be easily replaced by creating the config file yourself, and installers for Ruby On Rails apps, which use a separate server process.

HTTP Requests

Many PHP applications come with a script that asks the user a series of questions, like the database login and name, domain name, and initial administration username and password. The script then uses this information to create a config file and perhaps populated the database.

Ideally, Virtualmin script installers should create any needed config files directly - but in some cases this is too difficult due to their complexity. Similarly, it may not be possible to create and populate all the needed database tables if no SQL file is provided for doing this. In cases like this, it is simpler for a script installer to invoke the application's install code directly, by making an HTTP request to the correct URL.

To figure out the installation URL and the CGI parameters it needs, you will need to install the application manually and run through its install process in a browser. The View source feature can then be used to find the names and meanings of all form fields, which can then be used to construct code to call the script the form would submit to.

The following code fragment from the script_phpbb_install function of the phpbb.pl installer gives an example of this :

# Make config.php writable
&make_file_php_writable($d, $cfile);

# Trigger the installation PHP script
local @params = (
        [ "lang", "english" ],
        [ "dbms", $dbtype eq "mysql" ? "mysql4" : "postgres" ],
        [ "upgrade", 0 ],
        [ "dbhost", $dbhost ],
        [ "dbname", $dbname ],
        [ "dbuser", $dbuser ],
        [ "dbpasswd", $dbpass ],
        [ "prefix", "phpbb_" ],
        [ "board_email", $d->{'emailto'} ],
        [ "server_name", "www.".$d->{'dom'} ],
        [ "server_port", $d->{'web_port'} ],
        [ "script_path", $opts->{'path'}."/" ],
        [ "admin_name", $d->{'user'} ],
        [ "admin_pass1", $d->{'pass'} ],
        [ "admin_pass2", $d->{'pass'} ],
        [ "install_step", 1 ],
        [ "current_lang", "english" ],
        );
local $params = join("&", map { $_->[0]."=".&urlize($_->[1]) } @params);
local $ipage = $opts->{'path'}."/install/install.php";

# Make an HTTP post to the installer page
local ($iout, $ierror);

&post_http_connection("www.$d->{'dom'}", $d->{'web_port'},
                      $ipage, $params, \$iout, \$ierror);
if ($ierror) {
        return (0, "phpBB post-install configuration failed : $ierror");
        }
elsif ($iout !~ /Finish Installation/i) {
        return (0, "phpBB post-install configuration failed");
        }

As you can see, it makes use of the post_http_connection function provided by Virtualmin which makes an HTTP POST request, which is expected by most applications. If the form is submitted using a GET, you could use Webmin's http_download function instead.

In some cases, the installation process is a multi-step wizard, which means that you will need to make several POST requests with different parameters, and possibly parse the output from each. In the worst case, the application may set cookies to track the progress of the wizard - see the SugarCRM installer in sugarcrm.pl for an example of this.

Ruby On Rails Installation

Most Rails applications installed by Virtualmin are actually run by a separate server process, typically a Mongrel webserver. To link them up to the domain's actual website, Apache proxy directives are added that pass all requests to a path like /typo to a local webserver at a URL like http://localhost:3001/typo. Starting and maintaining this server process and configuring Apache to use it requires a fair bit of work, but fortunately Virtualmin Pro version 3.44 and above include functions that make it easier.

Some Ruby applications are available from the Ruby Gems package installation service, while others must be downloaded and extracted like PHP applications. For example, typo.pl does installation entirely from a Gem, and so has a script_typo_files function that returns nothing. It then makes use of the install_ruby_gem function to Install gems for Mongrel and Typo itself.

The code fragment below is the first part of the script_typo_install function. As you can see, it checks for the gem command, and then calls functions to install those Gems that it needs.

sub script_typo_install
{
local ($d, $version, $opts, $files, $upgrade) = @_;
local ($out, $ex);

# Check for the gem command (here instead of earlier, as it may have been
# automatically installed).
&has_command("gem") || return (0, "The Ruby gem command is not installed");

# Create target dir
if (!-d $opts->{'dir'}) {
        $out = &run_as_domain_user($d, "mkdir -p ".quotemeta($opts->{'dir'}));
        -d $opts->{'dir'} ||
                return (0, "Failed to create directory : <tt>$out</tt>.");
        }

# Install mongrel first
local $err = &install_ruby_gem("mongrel");
if ($err) {
        return (0, "Mongrel GEM install failed : <pre>$err</pre>");
        }

# Install typo itself
local $err = &install_ruby_gem("typo");
if ($err) {
        return (0, "Typo GEM install failed : <pre>$err</pre>");
        }
if (!&has_command("typo")) {
        return (0, "Install appear to succeed, but the <tt>typo</tt> command ".
                   "could not be found");
        }

Just installing the Gem is not enough - the code for Typo needs to be somehow copied into the virtual server's directory. Fortunately, Typo provides a command to do this, shown in the code below. Other Ruby applications are distributed in tar.gz files, and need to be extracted and copied into place.

$out = &run_as_domain_user($d, "cd ".quotemeta($opts->{'dir'})." && ".
                               "typo install .");
if ($?) {
        return (0, "Typo setup failed : <pre>$out</pre>");
        }

Because Rails applications use a separate server process, your installer must find a free port for it to run on, and then start it. Virtualmin provides the allocate_mongrel_port function to do the former, and the mongrel_rails_start_cmd function to build a command for the latter. Some Rails applications (like Typo) provide their own server startup scripts, so check the documentation to see which commands they recommend.

$out = &run_as_domain_user($d, "cd ".quotemeta($opts->{'dir'})." && ".
                               "typo start .");
if ($?) {
        return (0, "Failed to start Typo server : <pre>$out</pre>");
        }

All Rails applications will need an Apache proxy configuration to direct requests from the Apache webserver to their Mongrel server. Virtualmin provides a simple function to set this up, shown in the code below. Be aware that many Rails apps don't like being run in a sub-directory, and most don't automatically support it. Your installer may need to modify configuration files and perhaps even application code to support this.

&setup_mongrel_proxy($d, $opts->{'path'}, $opts->{'port'},
                     $opts->{'path'} eq '/' ? undef : $opts->{'path'});

The server process that runs the Rails application must be running all the time - but what happens if the system gets rebooted? To handle this, Virtualmin makes it easy to create either an @reboot crontab entry or /etc/init.d script to start the server, as shown in the following code. The init script will only be added if the domain has the new Bootup Actions plugin installed and made available.

if (!$upgrade) {
        # Configure server to start at boot
        local $typo = &has_command("typo");
        local $startcmd = "cd ".quotemeta($opts->{'dir'})."; ".
                          "$typo start . 2>&1 </dev/null";
        local $stopcmd = "kill `cat ".quotemeta($pidfile)."`";
        &setup_mongrel_startup($d, $startcmd, $stopcmd, $opts,
                               1, "typo-".$opts->{'port'}, "Typo Blog Engine");
        }

Ruby On Rails Un-Installation

Just as special code is required to install Rails applications, your script must also implement the script_scriptname_uninstall function to clean up all server processes, boot scripts and Apache config entries. This is made easier by several convenience functions provided by Virtualmin, the use of which is show in the code below:

sub script_typo_uninstall
{
local ($d, $version, $opts) = @_;

# Shut down the server process
local $pidfile = "$opts->{'dir'}/tmp/pid.txt";
local $pid = &check_pid_file($pidfile);
if ($pid) {
        kill('KILL', $pid);
        }

# Remove bootup script

&delete_mongrel_startup($d, $opts, "typo start .");

# Remove the contents of the target directory
local $derr = &delete_script_install_directory($d, $opts);
return (0, $derr) if ($derr);

# Remove proxy Apache config entry for /typo
&delete_mongrel_proxy($d, $opts->{'path'});
&register_post_action(\&restart_apache);

return (1, "Typo directory deleted.");
}

When Virtualmin deletes a domain, it does not call the uninstall functions for any installed scripts, as this would generally be a waste of time - their directories and databases are going to be removed anyway. In the case of Rails applications, this is not true - their installers start server processes and create boot scripts that must be cleaned up.

To ensure that this happens, your script installer must implement the script_scriptname_stop function, which only has to shut down any server processes and prevent them from being run at boot time. This function is only called at virtual server deletion time, and is optional for installers that don't require it.

sub script_typo_stop
{
local ($d, $sinfo) = @_;
local $pidfile = "$sinfo->{'opts'}->{'dir'}/tmp/pid.txt";
local $pid = &check_pid_file($pidfile);
if ($pid) {
        kill('KILL', $pid);
        }
&delete_mongrel_startup($d, $sinfo->{'opts'}, "typo start .");
}

Creating New Content Styles

Virtualmin Professional includes a fast website creator that allows users to build websites from templates with just a couple of clicks. Once built, the end user can edit the resulting website using a built-in WYSIWYG editor (or using other tools).

Virtualmin includes a few styles that are royalty free and usable for any purpose, commercial or otherwise. Adding new styles is easy, and we encourage web designers to create their own templates for sale - making an existing template into a Virtualmin Content Style is a very simple process.

Directory Structure

The content styles included with Virtualmin are located in the virtual-server/styles directory under the Webmin root. This may be /usr/libexec/webmin/virtual-server/styles (RHEL/CentOS/Fedora/SuSE/Mandriva) or /usr/share/webmin/virtual-server (Debian/Ubuntu). Styles you create yourself should go in /etc/webmin/virtual-server/styles - you may need to create that directory if it doesn't exist yet. Each style should have its own directory, named similarly to the name of the style. Style names should be unique. Including a STYLE-LICENCE.txt file is optional, but recommended if your style is not freely re-distributable.

Here is an example directory and file tree for a simple but complete style with three pages (index.html, sales.html, contact.html):

newstyle/
newstyle/css
newstyle/css/style.css
newstyle/index.html
newstyle/sales.html
newstyle/STYLE-LICENCE.txt
newstyle/template.html
newstyle/thumb.png
newstyle/images
newstyle/images/footer.jpg
newstyle/images/header.jpg
newstyle/contact.html
newstyle/style.info

Create the sub-directories under styles, each of which contains the template HTML and image files for your own style. The only other special file that needs to go in a style directory is style.info, which should contain lines like:

desc=My Custom Theme
name=newstyle

The desc= line specifies the description of the style as it appears in Virtualmin, while the name= line defines the directory it will be stored in under /etc/webmin/virtual-server/themes when installed on another system. No two styles should have the same name.

The other bit you'll want to create is a thumbnail image of the style. The format of this is PNG at 500x375 pixels. Call this file thumb.png. If you will be contributing your style for inclusion in Virtualmin Professional, you'll also want to include an HTML file called template.html which is a version of your index.html with suitable example content included instead of the variables mentioned below.

Within the .html files you can use variables ${CONTENT}, ${OWNER}, ${DOM} to tell Virtualmin where to put the user data (which can all be edited later in the WYSIWYG editor).

Packaging

Just like all other types of packages for Virtualmin, Webmin and Usermin, Content Styles can be bundled into tarballs, optionally gzipped. They can also be zipped, if you're more comfortable with zip format files.

To create a Content Style package, at the directory styles within the Virtualmin virtual-server directory, execute a command like the following:

cd /etc/webmin/virtual-server/styles/newstyle
tar czvf /tmp/newstyle.tar.gz .

This can then be easily installed using the *System Settings* → *Content Styles* page in Virtualmin. If you have the rights necessary to distribute the work (e.g. if you created the style, or if it is based on a Creative Commons licensed redistributable template), feel free to post a link in the forums so others can enjoy it. We also encourage commercial template developers to get involved. If you've already got a stable of templates, converting them for us in Virtualmin is simple, and could provide an additional source of revenue for your existing work. Let us know if you've built commercial Virtualmin Content Styles, and we'll provide a free link to your website.

Remote API

Explains how to manage Virtualmin servers, users, databases and other features remotely from other programs.

Introduction

Even though a command-line API exists for managing Virtualmin objects such as servers, users and databases, this may not be appropriate or usable in all circumstances. Because the commands need to be run as root, they cannot be called from PHP or CGI scripts invoked by a web server, which typically run as a less-privileged Apache user. Also, they must be run on the server running Virtualmin, which makes them difficult to call from another system.

For this reason, an alternate method exists for running these programs via HTTP requests. A special URL in the Virtualmin web interface exists to be called by other programs, and to then pass its parameters on to one of the command-line scripts. This URL can be requested from any system, and by processes running as any Unix user.

Before reading this documentation, you should be familiar with the Virtualmin Command Line Programs documentation, even if you never use those commands directly.

The Remote API

All remote calls must be made through the CGI /virtual-server/remote.cgi . The full URL for this will be https://yourserver:10000/virtual-server/remote.cgi , where 'yourserver' is the full hostname or IP address of the system running Virtualmin.

This URL must be provided with at least one parameter named 'program', whose value must be the name of the command-line program to invoke, without the .pl extension. So a possible URL to request would be :

https://yourserver:10000/virtual-server/remote.cgi?program=list-domains

Because most command-line programs require additional parameters, these must be included in the URL. Every CGI parameter is converted to a command-line parameter, with the value of the parameter appended if given. For example, to create a mail alias, you could invoke the URL :

https://yourserver:10000/virtual-server/remote.cgi?program=create-alias&domain=foo.com&from=sales&to=joe@foo.com

To specify a parameter that does not have anything after it, just add a CGI parameter with no value. For example, to list databases in detailed form, you could call :

https://yourserver:10000/virtual-server/remote.cgi?program=list-databases&domain=foo.com&multiline=

Both GET and POST format HTTP requests can be used. If your Virtualmin server is not running in SSL mode, use http:// instead of https:// in the URL.

Reading Output

The page returned by the remote.cgi URL will always be plain text, and will contain the output produced by the command-line program. One additional line will be appended though - the words 'Exit status:' followed by the numeric Unix exit status of the command. A status of 0 means that the program was successful, while a non-zero status indicates some error. The cause of the error can be determined from the command's output.

JSON and XML Output

If you would prefer JSON format output, add the json=1 parameter to the remote API call. Alternately, you can select XML format with the xml=1 parameter. Finally, Perl format can be selected with the perl=1 parameter.

Authentication

Because the remote API is part of the Virtualmin web interface, it is password-protected using the same authentication system as you would normally use to login via a web browser. Only the master administrator can access the remote API though, as it can be used to perform almost any action in Virtualmin, and thus would be unsafe for server owners or resellers to use.

When calling the remote API from your own programs, the HTTP request must have the necessary HTTP authentication headers. All HTTP libraries and programs have options to set the username and password - for example, the wget command uses --http-user and --http-passwd , so you could fetch a list of domains from a remote Virtualmin server with a command like :

wget--http-user=root --http-passwd=smeg 'https://yourserver:10000/virtual-server/remote.cgi?program=list-domains'

Example Usage

PHP Example

<?php
$result = shell_exec("wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate 'https://localhost:10000/virtual-server/remote.cgi?program=list-domains'");

echo $result;
?>

Perl Example

#!/usr/bin/perl -w
 
$result = `wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate 'https://localhost:10000/virtual-server/remote.cgi?program=list-domains'`;
print "$result\n";
 

Perl LWP Example

#!/usr/bin/perl -w
 
use strict;
use LWP;
 
my $browser = LWP::UserAgent->new( );
$browser->credentials("localhost:10000", "Webmin Server", "root" => "pass");

 
my $result = $browser->get( "https://localhost:10000/virtual-server/remote.cgi?program=list-domains" );
 
print $result->content;
 

Writing Virtualmin Plugins

Writing Virtualmin Plugins

Introduction to Plugins

Before starting on a plugin, we suggest that you first read the Webmin module developers guide at http://doxfer.com/Webmin/ModuleDevelopment .

A Virtualmin plugin is simply a Webmin module that can provide additional features to Virtualmin virtual servers or users. To do this, it must contain a Perl script called virtual_feature.pl which defines certain functions. The plugin module can then be registered by Virtualmin, and the feature it offers will then be available when creating new virtual domains.

A plugin typically adds a new possible to virtual servers, in addition to the standard features built into Virtualmin (website, DNS domain and so on). For example, it may enable reporting using some new statistics generator, or activate some game server in the virtual domain. Virtualmin will add options to the Create Server and Edit Server pages for enabling the plugin's feature, and call functions in its virtual_feature.pl when the feature is activated, de-activated or changed.

Starting a Plugin

The steps to start writing your own plugin are similar to those for creating a new Webmin module :

  1. Find the Webmin root directory, which will be /usr/libexec/webmin on Redhat-derived systems, /usr/share/webmin on Debian and Ubuntu, or /opt/webmin on Solaris.
  2. Pick a directory name for your plugin that is not currently in use by any other Webmin module. Plugin directories typically start with virtualmin- - so for the purposes of this documentation, we will assume that yours is going to be called virtualmin-yourname .
  3. Create that directory under the Webmin root. Then within it, create help and lang sub-directories.
  4. Create a file in the directory called module.info. This should contain lines like :
desc=A description of your plugin
version=1.0
hidden=1

Naturally, the desc= line should be changed to something more meaningful. If you want the plugin to appear in Webmin's menu of modules, remove the hidden=1 line. This is not typically the case, as most plugins are accessed entirely via Virtualmin.

  1. Create a module library file for your plugin, named virtualmin-yourname-lib.pl. Initially, it can contain the following code :
use WebminCore;
&init_config();
&foreign_require("virtual-server", "virtual-server-lib.pl");
1;

  1. Create a plugin API file called virtual_feature.pl, containing the following initial code :
do 'virtualmin-yourname-lib.pl';

sub feature_name
{
return "A description of your plugin";
}
  1. Delete the file /etc/webmin/module.infos.cache to clear Webmin's cache of installed modules.
  2. Open Virtualmin in your browser, and click on Features and Plugins under System Settings on the left menu. Your new plugin should appear in the list of those available - check its box in the left column, and click Save.

With this done, you can now start work on expanding the capabilities of the plugin by implementing the API documented below.

Package and Distribution

Since a plugin is just a Webmin module, the usual process for packaging it still applies. The commands to do this are :

cd /usr/libexec/webmin
tar cvzf /tmp/virtualmin-yourname.wbm.gz virtualmin-yourname

As you can see, a module or plugin is just a tar file of the directory. These can then be installed using the Webmin Configuration module, on the Webmin Modules page.

If you prefer to package your plugin as an RPM, this can be done using the makemodulerpm.pl script, available from http://www.webmin.com/makemodulerpm.pl . It must be run as root as shown below :

cd /usr/libexec/webmin
/usr/local/bin/makemodulerpm.pl --target-dir /tmp virtualmin-yourname

This will create a file named wbm-virtualmin-yourname-1.0-1.noarch.rpm in the /tmp directory.

A similar script exists for Debian and Ubuntu systems, available from http://www.webmin.com/makemoduledeb.pl .

Plugin CGI Scripts

Because a plugin is just a Webmin module, it can contain .cgi scripts like any other module. These can be useful for displaying additional information about the feature that the plugin manages, or for managing objects within that feature (such as mailing lists or user accounts). Most plugins will not need to include any CGI scripts, as their functionality is provided entirely by implementing the API functions described below.

You can see some examples of this by looking at the Mailman and Oracle plugins. The former includes several CGIs for managing mailing lists in a domain, while the Oracle plugin has CGIs for creating and viewing tables within databases created by Virtualmin.

The Plugin API

The meat of a plugin is it's implementation of an API that is called by Virtualmin when performing tasks like enabling or disabling the plugin's feature for a domain. These must all be defined in the file virtual_feature.pl under the plugin's directory. Most are optional, depending on which functionality your plugin is implementing.

For each function the name, supplied parameters, description and an example implementation are shown.

Many functions are passed a domain object as a parameter. This is simply a hash reference that is used internally by Virtualmin to store information about a virtual server. Some of the useful keys in the hash are :

In addition, for each feature the domain has enabled, the code for that feature will be set to 1 in the hash. For example, a domain with a website has web set to 1, for email the code is mail, and for a Webmin login the code is webmin. Virtualmin will add an entry for your plugin when its feature is enabled for the domain, the code for which will be the same as the plugin's directory.

Core Functions

Functions in this section must be implemented by all plugins.

feature_name()

This must return a short name for the feature, like My plugin.

sub feature_name
{
return "My plugin name";
}

Functions for Features

The most common use for plugins is to add a new feature that can be selected when a virtual server is created or modified. The functions listed in this section should be implemented in this case, although not all are mandatory.

feature_label(edit-form)

This must return a longer name for the feature, for display in the server creation and editing pages. The edit-form parameter can be used to determine which page is calling the function.

sub feature_label
{
return "Enable my plugin";
}

feature_check()

This optional function will be called when the plugin is registered by Virtualmin, to check that all of its dependencies are met. It must return undef if everything is OK, or an error message if some program or service that the plugin depends upon is missing. If not implemented, Virtualmin will assume that the plugin has no dependencies.


sub feature_check
{
if (&has_command("someprogram")) {
  return "The commmand someprogram required by this plugin is not installed";
  }
else {
  return undef;
  }
}

feature_losing(domain)

This should return text to be displayed when this feature is being removed from a domain. The domain parameter is the Virtualmin domain hash reference for the server the feature is being removed from.

sub feature_losing
{
return "My plugin for this virtual server will be disabled";
}

feature_disname(domain)

This optional function should return a description of what will be done when this feature is temporarily disabled. It is only needed if your plugin implements the feature_disable function, indicating that it can be disabled.

sub feature_disname
{
return "My plugin will be temporarily de-activated";
}

feature_clash(domain)

If activating this plugin feature in the given domain would clash with something already on the system, this function must return an error message. Otherwise, it can just return undef.

sub feature_clash
{
my ($d) = @_;
if (-r "/etc/someprogram/$d->{'dom'}") {
  return "Some program is already enabled for this domain";
  }
else {
  return undef;
  }
}

feature_depends(domain)

If implemented, this function should check if the given domain object has all the features enabled that would be required by this plugin. For example, if your plugin implements something that is accessible via the web, the domain must have the web feature set. If a dependency is missing it must return an error message explaining this, or undef if everything is OK.

sub feature_depends
{
my ($d) = @_;
if ($d->{'web'}) {
  return undef;
  }
else {
  return "My plugin requires a website";
  }
}

feature_suitable(parentdom, aliasdom, superdom)

This optional function should check the given parent domain, alias target domain and super-domain objects, to ensure that they are suitable for this feature. It can be useful for preventing the plugin from being enabled in sub-domains or alias domains, where it may not be appropriate. It must return 1 if the feature can be used, or 0 if not. If not implemented, Virtualmin assumes that it can be used anywhere.


sub feature_suitable
{
my ($parent, $alias, $super) = @_;
if ($parent && !$parent->{'web'}) {
  return 0;
  }
else {
  return 1;
  }
}

feature_setup(domain)

This function will be called when the plugin feature is being enabled for some server, either at creation time or when the server is subsequently modified. It must perform whatever actions are needed, such as modifying config files, running commands and so on. It should notify the user of the features activation by calling the functions &$virtual_server::first_print and &$virtual_server::second_print, like so :

sub feature_setup
{
my ($d) = @_;
&$virtual_server::first_print("Setting up My plugin..");
my $ex = system("somecommand --add $d->{'dom'} >/dev/null 2>&1");
if ($ex) {
  &$virtual_server::second_print(".. failed!");
  return 1;
  }
else {
  &$virtual_server::second_print(".. done");
  return 1;
  }
}

feature_delete(domain)

This function is called when the feature is removed for some server, either at deletion time or when the server is modified. It must perform whatever config file changes or run whatever commands are needed to turn the feature off, and should use the &$virtual_server::first_print and &$virtual_server::second_print functions to notify the user about what it is doing.

sub feature_delete
{
my ($d) = @_;
&$virtual_server::first_print("Turning off up My plugin..");
system("somecommand --remove $d->{'dom'} >/dev/null 2>&1");
&$virtual_server::second_print(".. done");
}

feature_modify(domain, olddomain)

Whenever a virtual server is modified, this function will be called in all plugins. It should check if some attribute of the server that the plugin uses has changed (like dom or user), and update the appropriate config files. For example, if your feature configures some program that needs to know the virtual server's domain name, this function must compare $domain→{'dom'} and $olddomain→{'dom'} , and if they differ perform whatever updates are needed. It should only produce output when it actually does something though.

sub feature_modify
{
my ($d, $oldd) = @_;
if ($d->{'dom'} ne $oldd->{'dom'}) {
  &$virtual_server::first_print("Changing domain for My plugin ..");
  rename("/etc/someprogram/$oldd->{'dom'}", "/etc/someprogram/$d->{'dom'}");
  &$virtual_server::second_print(".. done");
  }
}

feature_disable(domain)

If this function is defined, it will be called when a virtual server with the plugin feature active is disabled. It should temporarily turn off access to the feature in a non-destructive way, so that it can be fixed later by a call to feature_enable.

sub feature_disable
{
my ($d) = @_;
&$virtual_server::first_print("Temporariliy disabling My plugin ..");
rename("/etc/someprogram/$d->{'dom'}", "/etc/someprogram/$d->{'dom'}.disabled");

&$virtual_server::second_print(".. done");
}

feature_enable(domain)

This function will be called when a virtual server with the plugin's feature is re-enabled. It should undo whatever changes were made by the feature_disable function. It only needs to be implemented if feature_disable is.

sub feature_enable
{
my ($d) = @_;
&$virtual_server::first_print("Re-enabling My plugin ..");
rename("/etc/someprogram/$d->{'dom'}.disabled", "/etc/someprogram/$d->{'dom'}");
&$virtual_server::second_print(".. done");
}

feature_bandwidth(domain, start, bwhash)

If defined, this function should report to Virtualmin the amount of bandwidth used by some virtual server since the given start Unix time. Bandwidth is the total number of bytes uploaded and downloaded, broken down by day. This function should scan whatever log file is available for the feature, extract upload and download counts for the domain, and add to the values in the bwhash hash reference.

Because bandwidth is accumulated by day, the bwhash hash is index by the number of days since 1st Jan 1970 GMT, which is simply a Unix time divided by 86400.

feature_webmin(domain, other-domains)

If you want your plugin to provide access to a Webmin module to the owners of virtual servers that have its feature enabled, this function can be used tell Virtualmin which modules access should be granted to. Typically, a plugin will grant access to its own module, which will have standard CGI scripts for use in further configuring whatever service the plugin enables.

This function must return a list of array references, each of which has two values :

  1. The directory of a module to grant access to (typically just $module_name)
  2. A hash reference of ACL values to set in that module for the domain owner. This is typically used to restrict him to just the configurations relevant to the given domain.

The domain parameter is the virtual server object that this feature is enabled in, and other-domains is an array reference of other virtual servers that are owned by the same user as domain, and which have the plugin's feature enabled. This latter parameter should be taken into account in order to grant access to configure all of the user's servers.

sub feature_webmin
{
local ($d, $all) = @_;
my @fdoms = grep { $_->{$module_name} } @$all;
if (@fdoms) {
  return ( [ $module_name, { 'doms' => join(" ", @fdoms) } ] );
  }
else {
  return ( );
  }
}

feature_import(domain-name, user-name, db-name)

This function is called when an existing virtual server is being imported into Virtualmin. It should return 1 if the service configured by the plugin is already active for the given domain, perhaps because it was set up manually.

sub feature_import
{
my ($dname, $user, $db) = @_;
if (-r "/etc/someprogram/$dname") {
  return 1;
  }
else {
  return 0;
  }
}

feature_links(domain)

This optional function allows the plugin to provide additional links on the left menu of framed Virtualmin themes when a domain with the feature enabled is selected. It must return a list of hash references, each containing the following keys :

A link to a module that the current Webmin user does not have access to will not be displayed.

sub feature_links
{
local ($d) = @_;
return ( { 'mod' => $module_name,
           'desc' => "Manage My plugin",
           'page' => 'index.cgi?dom='.$d->{'dom'},
           'cat' => 'services',
         } );
}

feature_always_links(domain)

This function is similar to feature_links, but is called regardless of which domain is selected. It can be used when you have a page that can be used even for virtual servers that don't have the plugin's feature active.

feature_validate(domain)

This function is optional, and is used by Virtualmin domain validation page. If implemented, it should check to ensure that all configuration files and other settings specific to the domain are setup properly. If any problems are found it should return an error message string, otherwise undef.

sub feature_validate
{
my ($d) = @_;
if (!-r "/etc/someprogram/$d->{'dom'}") {
  return "Missing someprogram configuration file";
  }
else {
  return undef;
  }
}

virtusers_ignore(domain)

This optional function should be implemented by plugins that add and manage email aliases to a domain - for example, one that deals with mailing lists or autoresponders. Because you don't generally want these aliases showing up in the general list of those in the domain, it should return a list of full addresses to hide from the list.

sub virtusers_ignore
{
my ($d) = @_;
return ( "myplugin\@$d->{'dom'}" );
}

Limits and Template Functions

Plugins can define fields that will appear on the owner limits page for a virtual server, and in server templates. Limits are useful if your plugin uses up resources of some kind, such as disk space for databases or memory for server processes. You can then allow the master administrator to define limits on these resources, via functions documented here.

Virtualmin templates are the location of most configuration settings that are used when creating new virtual servers. If your plugin has some adjustable settings that might be used when it is enabled, you can implement the functions below to add new input fields to templates. These can then be fetched in your plugin's feature_setup function with the get_template call.

feature_limits_input(domain)

This optional function should return a HTML inputs for limits specific to this plugin's feature. The initial values of those limits should be take from the domain object, where they must be stored in keys starting with the plugin's name (to avoid clashes). The HTML returned must make use of the ui_table_row function to format table columns.

sub feature_limits_input
{
my ($d) = @_;
if ($d->{$module_name}) {
  return &ui_table_row("Maximum My plugin databases",
    &ui_opt_textbox($module_name."limit", $d->{$module_name."limit"},
                    4, "Unlimited", "At most"));
  }
}

feature_limits_parse(domain, in)

This function parses the HTML form inputs generated by feature_limits_input. It should examine the in hash reference and update the domain object to set or clear limits based on the user's selections. If any errors are found it should return an error message string, or undef if all is OK.

sub feature_limits_parse
{
my($d, $in) = @_;
if (!$d->{$module_name}) {
  # Do nothing
  }
elsif ($in->{$module_name."limit_def"}) {
  delete($d->{$module_name."limit"});
  }
else {
  $in->{$module_name."limit"} =~ /^\d+$/ || return "Limit must be a number";
  $d->{$module_name."limit"} = $in->{$module_name."limit"};
  }
return undef;
}

template_input(template)

This optional function must return HTML for editing template settings specific to this plugin. The template parameter is a hash reference to a template object, which contains settings for all features and plugins. Yours should only show and edit keys that start with the plugin's module name, so that they are properly merged when a non-default template is edited. HTML returned must make use of the ui_table_row function to format table columns.

sub template_input
{
my ($tmpl) = @_;
return &ui_table_row("Default My plugin database size",
  &ui_opt_textbox($module_name."dbsize", $tmpl->{$module_name."dbsize"}, 5, "Default").
  "MB");
}

template_parse(template, in)

This function must check in for selections made by the user in the fields created by template_input, and then update the template hash reference. If there are any errors in the user's input it should return an error string, or undef if everything is OK. Template keys must start with the plugin's module name, so that they are properly merged when a non-default template is edited.

sub template_parse
{
my ($tmpl, $in) = @_;
if ($in->{$module_name."dbsize_def"}) {
  delete($tmpl->{$module_name."dbsize"});
  }
else {
  $in->{$module_name."dbsize"} =~ /^\d+$/ || return "Database size must be a number";
  $tmpl->{$module_name."dbsize"} = $in->{$module_name."dbsize"};
  }
}

Backup and Restore Functions

In the Virtualmin architecture, each feature and plugin is responsible for backing up and restoring configuration files associated with a domain, but which are stored outside the virtual server's home directory. If your plugin adds a feature to Virtualmin which stores data in some location that won't be included in a domain's regular back, you should implement the functions in this section to ensure that it is backed up and restored.

feature_backup(domain, file, opts, all-opts)

This function should copy configuration files associated with the virtual server object domain and copy them to the path given by file. If there is just a single file then it can be copied directly - otherwise, your code should create a tar file of all required files and write it to that path.

The &$virtual_server::first_print and second_print functions should be called to tell the user that the backup is starting, and if it has succeeded or failed. If the copy was successful the function should return 1, or 0 on failure.

sub feature_backup
{
my ($d, $file) = @_;
&$virtual_server::first_print("Copying My plugin configuration file ..");
my $ok = &copy_source_dest("/etc/someprogram/$d->{'dom'}", $file);
if ($ok) {
  &$virtual_server::second_print(".. done");
  return 1;
  }
else {
  &$virtual_server::second_print(".. copy failed!");
  return 0;
  }
}

feature_restore(domain, file, opts, all-opts)

This function is the opposite of feature_backup - it should take the data in the file passed in with the file parameter, and update local config files or databases for the virtual server defined in domain to restore those settings. The format of file will be exactly the same as whatever your plugin created in the feature_backup function, although it may be in a different location.

The &$virtual_server::first_print and second_print functions should be called to tell the user that the restore is starting, and if it has succeeded or failed. If the process was successful the function should return 1, or 0 on failure.

sub feature_restore
{
my ($d, $file) = @_;
&$virtual_server::first_print("Restoring My plugin configuration file ..");
my $ok = &copy_source_dest($file, "/etc/someprogram/$d->{'dom'}");
if ($ok) {
  &$virtual_server::second_print(".. done");
  return 1;
  }
else {
  &$virtual_server::second_print(".. copy failed!");
  return 0;
  }
}

Other User Interface Functions

These functions aren't really related to any feature or capability that the plugin provides - instead, the allow it to add elements to the Virtualmin user interface.

settings_links

If implemented, this function should return a list of hash references, each of which defines a new link under the System Settings menus on Virtualmin's left frame. These are only accessible to the master administrator, and appear regardless of which domain is selected. They typically link to global configuration pages for the plugin.

Each hash must contain the following keys :

sub settings_links
{
return ( { 'link' => "/$module_name/edit_config.cgi",
           'title' => "My plugin configuration",
           'icon' => "/$module_name/images/config.gif",
           'cat' => 'setting' } );
}

theme_sections

The Virtualmin framed theme displays various information on the right-hand system information page after you login, such as the status of servers, available updates and comparative quota use. This function allows your plugin to add sections of its own, typically to display global status information.

If defined, it must return a list of hash references, each containing the following keys :

sub theme_sections
{
return ( { 'title' => 'My plugin status',
           'html' => &is_server_running() ? 'Some program is running OK'
                                          : 'Some program is down!',
           'status' => 0,
           'for_master' => 1 } );
}

Functions For Mailboxes

A Virtualmin plugin can also provide extra capabilities to virtual server users. This is done by implementing additional functions in the virtual_feature.pl file, similar to those used for adding a new server feature. This can be used for granting users access to some new service, like a game server or database, which is not supported natively by Virtualmin.

When a plugin adds capabilities to a user, additional inputs will typically appear on the user editing page. In additional, the plugin can define extra columns to appear in the user list, to display the status of the new user capabilities.

Most of the functions above take a user details hash reference as a parameter. Some of the useful keys in this hash are :

The functions that can be added to virtual_feature.pl to support user capabilities are :

mailbox_inputs(user, new, domain)

This function is called when the page for editing a virtual server user is displayed. The user parameter is a hash reference of user details, such as the login name, real name and home directory. The new parameter will be set to 1 if this is a new user, or 0 if editing an existing user. The domain parameter is a hash reference of virtual server information, as used in the plugin functions documented above.

This function must return HTML for the additional inputs to display, formatted to fit inside a 2-column table. This is best done with functions from ui-lib.pl, like:

sub mailbox_inputs
{
my ($user, $new, $d) = @_;
my $access = &check_user_access($user);
return &ui_table_row("Allow access to My plugin?",
                     &ui_yesno_radio("myplugin", $access));
}

It should detect the current state of the user, and use this information to determine the values of the inputs.

mailbox_validate(user, olduser, in, new, domain)

This function is called when the user form is saved, but before any changes are actually committed. It should check the form inputs in the in hash reference to make sure they are valid, and return either undef on success, or an error message if there is some problem.

mailbox_save(user, olduser, in, new, domain)

This function must save the actual settings selected for this user, by updating whatever configuration files are needed for this capability. The user parameter is the update user details hash, containing his new username, password, real name and other attributes. The olduser parameter is the user hash from before the changes were made, and can be compared with user to detect username and other changes. in is the form inputs hash, new is a flag indicating if this is a new or edited user, and domain is the details of the virtual server this user is in.

sub mailbox_save
{
my ($user, $olduser, $in, $new, $d) = @_;
if ($user->{'user'} ne $olduser->{'user'}) {
  &set_user_access($olduser, 0);
  }
&set_user_access($user, $in->{'myplug'} ? 1 : 0);
}

mailbox_delete(user, domain)

This function is called when a user is deleted. It should check to see if he has the capability managed by this plugin enabled, and if so perform whatever tasks are needed to remove it. The parameters are the same as those for the mailbox_save function.

sub mailbox_save
{
my ($user, $d) = @_;
&set_user_access($user, 0);
}

mailbox_modify(user, olduser, domain)

This function gets called when a user is modified by some part of Virtualmin other than the Edit User page, for example by the modify-user.pl command-line script. It should compare the old and new user objects to see if anything that this plugin uses has changed, such as the username or password. If so, it must update whatever configuration files the plugin uses.

sub mailbox_modify
{
my ($user, $olduser, $d) = @_;
if ($user->{'user'} ne $olduser->{'user'}) {
  my $oldaccess = &get_user_access($olduser);
  &set_user_access($olduser, 0);
  &set_user_access($user, $oldaccess);
  }
}

mailbox_header(domain)

If you want an additional column to appear in the user list indicating the state of this plugin's capability for users, this function should return the title for the column. Otherwise, it should just return undef. If you don't need to define any extra column, then you don't even need to implement it.

sub mailbox_header
{
return "Plugin access";
}

mailbox_column(user, domain)

When a column exists for this plugin in the user list, this function will be called once for each user. It must return the text to display, such as Enabled or Disabled. If mailbox_header is not implemented, then this function doesn't need to be either.

sub mailbox_column
{
local ($user, $d) = @_;
return &check_user_access($user) ? "Yes" : "No";
}

mailbox_defaults_inputs(defs, domain)

Virtualmin Pro allows users to define various defaults for new users added to domains, on a per-domain basis. If your plugin wants to be able to add to these defaults, you can implement this function. The defs parameters is a hash reference for a user object containing the defaults, which should be checked to find the current status for your settings.

sub mailbox_defaults_inputs
{
my ($defs, $d) = @_;
return &ui_table_row("Allow access to My plugin by default?",
                     &ui_yesno_radio("myplugin", $defs->{'myplugin'}));
}

mailbox_defaults_parse(defs, domain, in)

This function is the counterpart to mailbox_defaults_inputs. It should check form inputs in in and use them to update the default settings object defs.


sub mailbox_defaults_parse
{
my ($defs, $d, $in) = @_;
$defs->{'myplugin'} = $in->{'myplugin'};
}

Database Functions

In the core package, Virtualmin supports MySQL and PostgreSQL databases. However, the plugin architecture allows developers to add new database types which can then be associated with virtual servers. Typically a plugin that adds databases will also implement the feature_ functions, so that the new database type can be enabled for new or existing virtual servers - just as is the case for MySQL and PostgreSQL.

Because Virtualmin allows mailbox users to have access to some database types, the plugin can also include support for creating, listing and managing additional users associated with each database. Because not all database systems support granting a user full access to a database, implementation of the user-related functions is optional.

database_name()

This function must return the name of the database type.

sub database_name
{
return "FooSQL";
}

database_list(domain)

This function must return a list of the names of databases owned by the given domain object, each of which is a hash reference containing the following keys :

Typically the list of databases for a domain will be stored in the domain hash itself, in a key named db_$module_name. This removes the need for the plugin to store the domain → database mapping separately.

sub database_list
{
my ($d) = @_;
my @rv;
foreach my $db (split(/\s+/, $d->{'db_'.$module_name})) {
        push(@rv, { 'name' => $db,
                    'type' => $module_name,
                    'desc' => &database_name(),
                    'link' => "/$module_name/edit_dbase.cgi?db=$db" });
        }
return @rv;
}

databases_all()

This function should return a list of all databases known to the database server the plugin manages, even those not associated with any domain. Its return format should be the same as database_list.

sub databases_all
{
my @rv;
foreach my $dbname (&list_foosql_databases()) {
  push(@rv, { 'name' => $dbname,
              'type' => $module_name,
              'desc' => &database_name() });
  }
return @rv;
}

database_clash(domain, name)

This function must check if a database of the type managed by the plugin with the given name already exists, and if so return 1. It is used by Virtualmin to prevent database name collisions at creation time. If no clash exists, it must return 0.

sub database_clash
{
my ($d, $name) = @_;
foreach my $db (&list_foosql_databases()) {
  return 1 if ($db eq $name);
  }
return 0;
}

database_create(domain, name)

This function is where the real work of creating a new database should happen. It must perform all the work needed to add a database and associate it with the virtual server, typically by adding it to the db_$module_name key in the domain hash reference. It should use &$virtual_server::first_print to output a message before creation starts, and second_print to display success or failure when done. It should return 1 if creation was successful, 0 if not.

Access to the new database must be granted to the virtual server's owner. For databases managed by some kind of server (like MySQL and PostgreSQL), the domain's username and password must be able to login to access the new database. These can be found in the domain hash in the user and pass keys.

sub database_create
{
my ($d, $name) = @_;
&$virtual_server::first_print("Creating FooSQL database $name ..");
local $err = &create_foosql_database($name);
if ($err) {
  &$virtual_server::second_print(".. failed : $err");
  return 0;
  }
else {
  &$virtual_server::second_print(".. done");
  $d->{'db_'.$module_name} .= " ".$name;
  return 1;
  }
}

database_delete(domain, name)

This function must delete a database of the type managed by this plugin, and remove access to it from the virtual server. Like database_create, it should use the print functions to display progress and status to the user.


sub database_delete
{
my ($d, $name) = @_;
&$virtual_server::first_print("Deleting FooSQL database $name ..");
local $err = &delete_foosql_database($name);
if ($err) {
  &$virtual_server::second_print(".. failed : $err");
  return 0;
  }
else {
  &$virtual_server::second_print(".. done");
  $d->{'db_'.$module_name} =~ s/\s+\Q$name\E//g;
  return 1;
  }
}

database_size(domain, name)

This function is called by Virtualmin when a user displays information about a database, and when computing a virtual server's total disk usage. It must return two numbers :

sub database_size
{
my ($d, $name) = @_;
my $size = &disk_usage_kb("/var/foosql/$name");
my @tables = &list_foosql_tables($name);
return ( $size*1024, scalar(@tables) );
}

database_users(domain, name)

If the plugin's database type supports multiple logins, this function can be implemented to return a list of array references, each of which contains a login and password. Only users associated with domain and with access to the database specified by the name parameter need to be returned. If the password is encrypted, it is fine to use that as the second element of each array ref.

sub database_users
{
my ($d, $name) = @_;
return &execute_foosql_sql($name, "select login,password from users where db = '$name'");
}

database_create_user(domain, database, user, password)

This function must create a new database with with access to the database specified by the database parameter, which is a hash reference returned by database_list. The new user must have the login set by the user parameter, and password specified by password. If something goes wrong, it should called error.

sub database_create_user
{
my ($d, $db, $user, $pass) = @_;
&execute_foosql_sql($db->{'name'}, "create user '$user' with password '$pass'");
}

database_modify_user(domain, old-database, database, old-user, user, password)

This function must modify the user in the database specified by the old-database parameter and named old-user, changing his login to user and password to password (if provided). If the modification fails, it should call error.

sub database_modify_user
{
my ($db, $olddb, $db, $olduser, $user, $pass) = @_;
if ($user ne $olduser) {
  &execute_foosql_sql($olddb->{'name'}, "rename user '$olduser' to '$user'");
  }
if (defined($pass)) {
  &execute_foosql_sql($olddb->{'name'}, "alter user '$user' password '$pass'");
  }
}

database_delete_user(domain, user)

This function should delete the database user specified by the user parameter from all databases owned by the virtual server in domain.

sub database_delete_user
{
my ($d, $user) = @_;
foreach my $name (&list_foosql_databases()) {
  &execute_foosql_sql($name, "delete user '$user'");
  }
}

database_user(name)

Some database servers impose limits on the length or allowed characters in database logins. This function should check if the given name exceeds any such restrictions, and if so truncate or modify it to be valid. It should then return the modified version.

sub database_user
{
my ($name) = @_;
if (length($name) > 16) {
  $name = substr($name, 0, 16);
  }
return $name;
}

Domain Name Service

Domain Name Service

Automatic DNS Slave Configuration - Configuration of automatic DNS slave creation and management.

DNS FAQ - Frequently asked questions about DNS.

Domain Name Server Troubleshooting - Troubleshooting common problems with domain name service.

Domain Registration With Virtualmin - Use of the Virtualmin Registrar plugin, which allows users and administrators to register domains from within Virtualmin using one of several DNS registrars.

DNS Slave Auto-configuration

DNS Slave Auto-Configuration Quickstart

A quick guide to assist administrators who want to use Virtualmin's automatic DNS slave configuration features. This allows for DNS server redundancy.

Introduction

Virtualmin can automatically manage any number of DNS slave servers for you. Once configured, it will create slave zones on other servers and configure them to automatically update when changes are made on your Virtualmin server. For this to work, you need Virtualmin on your primary server and Webmin (a free download) on your slave server(s). Henceforth, all references will refer to the primary server as the "Virtualmin server" and the DNS slave server as the "slave server".

Getting Webmin for the Slave

If you don't have Virtualmin installed on your slave server(s), you'll need to install Webmin. Webmin is available for nearly every UNIX and Linux variant available, and is free to download and use.

You can download Webmin from webmin.com. It is available in .rpm, .deb, Solaris .pkg, .zip, and .tar.gz formats. Be sure to choose the appropriate package type for your slave server. Some Linux versions provide a package of Webmin via their package management system.

Install Webmin according to the instructions for your OS, found on the Downloading and Installing page at Webmin.com.

Login and confirm that the Webmin installation is working correctly and a firewall is not blocking access.

Install BIND

A supported version of BIND is also required on your slave server. Installation of BIND is beyond the scope of this document, as it is different on every operating system. But, on most systems it is very easy, and requires only one or two commands.

For example, installing BIND on CentOS, RHEL, and Fedora systems can be done with the following command:

yum install bind bind-config

The bind-config package is optional, but saves a few steps of configuration that you'd need to do, otherwise.

Configure BIND

On some systems, BIND will not have the necessary minimal configuration to start up immediately after installation. Webmin can usually perform the necessary initial steps for you, and it can usually detect if such steps are needed before starting and using BIND.

Browse to Servers:BIND DNS Server.

If BIND needs configuration, Webmin will offer to perform the configuration for you. It is probably most wise to choose the option that includes downloading the latest root zone file, rather than using the included root zone file (though either will work for our purposes, if you rely on the DNS server for regular DNS services there is a small possibility you'll run into stale data with the included zone file).

After Webmin has performed the initial configuration, you'll likely see a button labeled Start Name Server. Click it.

Don't forget to also enable starting BIND on boot, using the Bootup and Shutdown module. It's beyond the scope of this guide, but the Webmin documentation covers it in some detail in http://doxfer.com/Webmin/BootupAndShutdown|Bootup and Shutdown

Configuring the Virtualmin Server

Once you have the necessary software installed and running on the slave, login to Webmin on your Virtualmin system, and browse open the Webmin menu by clicking on the Webmin link in the upper right corner of the left-hand menu.

Before doing this, make sure that the slave system does not have a firewall blocking ports 10001-10010, as they are used by Webmin's RPC calls. The best way to check this and open them up is with the Linux Firewall module, on the slave system. Or you can use the BSD Firewall or IPFW Firewall modules for non-Linux systems.

Click on the Webmin Servers Index link in the Webmin dropdown menu.

Click Register a new server.

Enter the hostname of your slave server.

Select the type of OS running on the slave.

If you installed the Perl Net SSLeay module and Webmin is using SSL on the slave server, set the SSL server? option to Yes. Otherwise leave it on No.

Select a Link type of Login via Webmin with username ... password ..., and enter the authentication details for an admin level user (usually root).

Change Make fast RPC calls? to Yes.

Click Save.

There should now be an icon representing the server you created in the Webmin Servers page.

Enabling Cluster Slave Servers

Now that you've added the server, you can configure the local name server to automatically manage slave zones on the remote server.

Browse to Servers:BIND DNS Server and click on the Cluster Slave Servers icon.

In the Add server dropdown, select your slave server (if it's the only server you've added, you won't have to select it, as it will already be selected).

Set the Create secondary on slave when creating locally? option to Yes.

If you have already created any domains on your Virtualmin server, set the Create all existing master zones on slave? option to Yes.

If you want to use some name other than the name of the slave server for the NS record (for example, if you wanted it to be ns1.domain.tld, keeping with the convention of naming name servers nsN.domain.tld), you can enter it in the Name for NS record field. Note that you'll actually have to create an A record matching that name pointing to the slave server, if you haven't already created one.

Click Add server.

Setting the Master IP Address

By default, Virtualmin will use the IP address that the master server's hostname resolves to as the IP that the slaves should contact to transfer records. However, on some systems this IP is 127.0.0.1, which will not work.

To make sure the correct IP is used, do the following on the master system :

  1. Go to the BIND DNS Server module, and click on Module Config.
  2. In the Zone file options section, find the Default master server IP for remote slave zones field.
  3. Enter the externally visible internet IP address of your master system.
  4. Click Save. Any DNS zones created from now on will use that IP.

All Done!

Now Virtualmin will automatically include your slave server in the NS records for each new domain.

NOTE: If, for some reason, you don't like the default name of the first NS record (taken from the hostname of your server), you can change it in the Server Template(s) that you use, in the BIND DNS domain section. The field is labeled Master DNS server hostname. Just like with the slave servers, this name must be valid and point to the correct IP address, otherwise name service will not work, or will be unreliable.

Domain Registration With Virtualmin

Domain Registration With Virtualmin

Virtualmin now includes a plugin that can be used to automate the process of registering DNS domains. This means that you can full create a new virtual server with a website and domain, and have it visible on the Internet pretty much immediately - there is no need to manually register the domain separately.

The latest version of the plugin supports the Register.com, Gandi and Distribute.IT APIs, but others will follow in future releases. You can use either your existing account with those registrars, or create a new Register.com account using the Virtualmin web interface.

Installing the Domain Registration Plugin

Installing the Module

If you are using a standard install of Virtualmin Pro on a Redhat, CentOS or Fedora system, the plugin can be installed with the command :

yum install wbm-virtualmin-registrar

On a Debian or Ubuntu system, the command is :

apt-get install webmin-virtualmin-registrar

You must be running at least version 3.47 Virtualmin to install it. At the time of writing, this plugin is not included in the standard Virtualmin install, but this will soon change.

Enabling In Virtualmin

Once it is installed, login to Virtualmin as the master administrator. Open the System Settings section on the left menu, and click on Features And Plugins. In the list of features and plugins, check the box next to DNS Domain Registration and click Save at the bottom of the page.

If you want new Virtualmin domains to be registered in DNS by default, check the box in the Default column - if not, leave it un-checked. Since registration costs money, it is probably best to leave this off by default.

Adding or Creating an Account

Now that it is installed and active, refresh the page and then open the Addresses and Networking category on the left menu, then click on DNS Domain Registrars. This will bring you to a list of known registrar accounts - which will be initially empty.

Adding an Account

If you already have an API account with Register.com or any other supported registrar, select the registrar from the Add an existing account menu and click Start Adding. This will bring you to a page for entering details of your account - the most important are the login ID and password.

If you don't yet have a registrar account, one can be created at :

Registrar New Account URL
Register.com https://secure.rconnection.com/sign-up.asp?resell=VIRTUALMIN-TPP
Gandi http://www.gandi.net/reseller/
Distribute.IT http://www.distributeit.com.au/rs_signup.html

Enter a description for this account (such as Foo Corp's registrar account) and your login and password with the registrar, then click Create. If you only want this account to be used for certain TLDs, enter them in the Additionally limit to top-level domains field.

When the form is submitted, Virtualmin will validate the login details, and display an error message if they are incorrect. If all is OK, you will be returned to the list of accounts, which will now show the one you just added. To edit its details, click on the description, and the same form used for adding will be displayed so that you can change the settings.

Creating an Account

Some registrars allow you to create a new account online using this Virtualmin, which you can then use to register domains. To do this, select the registrar from the Create a new account menu, and click Start Creating. The details that you have to enter differ between registrars, but for the purposes of this documentation we will concentrate on Register.com as it is the first registrar supported by the plugin.

The Account description should be set to a short text of your choice to described the account, while the New account login and password must be set to a username and password that will identify the account. If you select a login that is already in use by someone else, Virtualmin will tell you when you try to create the account.

The first part of the form (starting with the Organization name field) is for entering your personal details. The second section (starting with Address) is for your location and contact information. The last section (starting with Credit card type) is for billing details. The costs of domain registration will be charged to the card entered - see the registrar's website for details on how much they charge for different top-level domains.

When you click Create, the new account details will be sent to the registrar. If all the fields have been filled in correctly and the credit card details are valid, Virtualmin will display the ID for the new account. If not, the error message from the registrar will be shown. Depending on the registrar, you may or may not be able to use the account right away - in the case of Register.com, they must first add your IP address to a whitelist of those allowed to access the account, which may take several hours.

Account Management

When you have create one or more registrar accounts, they will be listed on the DNS Domain Registrars page. Each account can be either enabled or disabled - only those that are marked as enabled will be used by Virtualmin when registering domains. To change the enabled status, check the box next to an account and click either the Enable Selected or Disable Selected button.

If you want to edit an account's details, click on its description in the list to bring up a form for changing the login, password, description and allowed top-level domains. Be careful changing the login details, as switching to another account with the registrar may make it impossible to renew or de-register your existing domains.

To remove an account you are no longer planning to use, check the box next to it and hit the Remove Selected button. This will NOT cancel the account with the registrar - just take it out of Virtualmin's list of usable accounts. You cannot do this if any virtual servers exist that were registered with the account, as it would make their future management impossible.

Registering Domains

A Note About Nameservers

When a domain is registered, at least one and often two nameservers must be supplied to the registrar. Virtualmin determines these by looking at the NS records in the DNS zone file, which are in turn set by default from the hostnames of your primary and any secondary nameservers. Alternately, when adding or editing a registrar account, you can enter the specific nameservers that should be used.

Either way, these nameservers must first be registered with the registrar that you created THEIR top-level domain with. So if your company is called myhosting.com and your nameservers are webhost.myhosting.com and ns2.myhosting.com, you must first use your original registrar's website to add those two hostnames (and their IP addresses) as registrars. If not, new domain registration using Virtualmin will fail.

For many top-level domains, you must have at least two separate nameservers - for example, .de is one that enforces this. Fortunately this is relatively easy to set up, and documented on the DNS Slave Auto-Configuration Quickstart page.

Registration

Once you have at least one enabled account, you will be able to use Virtualmin to register domains when they are created, or add registration for existing domains. To do this, just select the Register DNS domain? feature on the Create Virtual Server or Edit Virtual Server forms.

If the domain is available according to your registrar, it will be registered under your account and the nameservers set to your Virtualmin system. If it isn't available, creation of the entire virtual server will be blocked. As the creation process progresses, you will see a message starting with Registering DNS domain, followed by a line showing the success or failure of the registration.

Naturally, you must also select the DNS domain enabled? feature when creating the server, or else there will not be an actual nameserver configuration entry to serve the domain. If creating using the command-line create-domain.pl script, the --virtualmin-registrar flag enables registration.

De-Registration

De-registering a domain is as simple as un-checking the Register DNS domain? box on the Edit Virtual Server page. Or you can just delete the server using Virtualmin. Either way, the registrar used to create the domain will be told to remove the registration, which will make it no longer visible from the rest of the Internet unless you re-register it with a different registrar.

Domain Management

Once a virtual server's domain has been registered using Virtualmin, several options will show up under the Domain Registration category in the left-side menu. Some are only available to the master administrator though.

Editing Contacts

Every registered domain has several contact persons associated with it - the billing contact, administrative contact and technical contact. When the domain is first registered, the contact details will be either set from the parent server's contacts (if any), or from the contact information you provided when creating the registrar account. For domains that are owned by your customers, you may want to change these though.

Depending on the registrar, some or all of the contacts can be edited using the Edit Domain Contacts link under Domain Registration on the left menu. This will bring up a form with several collapsible sections, one for each contact. Edit the details as you see fit, and click the Save button at the bottom of the page. If anything goes wrong updating the registrar, an error message will be displayed.

Because all contacts are the same in most cases, you can use the Same as the first contact? option in contacts after the first to have their details duplicated from the first one. This will be set to Yes automatically (and the section collapsed) if the details are currently the same.

Renewing a Domain

Domains are registered only for a limited period, typically measured in years. When a domain approaches its expiry date, your registrar will typically contact you via email to the administrative or billing contact's address, asking you to renew. This can be done entirely from within Virtualmin, using the Renew Domain link under Domain Registration on the left menu.

Clicking on this link brings up a simple form showing the current expiry date, with a field for entering an additional number of years to renew for. When the Renew Domain Now button is clicked, your registrar will be notified of the request, and your account charged the appropriate renewal fee.

Associating an Existing Domain

If you have already registered a domain manually with a registrar and added the same account for use by Virtualmin, you can inform Virtualmin about the domain using the Associate Domain link on the left menu, under Domain Registration. This will allow you to edit the domain's contacts, renew it, and remove the registration when the virtual server is deleted.

When that link is clicked on, all you should need to do is select the account used to create it originally from the Registered under account menu. If the registrar gave you an ID number or code when the domain was created, enter it into the ID with registrar field - although this is not usually needed. If you want the domain's nameservers modified to match your Virtualmin system, change Update nameservers to Yes. Finally, hit Associate Domain and the success or failure of the association will be displayed.

Dis-Associating a Domain

If you no longer want Virtualmin to manage a domain registration but do not want to actually re-register it, open the Domain Registration category on the left menu and click on Dis-Associate Domain. The click the button on the confirmation form that appears.

If you change your mind, the Associate Domain feature can be used to bring the domain back under Virtualmin's control.

Troubleshooting Common Problems with DNS

DNS Troubleshooting

It's pretty safe to say that a majority of problems in any virtual hosting system will be DNS related, because DNS requires cooperation of numerous systems, rather than just one, and DNS problems can cause trouble with nearly every service on a hosting system.

For DNS to work, it must have correct glue records at your registrar, as well as correct records on your Virtualmin system (or whatever system you choose to use for DNS, if not the Virtualmin server). Also, any slaves must also have correct records, or you will experience intermittent resolution failures.

Glue Records

Checking your glue records can be done using the whois command.

whois example.com

Look for the "domain servers" or "name servers" section of the output. The resulting names must resolve to your DNS servers.

Glue records must be configured at your name service registrar. Virtualmin and Webmin have no control over records at your registrar, so problems must be corrected using whatever interface your registrar provides.

NS Records

The NS records on your Virtualmin server should match those found in the glue records discussed previously, or intermittent problems may result.

You can find the NS records for a given zone using the host command on your server:

host -t NS example.com

A Records

Address records, or A records, are the basic building block of DNS zones. They map names to IP addresses.

To check an A record, use the host command:

host example.com

You can also specify the name server used to resolve queries by adding the name or IP of the server you wish to query to the end of the command:

host example.com ns1.example.com

Or, if you aren't sure about the nameserver IP address resolving correctly, you can use an IP:

host example.com 192.168.1.1

MX Records

Mail exchanger records, or MX records, provide mail servers the information they need to know how to deliver mail for a particular domain.

You can check an MX record with the host command:

host -t MX example.com

Further Reading

The Webmin documentation provides additional information on the topic of troubleshooting name service, as well as the BIND DNS Server module documentation.

Email

Virtualmin Email Basics

POP3 and IMAP Configuration - How to configure common mail clients to download mail using POP3 and IMAP.

Spam and Anti-Virus Scanning - Explanation of Spam and Virus scanning features in Virtualmin.

Email Frequently Asked Questions - Frequently asked and answered questions about email service in Virtualmin systems.

Email Troubleshooting - Troubleshooting common email problems.

Advanced Email Topics

SMTPS Configuration - Configuring Postfix to accept secure SMTP connections for outgoing mail from mail clients.

Hold and Forward Backup Server - Configuration of a hold and forward backup SMTP server, using a second Virtualmin server.

Other Email-related Documents

Email Tutorials - Our step-by-step tutorials related to email.

All Documentation Pages tagged "Email" - A predefined search of pages that have been tagged "email".

Configuring POP3 and IMAP Clients

POP3 and IMAP and SMTP Authentication

Virtualmin configures the Dovecot POP3 and IMAP server for usage with all common mail clients, and Cyrus saslauthd for SMTP authentication on outgoing mail.

POP3/IMAP Username

You can always find the username for a user by looking on the Edit Mail and FTP Users page for the virtual server in which the user exists. It will be displayed in the IMAP/FTP login field. With the exception of users with @ in them, the username will be the same for all services (mail, ssh, FTP, Usermin, etc.).

Username Conventions

Virtualmin, by default, creates system login names by combining the username and the first part of the domain name, separated by a configurable separator ("." by default). Thus, a user named joe within the virtualmin.com domain would use the login name joe.virtualmin.

This is, of course, completely configurable. To choose the username format used, browse to System Settings:Server Templates and select the Mail for domain section, and locate the Format for usernames that include domain field at the bottom of the page.

user@domain.tld Style Usernames

Virtualmin also supports user@domain.tld style usernames, though there are some caveats in this configuration. Specifically, Postfix does not support delivery to users with @ in them, and so Virtualmin creates two users (one that Postfix will deliver to, and one with @).

In order for SMTP authentication to work with users in this format, saslauthd also needs to be configured to include domain information.

On Red Hat, Fedora, and CentOS systems, edit /etc/sysconfig/saslauthd and add "-r" to the FLAGS= line, save it and restart the saslauthd service.

On Debian and Ubuntu, edit /etc/defaults/saslauthd and add the "-r" flag to the PARAMS= line, save it, and restart the saslauthd service.

Thunderbird

Open the Account Settings dialog. Click the Add Account button in the lower right corner of the window. Select Email account and click Next.

Fill in your name and the email address for this account.

Select POP or IMAP, fill in the hostname of the Virtualmin server in the Incoming Server, and then click Next.

On the next page, fill in the username. Click Next.

Give the account a name (the default will be the email address associated with the account).

Email Frequently Asked Questions

How do I set up a catch-all email address to receive or bounce invalid inbound emails?

Note that this is not recommended. It breaks the ability of the mail server to reject mail early in the delivery process, which means your system will work dramatically harder because full spam messages and viruses will have to go through the full processing chain. It is far better to create every alias you need, as you need them.
  1. Virtualmin
  2. Choose the domain name of your server from the pull-down menu
  3. Click "Edit Mail Aliases"
  4. Click "Add an alias to this domain"
  5. Set "Name" to "All mailboxes"
  6. Fill in the delivery settings as usual (a local mailbox, usually).
  7. Click "Bounce mail?" if you want to use this catch-all email account to bounce inbound emails with invalid email addresses.

To "turn off" the automatic email bouncing, simply delete this catch-all email alias.

What's the deal with @ in mailbox usernames?

It's a bad idea, according to Wietse Venema in this post on the Postfix mailing list: http://archives.neohapsis.com/archives/postfix/2000-02/0892.html

Virtualmin has several clever hacks to workaround this particular feature of Postfix, revolving around the creation of a second user with the same UID and paths, which Postfix can deliver to. This has many potential problems and might confuse other software that isn't smart enough to deal with multiple usernames with the same UID (this is perfectly legitimate, and ought to work, but it is a common failing and even some of our stuff has had some bugs uncovered, but now fixed, by this hack).

On recent operating systems (Fedora Core 5+, CentOS 5, Debian 4.0+, and Ubuntu 8.04LTS are all confirmed to have this issue) the Cyrus saslauthd version defaults to dropping the "@domain.tld" portion of the username before attempting authentication. This, obviously, won't work. The solution is to add the "-r" flag to the saslauthd command. On Red Hat based systems, additional flags can be added in the "FLAGS=" section of the file /etc/sysconfig/saslauthd. On Debian-based systems, the file to edit is /etc/default/saslauthd and the directive to modify is "PARAMS=". This is an orthogonal issue to the Postfix issues, and will occur whether you use Sendmail or Postfix as your mail server.

We don't recommend using @ in the username for mailbox users (for the same reasons that Wietse removed support for them in Postfix), but if you must it can be done. Any problems you run into should be brought up in the Bug Tracker, so we can get them resolved. Just because it's a hack doesn't mean we won't make it work as well as any othe naming convention.

Also note that this trick is incompatible with mbox style mail spools (because mail will be delivered to the "wrong" mailbox: user-domain.tld, instead of user@domain.tld). Maildir format mail spools are not subject to this problem, and are the default in Virtualmin if you have used our automated installation script.

If you really do want to use this type of username, edit the Server Template(s) for which you'd like this type of username. Browse to the "Mail for domain" section (select it in the dropdown, if using the Virtualmin theme, or scroll to this section if using any non-menu-ized theme). Find the option labeled "Format for usernames that include domain", and select "user@domain", and save your changes.

Hold and Forward Backup Server

Hold And Forward Backup Mail Server

Configuring a secondary MX server to provide hold and forward mail service in the event your primary mail server is offline. Virtualmin Professional is required on the primary server, and Virtualmin Professional or Virtualmin GPL is required on the secondary server.

Introduction

Mail service is, for many users, the most important internet service. While always-on reliability on virtual hosting systems is impossible (kernel upgrades for security updates, at the very least, require system reboots), the DNS and mail standards provide mechanisms to allow mail to flow successfully even if the primary mail server is temporarily off-line.

Configuration of a secondary mail server is relatively simple, but can be made completely automatic with Virtualmin Professional. To use this automatic backup mail server configuration feature, you must have Virtualmin Professional on the primary server. On the backup server, either Virtualmin Professional or Virtualmin GPL will work.

Pre-Requisites

For this process to work, the following components are needed:

Configuring Virtualmin on the Primary

Adding a server to the Webmin servers list

The first step in this process is to add your secondary server to the list of available Webmin servers. To do this, click on the Webmin link in the upper right corner of the left menu pane to activate the Webmin menu. Then, open the Webmin menu category and click on ''Webmin Servers Index''.

Click the ''Register a new server'' link, and then fill in the form, providing the hostname of the secondary and the port on which Webmin is running. In the Link Type section, select ''Login via Webmin with username ... password ...'' and enter an administrative level username and password.

Once the form is filled out, click ''Save''. Assuming there are no errors, you should now see an icon representing your secondary server in the Webmin Servers Index page.

Setting up Virtualmin to use the secondary mail server

Once the server has been added as a Webmin server, you just need to enable it as a secondary server in Virtualmin. In the left-hand menu, re-activate the Virtualmin menu by clicking on the Virtualmin link in the upper left corner. Now open the ''Addresses and Networking'' menu item, and click on ''Secondary Mail Servers''.

The server you've just configured in the Webmin Servers Index should appear in the list with an empty checkbox beside it. Click the checkbox to activate it. If you already have domains on your server that you want to setup with secondary mail service, also check the ''Add all existing mail domains to secondary MX servers?''. Finally, click ''Save''.

That's it, you're done!

The Gritty Technical Details

Note: If you just want it to work and don't care how, you can stop reading at this point. This is merely for those folks who like to understand what's happening behind the scenes.

This Virtualmin Professional feature makes use of a couple of features of the mail RFCs. First up, it creates an additional MX record, with a lower priority (higher number, but lower priority in the sense that it won't be contacted unless the primary isn't responding) than the primary. Second, it adds an entry on the secondary server to the list of domains that the server will relay for. This causes the secondary to accept mail for the domain, despite not having a local mailbox to place it in.

Since the mail RFCs have well-defined rules about what to do in the event a server is down, this has the effect of causing the secondary to simply accept the mail and hold it in its queue until the primary comes back online. It will automatically attempt to resend the mail periodically, and will only bounce the mail back to the sender if the primary stays off-line for an extended period of time.

SMTPS Configuration

Configuring Encrypted SMTPS

Enable the SMTPS service

Browse to the Webmin:Servers:Postfix module, and click on Server Processes.

Click on the smtps service, and make sure it has the following in the Process command field: smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes. Save it.

Enable TLS support in Postfix

Browse to SMTP Authentication And Encryption in the Webmin:Servers:Postfix module, and set the following options:

Enable TLS encryption? Yes

TLS certificate file /path/to/your/certificate

TLS private key file /part/to/your/key

Optionally, if using a chained certificate:

TLS certificate authority file /path/to/your/CA-file

If you are using a chained certificate (including the popular low cost "Standard Certificate" offered by GoDaddy), the chain (called sf_issuing.crt from GoDaddy) file they provide is the one you need in the certificate authority field. Your key file should never be readable by anyone other than root (Postfix will start as root to bind to its ports and to read in configuration files and SSL files).

Save it, and restart Postfix.

Spam and Anti-Virus Scanning

Spam and Virus Scanning

Virtualmin allows you to enable spam and virus scanning on a per-virtual-server basis, and to configure what happens to email classifies as spam or virus-laden. Under the hood, it uses the popular SpamAssassin http://spamassassin.apache.org/ package for spam detection, and ClamAV http://www.clamav.net/ for viruses.

SpamAssassin assigns each message it scans a score indicating how spammy it is, based on the content and servers it was sent from. Typically, anything with a score above 5 is regarded as most likely spam. ClamAV however just compares the message contents with a database of know virus signatures, and reports if any were found or not.

Turning On Spam and Virus Scanning

In a typical Virtualmin installation, you can enable filtering for a new or existing virtual server by just selecting the Spam filtering enabled? and Virus filtering enabled? checkboxes in the features section of the Create or Edit Virtual Server page.

If they do not appear, make sure that these features are enabled globally on your system. This can be done as follows :

  1. Login as root, open the System Settings category on the left menu, and click on Features and Plugins.
  2. Check the boxes next to Spam filtering and Virus filtering.
  3. Click Save. If you see any error messages about SpamAssassin or ClamAV not being installed, you'll need to install their packages on your system first.

Spam and Virus Filtering and Procmail

Internally, Virtualmin creates an /etc/procmailrc file that in turn runs a Procmail include file under /etc/webmin/virtual-server/procmail, depending on the domain to which each email received is sent. This then invokes the spamassassin and clamscan commands, then uses their output to decide if email should be delivered to a special folder or deleted.

SpamAsssassin is run with command-line parameters that tell it to use configuration files under /etc/webmin/virtual-server/spam, which can be different for each domain. This way, domain owners can customize their own SpamAssassin rules, spam levels and message modification settings.

Changing Delivery Destinations

By default, email classified as spam as delivered to the ~/Maildir/.spam file under each user's home directory. This shows up as a folder named spam in users' mail clients, and in Usermin. Email that is detected as containing viruses is deleted by default, as virus detection is almost 100% accurate.

However, you can change these destinations on a per-domain basis using Virtualmin. Some users may prefer that spam be deleted outright, or delivered normally so that it can be filtered by their mail clients. To change the delivery rules, the steps to follow are :

  1. Login to Virtualmin as root or as the domain owner.
  2. Select the domain from the left menu.
  3. Open the Server Configuration category, and click on Spam and Virus Delivery.
  4. Change the Destination for spam emails and for virus emails to whatever you want.
  5. Click Save. The changes will take effect for email delivered from now on.

In Virtualmin versions 3.54 and above, you can select to have email whose virus score is above some threshold deleted instead of being delivered to a spam folder. This can be used to stop the delivery of messages that are obviously spam, saving on disk spam and the bandwidth used to download them.

To delete high-scoring spam, just follow the steps above and set the Delete spam if score is above field to some number like 10.

Default Delivery Destinations

If you have spam and virus delivery destinations that you want used for all new domains, you can set them as follows :

  1. Login to Virtualmin as root.
  2. Open the System Settings category on the left menu, and click on Module Config.
  3. Select the Spam filtering options section.
  4. Change the Default delivery for spam and for viruses to whatever you want.
  5. Click Save.

To make changes for all existing domains, use the modify-spam.pl command-line API script.

Automatic Spam Clearing

If Virtualmin is configured to deliver spam to a separate folder for each user, this can end up consuming a lot of disk space and disk quotas. To keep usage down, it is possible have Virtualmin automatically delete users' spam that is more than a certain number of days old, or is taking up more than some amount of disk space.

To set this up for a single domain, the steps to follow are :

  1. Select the domain from Virtualmin's left menu.
  2. Open the Server Configuration category, and click on Spam and Virus Delivery.
  3. In the Automatically delete spam? field, select Yes, if older than and enter a number of days into the adjacent text box. I suggest 5 days, which is more than enough time for users to periodically check their spam folders for false positives.
  4. Click Save.

If you prefer to delete based on disk usage, select Yes, when mailbox exceeds instead and enter a maximum size for the spam folder. When this is exceeded, messages will be deleted oldest first until it is smaller than the specified size.

The default setting for new virtual servers can be set on the Module Config page in the Spam filtering options section. To make changes for all existing domains, use the modify-spam.pl command-line API script.

Speeding Up ClamAV on Debian Etch

By default, Debian 4.0 (Etch) comes with ClamAV packages that are out of date and buggy. The most common symptom of this is very slow virus scanning, and high CPU load from clamscan or clamd. However, there is a fix - you can update to a newer ClamAV version from the Debian volatile repository, at http://www.debian.org/volatile/

To use the volatile repository, SSH into your system as root and edit /etc/apt/sources.list. At the bottom, add the line :

deb http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free

Then update ClamAV packages with the commands:

apt-get update
apt-get install clamav clamav-base clamav-daemon clamav-freshclam

Reducing CPU Load with Clamd

In the default Virtualmin configuration, each email received is processed with the clamscan command to check if it contains viruses. Unfortunately, this can take anywhere from seconds to minutes to run, particularly on VPS systems that have limited IO bandwidth or CPU resources. Most of this time is spent loading the virus database, which is continually growing as new viruses are found by the ClamAV authors.

Slowness running clamscan can cause email delivery to be delayed by several minutes, during which messages stay in the Postfix mail queue. It can also lead to high CPU load on the system, which then slows down other services like Apache or MySQL.

Fortunately, there is a fix - the clamd server process, which loads the virus database just once and then stays running. When email arrives, the clamdscan command connects to it, passes over the message to be scanned, then reads back the results. This typically only takes a seconds, even on a system with limited resources.

If your system is receiving a large amount of email, I recommend the use of clamd. It probably isn't worth running on a system used primarily as a web server though, as it consumes about 64M of RAM at all times.

To enable the use of the ClamAV server process, follow these steps :

  1. Login to Virtualmin as root.
  2. Open the Email Messages category on the left menu, and click on Spam and Virus Scanning.
  3. At the bottom of the page you should see a button labelled Enable ClamAV Server - click it. If the button isn't visible, this means that Virtualmin doesn't know how to configure clamd on your operating system, and you will need to do it manually.
  4. After clicking, check the messages that appear to make sure that no errors were reported. If all went well, return to the Spam and Virus Scanning page.
  5. Change the Virus scanning program to Server scanner (clamdscan) , and click Save.

Virtualmin will check if clamd and clamdscan are working properly, and if so configure all virtual servers to use it for virus classification from now on.

Common ClamAV Problems

If Virtualmin reports that the clamscan command is not working on your system, here are some things to try :

Moving Spam and Virus Scanning to Another System

SpamAssassin and ClamAV can use up a lot of CPU time, which on a system that receives a lot of email can significantly slow down email processing. However, it is possible to move some of this load to a separate system, by making use of spamd and clamd, the SpamAssassin and ClamAV server processes.

These can be run on one or two other systems on your network, and Virtualmin on the master system that actually receives email configured to offload scanning to them.

In the instructions below, serverip is the IP address of the system that will be running spamd, and virtualminip is the IP of the Virtualmin machine.

Setting up Spamd on CentOS, Fedora or Redhat

  1. Login to the system you want to run spamd on as root
  2. Install SpamAssassin with : yum install spamassassin
  3. Edit the file /etc/sysconfig/spamassassin and add the following to the SPAMDOPTIONS line : -i serverip -A virtualmin-ipAn example file would look like :
    # Options to spamd
    SPAMDOPTIONS="-d -c -m5 -H -i 193.9.101.242 -A 193.9.101.104"
  4. Run the following commands to start spamd :
    /etc/init.d/spamassassin restart
    chkconfig spamassassin on

Setting up Spamd on Debian or Ubuntu

  1. Login to the system you want to run spamd on as root
  2. Install SpamAssassin with : apt-get install spamassassin
  3. Edit the file /etc/default/spamassassin , and change the line ENABLED=0 to ENABLED=1.
  4. In the same file, add the following to the OPTIONS line : -i serverip -A virtualmin-ipAn example completed line would look like : OPTIONS="--create-prefs --max-children 5 --helper-home-dir -i 193.9.101.120 -A 193.9.101.104"
  5. Run the following commands to start spamd :
    /etc/init.d/spamassassin restart
    update-rc.d -f spamassassin defaults

Configuring Virtualmin to Use a Remote Spamd

Once spamd is running on the remote system, you can configure Virtualmin to use it as follows. Note that this will prevent domains and mailboxes from having their own SpamAssassin rules, unless you setup spam to fetch them from a MySQL or LDAP database .

  1. Login to Virtualmin as root, and go to Email Messages -> Spam and Virus Scanning.
  2. Change the SpamAssassin client program menu to spamc.
  3. Set the Server host for spamc to the IP address of the remote server you setup above.
  4. Click Save.

Now try sending email to a mailbox in one of the domains with spam filtering enabled on your Virtualmin server, and check if SpamAssassin X-Spam headers are added. If not, check /var/log/mail* on both the Virtualmin and spam scanning systems for error messages, and /var/log/procmail.log.

Setting up Clamd on a Remote System

The easiest way to setup clamd is to use Virtualmin's built-in support for configuring it. The steps to do this are :

  1. Install Virtualmin GPL or Pro on the system to be used for running clamd. You don't need to create any domains, or run any other servers like MySQL or Postfix.
  2. Login to the new Virtualmin, and go to Email Messages -> Spam and Virus Scanning.
  3. Click the Enable ClamAV Server button.
  4. SSH into the system as root, and edit the file /etc/clamd.conf and make sure the line TCPSocket 3310 exists and is not commented out.
  5. Also make sure the line TCPAddr 127.0.0.1 does not exist or is commented out.
  6. Run the command /etc/init.d/clamd-virtualmin restart or /etc/init.d/clamd restart to apply the configuration changes.

Configuring Virtualmin to Use a Remote Clamd

Unfortunately, the executables provided as part of the ClamAV package do not seem to support connecting to a remote server. However, the clamd-stream-client program can do this, and can be used by Virtualmin versions 3.63 and later. You can download it from : https://sourceforge.net/projects/clamd-stream-cl/

Once you have the clamd-stream-client-1.3.tar.gz file on your Virtualmin system, it can be compiled and installed with the commands :

tar xvzf clamd-stream-client-1.3.tar.gz
cd clamd-stream-client-1.3
./configure
make
make install

You can now configure Virtualmin 3.63 or later to use it as follows :

  1. Login to Virtualmin as root, and go to Email Messages -> Spam and Virus Scanning.
  2. Change the Virus scanning program to Remote server scanner
  3. In the Server host for clamd-stream-client field, enter the hostname of the system running Clamd that you setup in the previous section.
  4. Click Save.

Assuming that clamd-stream-client works and can contact the remote system, it will be enabled and used for virus scanning for all domains.

Troubleshooting Common Email Problems

Troubleshooting Email

Mail is perhaps the most complex component in a Virtualmin system, combining a mail transfer agent (usually Postfix, but optionally Sendmail or qmail), a mail delivery agent (usually procmail), POP3/IMAP retrieval (usually Dovecot), anti-virus (ClamAV), anti-spam (SpamAssassin), and mail log analysis (Virtualmin's built-in mail log analysis tools, and optionally logwatch and others). If any one of these components fails, mail may be completely broken for some or all tasks.

Logs

The first place to look for information about a mail problem is the relevant logs. On Red Hat, Fedora, CentOS, SUSE, and Mandriva systems, the majority of mail related logging is directed to /var/log/maillog. Thus, you should check the contents of this log while attempting whatever action is giving you trouble. Most failed actions will result in a log action, possibly a very helpful one. The log /var/log/secure may also contain information about failed login attempts, possibly including a reason.

On Debian and Ubuntu systems the mail log is called /var/log/mail.log and will contain similar information as that found in the /var/log/maillog mentioned previously. Debian/Ubuntu also has a /var/log/mail.err and /var/log/mail.info which may or may not contain information, depending on the MTA in use and the configuration of syslog.

DNS Resolution for Mail

Many issues with mail can be traced back to incorrect DNS configuration. Check to be sure DNS works for the problem domain, and returns valid records. In particular, check the MX record and the name it points to to be sure other hosts can correctly look up the address of your server.

To test DNS resolution you can use the host and dig commands.

For example, here's and example interaction checking the MX record for virtualmin.com:

# host -t mx virtualmin.com
virtualmin.com mail is handled by 5 mail.virtualmin.com.
# host mail.virtualmin.com
mail.virtualmin.com has address 70.86.4.226

This first checks for a MX (mail exchange) record, and then checks to see what address that name resolves to. Mail servers must also reverse resolve in order to be able to deliver to a large number of mail servers on the Internet, as reverse resolution is used as a simple tool to reduce spam by ruling out many classes of dynamic address (like some dialup accounts). Reverse resolution can also be tested with host:

# host 70.86.4.226
226.4.86.70.in-addr.arpa domain name pointer e2.4.5646.static.theplanet.com.

Note that it doesn't matter what the server reverse resolves to. It just matters that it does resolve. Note also that if you run these commands on your Virtualmin server, you aren't necessarily getting a complete picture of DNS. If your glue records at your registrar are incorrect, hosts other than the Virtualmin server will get completely different results from these commands (and they will also be unable to talk to your server, since they're looking for name information in the wrong place). You can use whois to check your glue records, but that's beyond the scope of simple email troubleshooting. See the Webmin BIND documentation, particularly the http://doxfer.com/Webmin/BINDTroubleshootingTools|BIND Troubleshooting Tools section.

Is Spam Filtering Working?

Sometimes it can seem like you've hooked right into the firehose that is the Internet and spam is spewing directly into your mailbox without any limit. It may be, if SpamAssassin isn't configured correctly or procmail is broken in some way. To find out if your mail is being processed by the spam filter, look in the headers of a message received on your server. In Usermin or the Webmin Read Mail module, you can see the headers on a message by clicking the View Full Headers link in the upper right corner of the email. Most mail clients have some sort of option to allow you to see the raw message or the full headers.

If spam filtering is happening correctly, there will be one or more X-Spam-* headers within the header. If no such message appears, procmail or SpamAssassin may be disabled for domain or the user, or mis-configured.

Is Virus Scanning Working?

This one is even easier to test. Write yourself an email with an attachment containing the EICAR test string. If it makes it to your mailbox, then AV scanning isn't working. If it doesn't, things are working fine.

The EICAR test string and information about it, can be found on the http://www.eicar.org/anti_virus_test_file.htm|EICAR home page.

Bouncing With Reverse Resolution Failures

Many mail servers in the wild will reject email from a server without correct reverse resolution.

Reverse is different than forward resolution. The authoritative server is defined by the owner of the IP address (i.e. your hosting provider or network service provider). Usually, this is just setup to whatever the provider likes, and that's fine. It doesn't matter what name it resolves to, as long as it resolves to something.

Webmin handles reverse DNS zones--but it's out of the scope of Virtualmin, because Virtualmin would end up assigning a new name every time you created a new virtual server on a shared IP. By that, I mean that you create one reverse entry for every IP address--not one for every virtual host that lives on it. It's also not something we can automate away--it requires cooperation from your hosting or network provider, or whoever is authoritative for your IP addresses.

So, to add reverse DNS, you'll first have to figure out who is authoritative for your IP address(es), and ask them to do one of the following:

  1. Provide a reverse entry for all of your IPs in their DNS servers.

  2. Delegate the zone to your DNS servers. everydns.net probably does not provide reverse resolution services, so you'll need to point them to your Virtualmin server, fire up BIND, and create those entries.

You definitely want reverse lookups on your IP to work, as it's considered "spammy" by most spam filters and mail servers when it doesn't.

You can find out what name servers are currently responsible for a zone with:

whois 192.168.1.1

Replacing 192.168.1.1 with your servers IP address, it will list lots of details about the IP, including the servers for the PTR records.

Usermin Webmail Sends With Incorrect From: Address

In most cases, if Usermin webmail does not include the correct From: address, it is incorrectly configured. The default was not being set correctly in our automated installer until recently due to a bug.

The old default would default to a From: address of the form "user-domain@hostingco.tld", when it should instead be "user@domain.tld".

To correct this problem:

Browse to Webmin:Usermin Configuration:Usermin Module Configuration:Read Mail page

Locate the option labeled From: address mapping file, and set it to /etc/postfix/virtual

Locate the option labeled Address mapping file format, and set it to Address to username (virtusertable)

Save it.

No space left on device errors

A particularly tricky problem with mail processing, delivery, and retrieval may be seen on systems that use disk quotas. Specifically, it will manifest as errors about disk space, even on a disk with plenty of free space.

ClamAV processing causes delivery to fail

Because mail processing with SpamAssassin and ClamAV can be temporarily very disk space intensive, it can run into disk quotas while it will appear that disk usage is still well below the limit you've imposed.

The solution to this problem is to mount the /tmp directory that clamav or clamd are configured to use on a partition separate from /home. This will allow clam to use as much space as it needs in order to decompress files and process them.

We now recommend all installations that will use disk quotas to use an independent /home partition--that is separate from /, /tmp/, and /var directories.

Dovecot won't allow mail retrieval if disk quota is filled

This is caused by the inability of Dovecot to manage its index files on a "full" disk. Dovecot can be configured to place indexes in a different location from the mailbox, which resolves this problem (though it does mean users can use slightly more than their disk quota on the system, but indexes are generally pretty small, so this shouldn't be a big concern).

To configure Dovecot to use an alternate location for index files, you can set the followin