Installing Maia Mailguard On Debian Lenny (Virtual Users/Domains With Postfix/MySQL)

Version 1.0
Author: Falko Timme
Follow me on Twitter
Last edited 07/05/2010

This guide explains how to install Maia Mailguard, a spam and virus management system, on a Debian Lenny mailserver. Maia Mailguard is a web-based interface and management system based on the popular amavisd-new email scanner and SpamAssassin. Written in Perl and PHP, Maia Mailguard gives end-users control over how their mail is processed by virus scanners and spam filters, while giving mail administrators the power to configure site-wide defaults and limits.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

This tutorial is based on Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Debian Lenny), so you should have this set up already. If your mail setup is different, this tutorial might not work out for you, or you might have to make some adjustments.

My server has the hostname and the IP address I will install Maia's web interface in Debian's default Apache document root, /var/www, and I will use to access the web interface. You will have to adjust this if your document root and your domain differ.


2 Downloading Maia Mailguard

Maia Mailguard can be downloaded from SVN only, so we have to install Subversion first:

aptitude install subversion

I want to download the sources to /usr/src/maia:

mkdir /usr/src/maia
cd /usr/src/maia

Open a browser and go to to find out what the latest revision is - in my case it was 1495. Then start the download as follows:

svn -r 1495 checkout

(Make sure you replace 1495 with the latest revision.)


3 Creating A Database For Maia Mailguard

Next log into MySQL...

mysql -u root -p

... and create a database called maia:


Leave the MySQL shell afterwards:


Import Maia's SQL dump into the empty maia database:

cd /usr/src/maia/1.0/
mysql -u root -p maia < maia-mysql.sql

Then log into MySQL again...

mysql -u root -p maia

... and create a MySQL user called amavis:




(You can replace passwd with a password of your choice, but keep in mind that you have to use that password later on in the Maia configuration!)

Next make sure you have a big enough value for max_allowed_packet in your /etc/mysql/my.cnf (in the [mysqld] section). This setting determines the size of the largest mail item you'll be able to process with Maia, so make sure to set this value large enough to accommodate your needs.

vi /etc/mysql/my.cnf

max_allowed_packet      = 16M

Restart MySQL if you have changed the value of max_allowed_packet:

/etc/init.d/mysql restart


4 Installing Maia's Scripts And Templates

The home directory of the amavis user on Debian Lenny is /var/lib/amavis, and that's where we create a subdirectory called maia. In that subdirectory we will place Maia's scripts and templates:

mkdir /var/lib/amavis/maia
mkdir /var/lib/amavis/maia/scripts
mkdir /var/lib/amavis/maia/templates

cp -pfr /usr/src/maia/1.0/scripts/* /var/lib/amavis/maia/scripts
cp -pfr /usr/src/maia/1.0/templates/* /var/lib/amavis/maia/templates

chown -R amavis /var/lib/amavis/maia
chgrp -R amavis /var/lib/amavis/maia
chmod 640 /var/lib/amavis/maia/templates/*.tpl
chmod 750 /var/lib/amavis/maia/scripts/*.pl


5 Configuring Maia

Next we rename /usr/src/maia/1.0/maia.conf.dist to /etc/maia.conf:

cp /usr/src/maia/1.0/maia.conf.dist /etc/maia.conf
chown amavis /etc/maia.conf
chgrp amavis /etc/maia.conf
chmod 640 /etc/maia.conf

Open /etc/maia.conf and adjust the following settings:

vi /etc/maia.conf

# Configure your Maia database DSN here
$dsn = "DBI:mysql:maia:localhost:3306";
# Your Maia database user's login name
$username = "amavis";
# Your Maia database user's password
$password = "passwd";
# The directory where Maia's Perl scripts can be found.
$script_dir = "/var/lib/amavis/maia/scripts";
# Location to write the lock/PID files (must be writeable by your
# amavis user)
$pid_dir = "/var/lib/amavis/";
# Base URL to Maia's PHP scripts
$base_url = "";
# Template directory
$template_dir = "/var/lib/amavis/maia/templates/";

Make sure you fill in the correct password for the MySQL user amavis in the $password line. Also fill in the correct URL in the $base_url line.

Share this page:

6 Comment(s)

Add comment


From: VinS at: 2010-07-16 08:00:29

You can use
aptitude install  libdbd-pg-perl libdata-uuid-perl
to install  Data::UUID & DBD::Pg


From: David Morton at: 2010-07-10 13:22:11

As a developer for Maia Mailguard, I appreciate any the effort put into making a tutorial like this, however, I'm a little confused about the lack of communication with our community shown at the end of this tutorial.

We have an active community on the users mailing list, which you can join here:

It is unfortunate that the author happened to check out the 1.0 branch when he did, as it was one of the strangest states I've ever left that tree in.  I have since committed fixes for the items listed at the end of this tutorial.   A quick note on the mailing list could have had that fixed sooner and allowed the author to skip the work of documenting it!

 @Boudewijn Ector:  I develop Maia on Ubuntu, so it runs quite well on Debian-like systems.  If you have problems, please join the mailing list!   Having said that, we are in the process of packaging it up into an Ubuntu set of packages, so it will get easier when we finish that up. :)

 Lastly, I would like to point out that this tutorial uses screenshots from the "Ocean Blue" theme, which is the theme that has received less love.  The "Desert Sand" theme has a much more polished look to it, and is much preferred.


From: Anonymous at: 2010-07-12 12:42:28

If your developing maya for Ubuntu, which is nice, but wouldn't it not be nicer to port it to debian itself and let the ubuntu developers adapt it.


From: Boudewijn Ector at: 2010-07-09 23:13:37

Dear Author,

Well done! Maia is great, and debian is great!

Too bad there's no such thing as a debian package. Although I've been using FreeBSD together with Maia for years, I've been trying for some time to get Maia to work on Debian.


A minor comment (I might make more during the implementation of maia on my debian system): 

One might try :

svn checkout

 Instead of including a version number: this will automatically get the newest version in SVN. Minor note: watch out, this might be an unstable version!

From: Keith at: 2010-07-10 17:04:36

The developers of Maia have fixed the PHP errors described in this article so a checkout of the latest 1.x branch will not need to have these corrections applied.

From: Joshua at: 2010-08-11 19:35:01

I keep seeing the Maia Mailguard server (literally, it's in the room down the hall) and I mean to try it for my own personal use, but I haven't really got around to it. We use it at an ISP level and it works extremely well. This guide should hopefully help me get off my rear and install it on some more servers.