Installing Maia Mailguard On Debian Lenny (Virtual Users/Domains With Postfix/MySQL)
Author: Falko Timme
Follow me on Twitter
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 server1.example.com and the IP address 192.168.0.100. I will install Maia's web interface in Debian's default Apache document root, /var/www, and I will use www.example.com 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:
Open a browser and go to https://www.maiamailguard.com/svn/branches/1.0 to find out what the latest revision is - in my case it was 1495. Then start the download as follows:
svn -r 1495 checkout https://www.maiamailguard.com/svn/branches/1.0
(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:
CREATE DATABASE maia;
Leave the MySQL shell afterwards:
Import Maia's SQL dump into the empty maia database:
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:
GRANT CREATE, DROP, ALTER, SELECT, INSERT, UPDATE, DELETE ON maia.* TO [email protected] IDENTIFIED BY 'passwd';
(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.
[...] [mysqld] [...] max_allowed_packet = 16M [...]
Restart MySQL if you have changed the value of max_allowed_packet:
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:
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:
[...] # 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 = "http://example.com/"; # 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.