How to use the documentation - Start here. It provides a brief (about one page) overview of the conventions and organization of this documentation.
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.
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.
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.
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.
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.
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?
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.
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.
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.
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.
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.
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.
A guide for Virtualmin Reseller account holders. Documents domain creation, editing, maintenance, and script installation.
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.
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.
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.
At the bottom of the left-hand menu, you'll find a Logout link. Clicking this link will, obviously, log you out of Webmin.
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.
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).
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.
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.
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.
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 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).
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 allows you, the domain virtual server account holder, to manage your website files, mailboxes, databases, DNS entries, and install scripts.
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.
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.
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.
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.
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.
Filezilla
A free graphical FTP client that supports FTP over SSH is Filezilla. http://filezilla.sourceforge.net/|Filezilla Home Page.
To Configure Filezilla:
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.
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]
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.
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.
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.
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.
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.
To use the Cloudmin paid AMI, the steps to follow are :
ec2-describe-images -o 541491349868
You should see at least one in the available state.
ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair chmod 700 ~/.ssh/id_rsa-vgpl-keypair
ec2-run-instances ami-a5bf59cc -k vgpl-keypair
This will output the new instance ID, which is like i-10a64379
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 .
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
ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
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 :
Cloudmin also needs at least one SSH key to login to EC2 instances it creates. To add one, do the following :
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.
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 :
ec2-describe-images -o 093590521311
You should see at least one in the available state.
ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair chmod 700 ~/.ssh/id_rsa-vgpl-keypair
ec2-run-instances ami-7c1df915 -k vgpl-keypair
This will output the new instance ID, with is like i-10a64379
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 .
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
ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
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
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
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.
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.
To use this new paid AMI, the steps to follow are :
ec2-describe-images -o 541491349868
You should see at least one in the available state.
ec2-add-keypair vgpl-keypair >~/.ssh/id_rsa-vgpl-keypair chmod 700 ~/.ssh/id_rsa-vgpl-keypair
ec2-run-instances ami-6d4ca904 -k vgpl-keypair
This will output the new instance ID, which is like i-10a64379
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 .
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
ssh -i ~/.ssh/id_rsa-vgpl-keypair root@ec2-WHATEVER.compute-1.amazonaws.com
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.
Virtualmin on EC2 works exactly the same as it would on a regular system. For full documentation, see : http://www.virtualmin.com/documentation/
How to use the documentation - Start here. It provides a brief (about one page) overview of the conventions and organization of the Cloudmin documentation.
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.
Introduction to Virtualization Concepts - Introductory coverage of virtualization concepts, types of virtualization, and how Cloudmin interacts with virtualized cloud servers.
Setting Up Linux Xen Virtualization - Using Cloudmin with Linux 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
Location Groups - Simplifying host system allocation with location groups
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 a Xen Virtual Machine - How to create a new Xen Virtual Machine.
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.
Backup and Restore - Backing up Cloudmin systems on schedule.
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?
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.
Managing Virtual Disks - Creating additional disk images 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.
System Monitoring and Alerts - Setting up email notifications when systems go down or exceed thresholds.
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.
In Cloudmin, an account plan is a set of restrictions that can be applied to a system owner. Plans can limit the following :
All limits apply to the total usage of all systems owned by the user the plan is applied to.
Cloudmin comes with one default plan that is created when installed. To add your own plans, do the following :
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.
Once a plan has been created, you can apply it to an owner as follows :
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.
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 :
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 :
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.
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 :
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.
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.
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.
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 :
/backup.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.
Once a default destination has been set, you can schedule a backup like so :
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.
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.
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 :
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.
Explains how to use the command-line scripts included with Cloudmin to manage users, aliases, servers, databases and resellers.
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.
API commands are broken down into the following categories :
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 :
192.168.1.1 and 192.168.1.200.255.255.255.0.Once the range has been created, it will be available when creating or editing host systems.
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 :
root password to set for the new system into the adjacent field.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.
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 :
root password to set for the new system into the adjacent field.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.
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 :
root password to set for the new system into the adjacent field.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.
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 :
root password to set for the new system into the adjacent field.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.
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.
An image is created from a virtual system running on Amazon's EC2 service. The steps to make an image are :
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.
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.
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 :
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.
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 :
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.
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.
If you want to change the rules for an existing group, the steps to take are :
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.
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.
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.
To request a new static EC2 address, follow these steps :
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.
Once an address has been requested, you can assign it to an EC2 system as follows :
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 (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.
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.
To create an EC2 volume in Cloudmin, do the following :
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).
Once you have at least one EC2 volume, Cloudmin will allow you to create a snapshot of it as follows :
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.
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 :
/mnt/disk2 or /home.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.
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.
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 :
/root/.ssh/id_rsaAlternately, you can have Cloudmin generate a new key or use one that you paste in on that same form.
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 :
xen.example.com.cloudmin.example.com.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 :
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 :
If Cloudmin does not detect any problems with the host system, it can now be used to host new virtual instances.
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 :
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.
Once all the steps above are complete, you can create a new virtual system as follows :
myvps.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.
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.
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.
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 :
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.
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 :
yum install perl
yum install openssl openssl-devel perl -MCPAN -e 'install Net::SSLeay'
rpm -U http://www.webmin.com/download/rpm/webmin-current.rpm
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'
rpm -U wbm-server-manager-*.rpm wbt-virtual-server-theme-*.rpm
/etc/server-manager-licenseAnd 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.
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.
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 :
cloudmin.virtualmin.com to download packages via HTTP? If it is blocked by a firewall, the install will fail./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.
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.
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.
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.
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.
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.
To add a new location group, do the following :
Once a group has been created, you can assign a host system to it as follows :
Once at least one running host system is in a group, you will be able to select it on the Create System page.
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 :
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.
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 :
To add an additional image storage location, the steps to follow are :
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 :
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.
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.
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 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.
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.
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.
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.
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.
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 Xen system has one or more files or devices on the host system (like /xen/mysystem.img</code)> mapped to devices on the virtual system (like <code>/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 syste, 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.
The most common operation to perform on a disk image is expanding it when the filesystem is full. The steps to do this are :
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.
For KVM 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.
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 :
A reboot of the virtual system will be needed before the new disk is available.
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.
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.
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.
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.
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 :
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.
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.
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 :
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.
As well as creating domains, Cloudmin can be used to delete, disable and enable them. The steps to do this are :
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.
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 :
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.
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 :
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.
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 :
/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
chmod +x /etc/xen/scripts/multiple-bridge/etc/xen/xend-config.sxp and find the line like (network-script network-bridge) line, and change it to (network-script multiple-bridge)/etc/init.d/xend restartifconfig -a command.If you have multiple host systems, these steps must be performed on each of them.
Once the additional bridge is active on the Xen host, you can configure Cloudmin to use it as follows :
xenbr0 and xenbr1.xenbr1 bridge in the For interface column.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.
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.
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 :
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 :
The steps to add a system for Xen hosting are :
Once at least one system has been registered, you will be able to create Xen instances using Cloudmin.
The steps to add a system for Linux VServers hosting are :
Once at least one system has been registered, you will be able to create VServers instances using Cloudmin.
The steps to add a system for Zones hosting are :
Once at least one system has been registered, you will be able to create Solaris Zones using Cloudmin.
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.
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.
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.
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.
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'
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 :
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.
To configure Cloudmin to replicate one or more virtual servers from a source system to one or more destinations, follow these steps :
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.
To instead copy global settings like plans between systems running Virtualmin, follow these steps :
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.
When replication is enabled, Cloudmin will copy the following to all replicas :
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.
The process for setting up a new Cloudmin replica is :
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.
To configure a system to copy settings to one or more Cloudmin replicas, the steps to follow are :
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.
If your original Cloudmin master system fails and you have a single replica, it can be switched to become the new master as follows :
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 :
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 .
To setup a Redhat-based system to host KVM instances, the steps to follow are :
yum install kvm qemu qemu-img parted/etc/sysconfig/network-scripts directory, copy ifcfg-eth0 to ifcfg-br0.DEVICE line to DEVICE=br0.ifcfg-eth0 file, and at the bottom add the line BRIDGE=br0service network restart . This should be done at the console, as it will break network access to the host system if anything goes wrong.apt-get install kvm qemu parted/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
/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./kvm . This can be located anywhere on the system though.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.
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 :
Once a volume group has been created, you can configure Cloudmin to use it as follows :
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 :
cd /etc/yum.repos.d wget "http://download.openvz.org/openvz.repo" rpm --import "http://download.openvz.org/RPM-GPG-Key-OpenVZ"
yum install ovzkernel . Or if you want a kernel that can host both Xen and OpenVZ, use yum install ovzkernel-xen .default= line refers to the new OpenVZ-capable kernel section - typically this will need to be set to default=0# 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
SELINUX= line to SELINUX=disabledOnce you have the kernel on the host system, other needed utilities can be installed as follows :
yum install vzctl vzquota/etc/init.d/vz startvzlist -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 .
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 :
/etc/selinux/config and changing the SELINUX line to :
SELINUX=disabled
yum upgrade
/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
/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
yum install kernel , or if you are using an SMP system yum install kernel-smp . The reboot with the reboot command./proc/virtual/info exists. It should contain something like
VCIVersion: 0002:0001 VCISyscall: 273 VCIKernel: 03000016
yum install util-vserver util-vserver-core util-vserver-lib util-vserver-sysv util-vserver-build
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.
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 :
eth0. For the sake of these instructions, let's say it is 192.168.10.10.To use Webmin to shut down other services that may use ports needed by Virtualmin in VServers, do the following :
apache , httpd , sendmail , postfix , named , proftpd , vsftpd , dovecot and mysql .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.
Once you have a freshly installed system running CentOS 5, the steps to set it up for Xen hosting are :
root via SSH or at the console.yum install kernel-xen kernel-xen-devel
/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/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).yum install xen
cat /dev/null >/etc/libvirt/qemu/networks/default.xml
reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.xm list
If you see a line starting with Domain-0, then all is good.
/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.
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 :
root via SSH or at the console.up2date -u
up2date kernel-xen kernel-xen-devel
/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/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).up2date xen
cat /dev/null >/etc/libvirt/qemu/networks/default.xml
reboot command. If you are at the console, you should be able to see Xen-related messages during the kernel boot process.xm list
If you see a line starting with Domain-0, then all is good.
/xen directory, which Cloudmin uses by default for Xen system images, with the command
mkdir /xen
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 :
cd /tmp wget http://www.webmin.com/download/webmin-current.pkg.gz gunzip webmin-current.pkg.gz pkgadd -d webmin-current.pkg WSwebmin
http://yourserver:10000/ as root with your system's root password, to make sure that it is running.mkdir /zones
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.
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 :
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.
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.
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.
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.
To create a new system owner account, do the following :
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.
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 :
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.
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 :
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.
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
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.
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
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.
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 :
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.
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.
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 :
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.
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.
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 :
The master system will most likely have the status Webmin but no Virtualmin, unless you are also using it to host domains with Virtualmin.
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 :
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.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.
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.
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.
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.
Once you have several systems registered, it becomes convenient to perform operations on more than one at once. This can be done as follows :
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.
To aquire a new Virtualmin license and add it to Cloudmin, follow these steps :
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.
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.
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.
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 :
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.
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 :
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.
Databases in Virtualmin FAQ - Have questions about database support in Virtualmin?
Database troubleshooting - Troubleshooting common problems with databases in Virtualmin
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.
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.
Command Line API - Command line tools for managing Cloudmin.
Remote API - Remote access to the Cloudmin API.
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.
Explains how to use the command-line scripts included with Virtualmin to manage users, aliases, servers, databases and resellers.
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.
API commands are broken down into the following categories :
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.
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.
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.
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 :
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.
This function must return a short name for the script, usually a couple of words at most.
sub script_wordpress_desc
{
return "WordPress";
}
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" );
}
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" );
}
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";
}
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 );
}
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");
}
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");
}
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" );
}
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" );
}
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.
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.
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;
}
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'}", };
}
}
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;
}
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;
}
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");
}
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 :
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);
}
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.");
}
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 :
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;
}
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.
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.
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");
}
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'});
®ister_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 .");
}
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.
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).
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.
Explains how to manage Virtualmin servers, users, databases and other features remotely from other programs.
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.
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 :
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.
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.
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.
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'
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;
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.
The steps to start writing your own plugin are similar to those for creating a new Webmin module :
/usr/libexec/webmin on Redhat-derived systems, /usr/share/webmin on Debian and Ubuntu, or /opt/webmin on Solaris.virtualmin- - so for the purposes of this documentation, we will assume that yours is going to be called virtualmin-yourname .help and lang sub-directories.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.
virtualmin-yourname-lib.pl. Initially, it can contain the following code :
use WebminCore;
&init_config();
&foreign_require("virtual-server", "virtual-server-lib.pl");
1;
virtual_feature.pl, containing the following initial code :
do 'virtualmin-yourname-lib.pl';
sub feature_name
{
return "A description of your plugin";
}
/etc/webmin/module.infos.cache to clear Webmin's cache of installed modules.With this done, you can now start work on expanding the capabilities of the plugin by implementing the API documented below.
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 .
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 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 :
dom - the domain name, like foo.comuser - the administration username for the domainhome - the server's home directoryip - the server's IP address (which may be virtual or shared)
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.
Functions in this section must be implemented by all plugins.
This must return a short name for the feature, like My plugin.
sub feature_name
{
return "My plugin name";
}
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.
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";
}
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;
}
}
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";
}
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";
}
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;
}
}
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";
}
}
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;
}
}
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;
}
}
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");
}
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");
}
}
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");
}
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");
}
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.
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 :
$module_name)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 ( );
}
}
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;
}
}
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 :
mod - The module the link is to, typically $module_name .desc - The text of the link.page - The CGI within the module that the link is to.cat - The left-side menu category that this link should appear under, such as services or logs.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',
} );
}
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.
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;
}
}
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'}" );
}
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.
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"));
}
}
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;
}
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");
}
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"};
}
}
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.
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 = ©_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;
}
}
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 = ©_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;
}
}
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.
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 :
setting or email or ip.
sub settings_links
{
return ( { 'link' => "/$module_name/edit_config.cgi",
'title' => "My plugin configuration",
'icon' => "/$module_name/images/config.gif",
'cat' => 'setting' } );
}
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 :
title - The title of the sectionhtml - The HTML to appear within the section when it is opened. Forms that submit to CGIs within the plugin are perfectly OK.status - Set to 1 if you want the section to be open by default, 0 if not.for_master - This must be set to 1 if the section should be visible to the master administrator.for_reseller - Set to 1 if it should be visible to resellers.for_owner - Set to 1 if it should be visible to individual domain owners.
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 } );
}
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 :
user - The full Unix username of the user, which may have the domain name appended, like jcameron-foo.real - The real name of the user, such as Jamie Cameron.home - The user's home directory, which is typically under the virtual server's home.pass - The user's encrypted Unix password.plainpass - If the user's password has just been changed or set, this field will contain the plain text password. It is not always available though, for example when editing a user without changing the password.
The functions that can be added to virtual_feature.pl to support user capabilities are :
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.
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.
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);
}
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);
}
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);
}
}
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";
}
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";
}
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'}));
}
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'};
}
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.
This function must return the name of the database type.
sub database_name
{
return "FooSQL";
}
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 :
name - The unique database name.type - The database type code, typically set to $module_name.desc - A description of the database type, usually the same as returned by database_name.users - A flag, set to 1 if the database supports multiple users, 0 if not.link - A URL path for managing the database's contents. If you have not implemented this, it this key can be left out.
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;
}
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;
}
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;
}
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;
}
}
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;
}
}
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) );
}
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'");
}
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'");
}
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'");
}
}
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'");
}
}
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;
}
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.
A quick guide to assist administrators who want to use Virtualmin's automatic DNS slave configuration features. This allows for DNS server redundancy.
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".
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 http://www.webmin.com|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.
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.
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
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.
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.
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 :
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.
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.
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.
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
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
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
The Webmin documentation provides additional information on the topic of troubleshooting name service, as well as the BIND DNS Server module documentation.
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.
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.
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".
Virtualmin configures the Dovecot POP3 and IMAP server for usage with all common mail clients, and Cyrus saslauthd for SMTP authentication on outgoing mail.
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.).
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.
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.
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).
To "turn off" the automatic email bouncing, simply delete this catch-all email alias.
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.
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.
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.
For this process to work, the following components are needed:
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.
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!
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.
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.
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.
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.
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 :
root, open the System Settings category on the left menu, and click on Features and Plugins.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.
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 :
root or as the domain owner.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.
If you have spam and virus delivery destinations that you want used for all new domains, you can set them as follows :
root.To make changes for all existing domains, use the modify-spam.pl command-line API script.
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 :
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.
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
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 :
root.clamd on your operating system, and you will need to do it manually.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.
If Virtualmin reports that the clamscan command is not working on your system, here are some things to try :
freshclam to download the virus database. On some systems, the standard ClamAV packages do not include any virus data files, so clamscan cannot run.Example line from /etc/freshclam.conf. On some systems this line exists by default, to intentionally prevent freshclam from running!/etc/clamd.conf matches the directory updated by freshclam. If not, clamd will not start due to the lack of data files.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.
spamd on as rootyum install spamassassin/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"
spamd : /etc/init.d/spamassassin restart chkconfig spamassassin on
spamd on as rootapt-get install spamassassin/etc/default/spamassassin , and change the line ENABLED=0 to ENABLED=1.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"spamd : /etc/init.d/spamassassin restart update-rc.d -f spamassassin defaults
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 .
root, and go to Email Messages -> Spam and Virus Scanning.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.
The easiest way to setup clamd is to use Virtualmin's built-in support for configuring it. The steps to do this are :
clamd. You don't need to create any domains, or run any other servers like MySQL or Postfix.root, and edit the file /etc/clamd.conf and make sure the line TCPSocket 3310 exists and is not commented out.TCPAddr 127.0.0.1 does not exist or is commented out./etc/init.d/clamd-virtualmin restart or /etc/init.d/clamd restart to apply the configuration changes.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 :
root, and go to Email Messages -> Spam and Virus Scanning.Assuming that clamd-stream-client works and can contact the remote system, it will be enabled and used for virus scanning for all domains.
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.
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.
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.
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.
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.
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:
Provide a reverse entry for all of your IPs in their DNS servers.
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.
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.
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.
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.
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 following in the dovecot.conf:
default_mail_env = maildir:%h/Maildir:INDEX=/var/cache/dovecot/index/%u:CONTROL=/var/cache/dovecot/control/%u
Or (depending on the Dovecot version):
mail_location = maildir:%h/Maildir:INDEX=/var/cache/dovecot/index/%u:CONTROL=/var/cache/dovecot/control/%u
This will tell Dovecot to use a different filesystem for those control and index files that it is having trouble writing to. Just make sure you create /var/cache/dovecot/index and /var/cache/dovecot/control first, and make them mode 6777.
Then re-start the Dovecot server.
The Webmin wiki covers the following topics in some detail:
Documentation is divided into a few categories, such as "Email", "DNS", and "Database", which covers the common types of service you'll be managing with your Virtualmin 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 Virtualmin and the services it manages. For example, the FAQ for Email includes a brief, non-technical, description of the email processing stack in a default Virtualmin system. 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 Virtualmin does things.
Pages labeled "Troubleshooting" are intended to help you solve specific problems. If you are receiving an error message from a service or Virtualmin, the troubleshooting section for that particular service may have solutions. For example, the Web troubleshooting guide includes solutions to many problems relating to problems running applications, error conditions, and VirtualHost related anomalies (such as the wrong site showing up, or confusion about "default" websites). Troubleshooting pages are specific and technical, and are intended to help you solve problems.
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.
Virtualmin 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 Installation - Installation of the full Virtualmin stack using our automated install script. This is the recommended way to install Virtualmin.
Manual Installation - Installation of Virtualmin and related packages manually. This method is time-consuming, and requires a high level of technical experience. This is not recommended, except in cases where the automated installation is inappropriate or impossible.
Installation Troubleshooting - Troubleshooting common problems encountered during installation.
Uninstalling Virtualmin - Uninstallation, downgrading from Virtualmin Professional to Virtualmin GPL, and selective removal of packages.
There are two methods for installing Virtualmin Professional: a fully automated shell script and package-based install, as documented here, and a manual installation using either native packages or .wbm Webmin packages, as documented in the Manual Virtualmin Installation page. When possible, the automated installation is recommended, as it removes many possible errors during configuration and insures that all applications are built with appropriate options for virtual hosting within the Virtualmin system.
Installation involves first installing a basic install of your preferred Operating System, according to the documentation provided by your OS vendor. If the vendor provides a "server" version of the system, it is generally recommended you use it, as it will include fewer extraneous packages. A list of supported Operating Systems is provided at the OS Support page. There are a few simple guidelines for your system that must be met for proper operation of all Virtualmin features, which are detailed in the rest of this section.
The partitions on your Virtualmin server should be allocated in one of the the following two ways, depending on your requirements and preference. Either partition scheme is supported by the Virtualmin Professional Installer. Other partition layouts may lead to incorrect configuration of filesystem quotas, but can be corrected after installation is completed if other partitioning schemes are preferred.
In this partition layout, you will only have one system partition plus a swap partition and /boot partition. The system partition contains /home for users, /var for logs and databases, as well as all of the normal system executable files, documentation and libraries. It is often simpler to deploy. Traditionally, "one big partition" was considered problematic from an administration standpoint, but most such issues have been resolved by modern filesystems, backup utilities, and improved hardware reliability.
swap: The swap partition should be at least twice the size of RAM on the system.
/boot: The /boot partition should be large enough to accomodate a few system kernels and initrd images. Your OS vendor probably knows best what size this should be.
/: The remainder of the disk(s) should be devoted to /. This is where all system and user data will go.
Note If you plan to use disk quotas, you should be aware of a few potential gotchas with this type of deployment. Quotas apply to all files on a given partition, regardless of the directory. In the case of mail delivery and processing, there are several very sneaky ways for this to cause failures of various types. Because of this, if you are using disk quotas, you probably want to make /home its own very large partition.
This layout spreads files across a few partitions, in order to facilitate usage some types of backup utility as well as making some types of administrative task easier (for example, installing larger disks for some partitions at a later time). Historically, multiple partitions were considered wise administrative policy, but most modern systems and backup utilities eliminate the reasons for utilizing multiple partitions.
/: This partition is used for all of the operating system files, executables, and configuration files. This partition should be at least 3.5 GB for most operating systems.
/boot: The /boot partition should be large enough to accommodate a few system kernels and initrd images. Your OS vendor probably knows best what size this should be.
swap: The swap partition should be at least twice the size of RAM on the system.
/var: The /var partition is where system logs, various changing data, and MySQL and PostgreSQL databases are stored. Depending on whether you will allow your domain users to use the database features, this partition may be between 2 GB and 10 or more GB. If users are expected to be heavy database users, you may opt to divide the remaining disk space between /var and /home.
/home: The home partition is where all of your domain users data, email, CGI scripts, logs etc. will be stored. Pretty much anything that belongs to your users, except for MySQL and PostgreSQL databases, will reside on /home. Devote the remainder of your disk to /home, as usage will likely grow rapidly if you have many users.
In order for the install.sh installation method to work, your system must have a working package management system. Supported systems are yum and up2date on RPM-based systems, and apt-get on Debian systems. The Virtualmin Professional installer uses the native package manager in order to cleanly and safely install all of the appropriate software dependencies. The installer will then install the Virtualmin, Inc. provided packages, including some custom versions of packages that include features necessary for all features of Virtualmin to operate. If your native package management tool requires configuration to operate correctly, this step should be done before running the Virtualmin Professional install script. For example, up2date has to be configured before it will successfully install packages, which can be done by simply running the up2date utility manually from the command line or the GUI. The installer will attempt to configure apt-get to use the universe repository on Debian and Ubuntu.
On Red Hat Enterprise Linux and CentOS systems, in all 3.x and 4.x versions, the up2date system is used to install some components from the system repository. Please run up2date (or the up2date GUI client) at least once prior to running the Virtualmin Professional Installer. If you do not, the installer will stop when the standard component installation phase is reached, and will require human intervention.
up2date must be run once before running install.sh or installation will fail.
On FreeBSD the automated installation makes use of both the ports system and the remote installation capability of pkg_add. You must insure both of these tools are in full working order before attempting to install Virtualmin using install.sh. Documenting these utilities is well beyond the scope of this guide. Consult with the FreeBSD documentation for further details.
See also: [[FreeBSD Installation and Configuration]]
Packages in Virtualmin depend on a lot of OS-standard packages in addition to the packages our repositories provide. And most package managers are a bit temperamental about dependencies; sometimes they'll refuse to install a package because an older version of one of its dependencies is installed. So, in order to avoid dependency problems of this sort it is best to fully update your system using your native package manager prior to running the install script.
The Virtualmin installer requires network connectivity, including DNS resolution. The speed of your connection may impact the speed of installation, as up to 200 MB of packages will be downloaded and installed (if your system already has the majority of the dependencies installed, the download size will be reduced). Latency and bandwidth usage can be reduced significantly for multiple system installations by running a local caching proxy server like Squid, or by operating a mirror of the Operating System being used. It is also possible to pre-install most of the packages during OS installation, and only updates will need to be downloaded over the network.
So, let's boil down all of those preliminaries into a simple checklist. These are the things you need to do before running the install.sh:
Note: If you are installing on a low memory system, the package manager (both yum and apt-get/dpkg) can be very memory intensive during installation. A possible solution is to disable all but the necessary repositories (the OS standard repositories and the Virtualmin repositories. This is generally a good idea, anyway, as packages from non-OS sources may conflict with the Virtualmin packages and lead to unpredictable results.
Installation is performed automatically by the OS-neutral Virtualmin Professional install.sh script. This script sets up the license key in /etc/virtualmin-license and configures the appropriate package management and installation tool for use with the password-protected Virtualmin software repository. It will then install the virtualmin-base package, which performs the remainder of the installation, appropriate for your OS and version.
Download the file from the Software Registrations page at [[http://www.virtualmin.com/serial/]]. All of your purchased products will be available for download throughout the life of your license period. Copy the file on to the server to be installed, using scp on Linux or Mac OS X client machines or WinSCP or PSCP on Windows.
Note: A frequent source of trouble is the use of FTP to make the transfer to your server. Because Windows uses different line endings than UNIX and Linux systems, the script can become corrupted if care is not taken to insure a "binary" mode transfer. scp and FTP over SSH are not generally subject to this problem, and so using the scp protocol for the transfer avoids many possible troubles.
Then, as root, run this:
# sh ./install.sh
Depending on your OS and the state of your system, the install.sh script may ask one or more questions.
If your system is a RHEL or CentOS version 3 or 4 system, you will be asked to confirm that you have run up2date at least once before running install.sh. If you have not run up2date before running install.sh, exit the installer and run "up2date -u". This will insure the forced non-interactive configuration process of up2date is already completed--if you haven't run up2date before running install.sh the process will hang forever while trying to install system-provided packages. This does not effect versions 5 and above of these systems, or any other supported OS.
If your system does not have a fully qualified domain name (FQDN), the installer will stop and ask you to choose one. This is mandatory because many services rely on having a fully qualified domain name in order to function. Mail, in particular, but some Apache configurations and many of the Virtualmin-created configuration files, also require a valid fully qualified domain name to function correctly. A fully qualified domain name is one of the form "www.virtualmin.com", or simply "virtualmin.com". We recommend you choose a name that is not one for which you will be receiving mail, in order to simplify later configuration. A good choice is to use a name server designator, such as "ns1.virtualmin.com". Some customers also choose something like "host1.virtualmin.com" or "primary.virtualmin.com". Any of these would be valid and would satisfy the install script and the services that rely on this option. The install script will add this name to /etc/hosts, which will satisfy all local services. It is even better if this name resolves correctly when looked up from outside of the system--this requires the name be added to your DNS zone for the second level domain. If the Virtualmin server you are installing will be the authoritative name server for this zone, you can later use Webmin to add a record for this name to the zone.
Once the necessary questions have been answered, installation will proceed automatically. After 15-45 minutes, depending on the speed of your network connection, your system will be configured for Virtualmin Professional and ready to login to. You can then login to Virtualmin. Virtualmin runs on port 10000 and is encrypted using SSL. Thus, you can connect to your system with an address of the form:
https://example.com:10000
Or:
https://192.168.1.1:10000
The final step in the installation is to perform the configuration check, by clicking the Check Configuration button at the top of the Virtualmin System Information page.
Unlike the Automated Virtualmin Installation, to make use of this installation type, your OS does not need to be freshly installed, nor does it need to be a supported operating system. This method, however, requires significantly more knowledge on the part of the person doing the installation, and a much larger time investment to insure that all necessary configuration is performed and all Virtualmin managed services are working correctly.
If you are not extremely comfortable with your operating system, the services used in a hosting system, and performing various configuration tasks from the command line, you are advised to use the automatic installation on a Grade A supported operating system.
The partitions on your Virtualmin server should be allocated in one of the the following two ways, depending on your requirements and preference. Either partition scheme is supported by the Virtualmin Professional Installer. Other partition layouts may lead to incorrect configuration of filesystem quotas, but can be corrected after installation is completed if other partitioning schemes are preferred.
In this partition layout, you will only have one system partition plus a swap partition and /boot partition. The system partition contains /home for users, /var for logs and databases, as well as all of the normal system executable files, documentation and libraries. It is often simpler to deploy. Traditionally, "one big partition" was considered problematic from an administration standpoint, but most such issues have been resolved by modern filesystems, backup utilities, and improved hardware reliability.
swap: The swap partition should be at least twice the size of RAM on the system.
/boot: The /boot partition should be large enough to accomodate a few system kernels and initrd images. Your OS vendor probably knows best what size this should be.
/: The remainder of the disk(s) should be devoted to /. This is where all system and user data will go.
Note If you plan to use disk quotas, you should be aware of a few potential gotchas with this type of deployment. Quotas apply to all files on a given partition, regardless of the directory. In the case of mail delivery and processing, there are several very sneaky ways for this to cause failures of various types. Because of this, if you are using disk quotas, you probably want to make /home its own very large partition.
This layout spreads files across a few partitions, in order to facilitate usage some types of backup utility as well as making some types of administrative task easier (for example, installing larger disks for some partitions at a later time). Historically, multiple partitions were considered wise administrative policy, but most modern systems and backup utilities eliminate the reasons for utilizing multiple partitions.
/: This partition is used for all of the operating system files, executables, and configuration files. This partition should be at least 3.5 GB for most operating systems.
/boot: The /boot partition should be large enough to accommodate a few system kernels and initrd images. Your OS vendor probably knows best what size this should be.
swap: The swap partition should be at least twice the size of RAM on the system.
/var: The /var partition is where system logs, various changing data, and MySQL and PostgreSQL databases are stored. Depending on whether you will allow your domain users to use the database features, this partition may be between 2 GB and 10 or more GB. If users are expected to be heavy database users, you may opt to divide the remaining disk space between /var and /home.
/home: The home partition is where all of your domain users data, email, CGI scripts, logs etc. will be stored. Pretty much anything that belongs to your users, except for MySQL and PostgreSQL databases, will reside on /home. Devote the remainder of your disk to /home, as usage will likely grow rapidly if you have many users.
Install the following applications, using whatever method is appropriate for your operating system:
With the exception of Apache, standard versions of these applications are usually sufficient, as long as they are reasonably modern and have all security patches applied.
Additionally, if your system supports disk quotas, and you will be using them with Virtualmin, you need the management tools for disk quotas. Webmin also provides support for firewall management on most UNIX and Linux platforms, assuming the appropriate command line tools are available.
Note The Apache web server package provided with most operating systems requires customization to be suitable for use in a virtual hosting system, specifically it must be rebuilt with suexec_docroot set to /home. The standard OS Apache package will not work with applications in home directories, and thus is not suitable for virtual hosting usage. A custom build of Apache is not optional. This configuration cannot be done without a rebuild of the suexec binary, for security reasons.
Download and install Webmin and Usermin, from http://www.webmin.com Webmin.com. There are multiple package types of available, so choose the most appropriate one for your OS. Installation instructions can be found on the Webmin site.
Once Webmin is operational you can download and install the Virtualmin modules and theme in either RPM format (for RPM-based Linux distributions), deb format (for deb-based Linux distributions), or wbm format (for any other UNIX or Linux system), and install them using the Webmin Modules module found in Webmin:Webmin Configuration.
The modules and themes can be found in the following locations:
http://software.virtualmin.com/wbm - wbm format modules
http://software.virtualmin.com/universal - RPM format modules for all RPM-based Linux distributions
http://software.virtualmin.com/debian/dists/virtualmin-etch/main/binary-... - Debian etch (4.0) packages
http://software.virtualmin.com/debian/dists/virtualmin-universal/main/bi... - Debian lenny (5.0) module packages
http://software.virtualmin.com/ubuntu/dists/virtualmin-hardy/main/binary... - Ubuntu Hardy Heron (8.04LTS) packages
You will need to make a note of your serial number and license key, found on the http://www.virtualmin.com/serial/|Serial Numbers page at Virtualmin.com, so that you can login using the serial number as the username and the license key as the password.
http://software.virtualmin.com/gpl/wbm - wbm format modules
http://software.virtualmin.com/gpl/universal - RPM format modules
http://software.virtualmin.com/gpl/debian/dists/virtualmin-etch/main/bin... - Debian etch (4.0) packages
http://software.virtualmin.com/gpl/debian/dists/virtualmin-universal/mai... - Debian lenny (5.0) module packages
http://software.virtualmin.com/gpl/ubuntu/dists/virtualmin-hardy/main/bi... - Ubuntu Hardy Heron (8.04LTS) packages
On most platforms Apache must be built with suexec_docroot set to /home. This requires a recompile of Apache. We provide packages for the most popular operating systems in our GPL repositories at http://software.virtualmin.com/gpl/. For other systems, you will need to download a source package from your OS vendor and rebuild it with the necessary change.
On Debian and Ubuntu systems, you can instead use the apache2-suexec-custom package. This option requires no rebuild of Apache. Configuring the custom suexec package is performed in /etc/apache2/suexec/www-data, and is as simple as changing the first line from /var/www to /home.
BIND needs to be installed, and configured to accept queries from any address. Also, it is recommended that you configure the system to query the local name server by adding 127.0.0.1 to /etc/resolv.conf.
Postfix should be installed, and configured for virtual hosting. The best way to do this for the vast majority of deployments is to use a simple map file.
Edit main.cf and add the following line:
virtual_alias_maps = hash:/etc/postfix/virtual
Save it, and restart Postfix.
Procmail is necessary if you plan to make use of the spam and anti-virus filtering capabilities in Virtualmin. A reasonable starting procmailrc might be:
LOGFILE=/var/log/procmail.log TRAP=/usr/libexec/webmin/virtual-server/procmail-logger.pl VERBOSE=true :0wi VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME :0 * ?test "$VIRTUALMIN" != "" { INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN } DROPPRIVS=yes DEFAULT=$HOME/Maildir/ ORGMAIL=$HOME/Maildir/
SpamAssassin should be installed if you will be using the spam filtering features of Virtualmin.
ClamAV should be installed if you will be using the anti-virus features of Virtualmin.
Dovecot should be installed and configured for use with Maildir mail spools.
PAM or shadow authentication should be used.
ProFTPd should be installed.
PAM or shadow authentication should be used.
If you plan to use MySQL, or any of the Install Scripts in Virtualmin Professional that rely on MySQL, it should be installed, and accessible to localhost. The root account should have a password set. Once Webmin is installed, you will need to configure the MySQL module to know the root MySQL password.
Note - Virtualmin does not require MySQL, and no Virtualmin-related user data is stored in MySQL. If you've read setup guides on the web for virtual mail hosting that require MySQL, we strongly recommend you ignore them. This is a very common source of confusion for new users, and there's simply no reason to introduce the complexity of this kind of deployment.
If you plan to use PostgreSQL or any of the Install Scripts in Virtualmin Professional that rely on PostgreSQL, it should be installed, and accessible to localhost.
If users will be sending email through your server, you will need to configure saslauthd. This requires interaction with your MTA (probably Postfix), and it should be configured to use PAM or shadow authentication.
Most installation problems are related to network connectivity, package management, or attempting to run the install script on an unsupported operating system or architecture.
Check the virtualmin-install.log. It is likely your package manager is configured to use a local CD ROM device for packages, and the disk is unavailable. Another possibility is that connections to remote package one or more repositories are timing out, and causing the system to install packages very slowly. Finally, on systems that have up2date (RHEL and CentOS versions 3 and 4), you must run up2date once before attempting to install Virtualmin, as it has an interactive configuration step that must be performed manually.
If your package manager is configured to use non-OS package repositories, of if you have installed alternative versions of packages before installation, conflicts are likely to occur during installation. If you plan to use non-OS standard packages (other than those provided by Virtualmin repositories), they should be installed after installation of Virtualmin, and you should add an exclude directive to the yum or apt-get configuration in order to insure similar conflicts do not happen in the future.
Also note that if you are using non-OS standard packages, you may need to configure the relevant Webmin module to make it aware of the location of the configuration files.
Virtualmin Professional customers receive free installation service if the automated installation process fails to work correctly on any Grade A or B supported operating system listed on the OS Support page. Open a ticket in the issue tracker with a description of your problem and the relevant portion of the virtualmin-installation.log, and we will try to walk you through to a solution, or log into your system and complete the installation free of charge.
Virtualmin GPL users can make use of the forums to ask for assistance with any problems that arise during installation.
There are many levels of "uninstalling" Virtualmin, but the most common is simply that you don't want the Virtualmin GUI or any of its plugins installed. The simplest way to accomplish this, assuming you used the automated installation process (install.sh), is to re-run install.sh with the - -uninstall flag:
sh install.sh --uninstall
This is a rather haphazard uninstall routine, but it will remove pretty much everything Virtualmin-specific while leaving behind the services that it manages (like Apache and BIND).
Note This will remove Virtualmin related meta-data. This should never be used to allow you to "reinstall" Virtualmin on a production system. If you have Virtualmin running on a production system with accounts, you should not try to install Virtualmin again. If there are any problems with your running installation, let us know and we'll help you fix the problems. However, it can be used to cleanup after a prior failed install--perhaps after we've fixed a bug or something in the installer and you'd like to run it again but run into conflicts (perhaps virtualmin-release is in the way).
If you no longer need the features of Virtualmin Professional, but wish to continue to use Virtualmin on your system, you can downgrade quite easily.
In its simplest form, you merely install the Virtualmin GPL module over the Virtualmin Professional module. How that is done depends on your OS and how Virtualmin was initially installed.
On RPM-based distributions, like CentOS or RHEL, download the latest Virtualmin GPL RPM from http://software.virtualmin.com/gpl/universal/
Then install it using RPM with the --oldpackage option. For example:
rpm -Uvh --oldpackage wbm-virtual-server-3.64.gpl-2.noarch.rpm
If you were also using our yum repository (which is true if you used install.sh to install Virtualmin), you will need to switch the the GPL repository. To do that, install the latest version of the virtualmin-release package for your operating system and version. For example, for CentOS 5, you could run the following command:
rpm -Uvh --oldpackage http://software.virtualmin.com/gpl/centos/5/i386/virtualmin-release-latest.noarch.rpm
On Debian and Ubuntu systems update /etc/apt/sources.list to point to the GPL version of the Virtualmin repository for your OS (merely insert gpl into the path just after the domain name).
Once apt has been reconfigured, you can use apt-get to install the GPL version of the webmin-virtual-server module.
If you didn't use packages, and instead used the .wbm format of module, download the latest version of the virtual-server module from http://software.virtualmin.com/gpl/wbm and install it using the Webmin modules module, found in the Webmin menu under Webmin:Webmin Configuration:Webmin Modules.
Once you've downgraded the virtual-server module to the GPL version, you can change the /etc/virtualmin-license file to :
SerialNumber=GPL LicenseKey=GPL
Then remove the /etc/webmin/virtual-server/licence.pl , sendratings.pl and fcgiclear.pl cron jobs. You can use the Webmin System:Schedule Cron Jobs module to locate and delete that job, if you like.
In a standard install of Virtualmin 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.
Alternately, you can install the same packages from the command line as root. On CentOS or Redhat Enterprise, the command to use will be like :
yum install wbm-virtual-server bind perl python
On Debian or Ubuntu, you could use :
apt-get install webmin-virtual-server bind perl python
When upgrading Virtualmin Professional licenses, it is never necessary to re-install or perform any changes to your license on your system. Once a license upgrade has been applied on our server (usually immediately after confirmation of your purchase, but if there is any delay, you can open an issue identifying the serial number and your order number, and we will manually process it), you can click the "Re-check Virtualmin License" in the System Information page to immediately update the license details on your system.
(Make some Reseller and Mailbox/FTP User-specific docs)
This tutorial covers the various kinds of accounts available in Virtualmin.
Master Administrator -- this is the root user of the system. The root user has rights to manage any aspect of the server.
Reseller -- this user is created by the Master Administrator. They have rights to create Virtual Servers accounts for other users.
Virtual Server Owner -- a Virtual Server owner is the administrative user of a Virtual Server and any of it's Sub-Servers and Aliases. This user is created by either the Master Administrator or a Reseller.
Mail/FTP Users -- these users belong to a particular Virtual Server, and are setup to have Email access, FTP access, or both. These users are generally created by the Virtual Server Owner, though they can also be created by Resellers and the Master Administrator.
This tutorial covers how to add an SSL certificate to a Virtual server.
You will need an IP address dedicated to this purpose -- you can obtain IP addresses from the ISP hosting your server.
This tutorial assumes you have first logged into Virtualmin.
Choose the domain for which you would like to add the SSL Certificate. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Virtual Server.
Click Configurable Settings.
Click the radio button next to Virtual interface labeled Create now with IP.
Enter the IP address you obtained for this SSL certificate in the field next to Create now with IP.
Click Enabled features.
Click Save Virtual Server.
At this point, you have a self-signed SSL Certificate. That means your communications are secured, but since this certificate wasn't generated by a certificate authority, your users will receive a security warning every time they access the site.
It's recommended that you get a commercial certificate -- the following steps detail how to obtain and install one.
Click Server Configuration.
Click Manage SSL Certificate.
Click Signing Request.
Enter the domain name you wish to use for SSL in the Server Name field.
Enter your email address in the Email Address field.
Enter your business name or organization in the Organisation field.
Click Generate CSR Now
This next step you have to do on your own. Take the resulting "CSR", and take it to one of the many companies able to create SSL certificates. Have them use the CSR you made to generate your SSL Certificate.
Click New Certificate.
Paste in the contents of the SSL Certificate you received into the Signed SSL certificate field.
Keep the Matching private key provided by Virtualmin.
Click Install Now.
You should now be able to access your site securely by using https://example.com, where example.com is the domain name you used while generating your SSL Certificate.
This tutorial will cover how to backup a single Virtual Server.
It assumes you have first logged into Virtualmin.
Click Backup and Restore.
Click Backup Virtual Servers.
In Backup destination, select Download to browser
Click Backup Now.
A backup of your Virtual Server will begin, and will download to your PC.
This tutorial covers how to change a Mailbox or FTP user's from within Virtualmin.
It assumes you have first logged into Virtualmin.
Choose the domain for which you would like to change the user's password. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Email and FTP User's.
Click the name of the user who's password you would like to change.
Next to Password, click the Set to radio button.
In the textbox next to Set to, enter the new password.
Click Save.
This tutorial covers how to change a Virtual Server Owner's password from within Virtualmin.
It assumes you have first logged into Virtualmin.
Choose the domain for which you would like to change the password. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Virtual Server.
Click Configurable Settings
Next to Administration password, click the radio button marked Set to.
In the text area next to Set to, enter the new password.
Click Save Virtual Server.
This tutorial covers how to change your password from within Usermin.
It assumes you have logged into Usermin Webmail.
Click the Change Password link, towards the bottom on the left.
Enter your current password in the Current password field.
Enter your new password in the New Password field.
Enter your new password a second time in the New Password again field.
Click Change now.
This tutorial will cover how to setup a catch-all email account. Once finished, it will be the default destination for any email arriving at your domain, unless overridden by another email account or alias.
It assumes you have logged into Virtualmin as the root user.
You can make any email account the default (or catch-all) account for a given domain.
Choose the domain for which you would like to setup a catch-all address. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Email and FTP Users.
Click the name of the email account you would like to make a catch-all account.
Click Email Settings.
In Additional email addresses, type @example.com, where example.com is the name of your domain name.
Click Save, and this account will now be the default email address for this domain.
This tutorial covers how you can create a MySQL or PostgreSQL database.
It assumes you have first logged into Virtualmin.
Choose the domain for which you would like to add the database. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Databases.
Click Create a new database.
Choose a name for your database, and enter it in the Database name field.
In Database server type, select either MySQL or PostgreSQL. If unsure, use MySQL.
Click Create.
This tutorial will cover how to create a sub-server, allowing for a second domain to be setup within a given Virtual Server account.
It assumes you have first logged into Virtualmin.
Choose the domain for which you would like to add the sub-server. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Create Virtual Server.
Click Sub-server.
Enter the Domain Name and Description for the Sub-server.
Click Create Server.
This tutorial covers how to create an alias for an existing Virtual Server.
If you have a Virtual Server such as example.com, setting up an alias would allow you to have example.net point to the same website, and share the same email addresses.
It assumes you have first logged into Virtualmin.
First, choose the domain you for which you would like to add the Virtual Server Alias. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Create Virtual Server.
Click Alias of example.com, where example.com is the domain for which you are setting up the alias.
Enter the domain name for the alias in the Domain name field. This will be something like example.com.
Enter a description for the alias in the Description field.
Click Create Server.
This tutorial will cover how to create an FTP account for a Virtual Server.
It assumes you have first logged into Virtualmin.
Choose the domain you would like to add the FTP account to. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Email and FTP Users.
Click Add a website FTP access user (on the far-right).
In the Email Address, enter the name for the new FTP account.
Enter the FTP user's name in the Real Name field.
You can enter a password in the Password field if you wish to override Virtualmin's random password that it puts there by default.
Click Create.
This tutorial will cover how to create an email auto-responder for a user within Virtualmin.
An email auto-responder is an automated reply that will be sent to anyone sending an email to the account.
It assumes you have first logged into Virtualmin.
Choose the domain you would like to add the email account to. You can do that by selecting the domain name from the drop-down box on the top-left.
Choose Edit Mail and FTP Users.
Click the name of the account you would like to add the auto-responder to.
Click Mail forwarding settings to view the auto-responder text area.
Click the checkbox next to Send automatic reply
In the text area beneath Send automatic reply, you can now enter the text that will be included in the auto-responder.
Click Save.
The above auto-responder will be used until you un-check "Send automatic reply".
This tutorial will cover how to create an email auto-responder for your email account within Usermin.
An email auto-responder is an automated reply that will be sent to anyone sending an email to your address.
It assumes you have logged into Usermin Webmail.
Click the Automatic Reply link, towards the bottom on the left.
Click the checkbox next to Automatic Response Enabled
In the text area next to Reply Message, you can now enter the text that will be included in the auto-responder.
Click Save.
The above auto-responder will be used until you un-check "Send automatic reply".
This tutorial will cover how to create an email account that can be accessed via POP, IMAP, or web-mail.
It assumes you have first logged into Virtualmin.
Choose the domain you would like to add the email account to. You can do that by selecting the domain name from the drop-down box on the top-left.
Click Edit Email and FTP Users.
Click Add a user to this server.
You can now enter the email address, full name, and password to use for this email account.
Click Create, and Virtualmin will add the email account to your server.
This tutorial will cover how to create an email filter from within Usermin.
Email filters allow you to sort incoming emails based on criteria such as who sent them and what the subject is.
It assumes you have logged into Usermin Webmail.
Click the Email Filters link, towards the bottom on the left.
Click Add a new email filter.
Under Condition for filter, click the radio button next to Based on header.
Click the dropdown next to Header, and change it from From to Subject.
In the textbox at the end of that line, enter the text test email filter.
Under Action if condition is matched, click the radio button next to Save to Folder.
Click the dropdown box next to Save to Folder, and change it from Inbox to Trash.
Now, any time you receive an email message with a subject of test email filter, it will end up in the Trash folder!
Go ahead and send yourself an email with the subject test email filter in order to test the filter.