Web-Cyradm Install
Web-Cyradm provides web based admin of accounts, quotas and domains, along with domain level admins. Installation is not difficult...as long as you use the right version and settings.
Preliminaries
You'll need to come up with 4 passwords for this section. The first 3 are entirely internal. Once configured, the passwords should be tucked away and not needed, except in an emergency debug of some kind.- MySQL "root" user - Don't run MySQL without a root user password. The installer will ask for it. Note that this is a database user, internal to MySQL and having nothing to do with login users or mail users.
- MySQL "mail" user - Another MySQL user, for accessing the soon to be created mail database.
- Web-Cyradm "cyrus" user - When we configured /etc/cyrus.conf we designated "cyrus" as an admin user. Web-Cyradm will need this user, and we'll set the password when we configure Web-Cyradm. This user is internal to the Web-Cyradm app.
- Web-Cyradm "admin" user - This is the initial admin user once the website is up and running.
Apache + PHP
Web-Cyradm is a PHP app that uses a MySQL db. Let's start with Apache & PHP.- Install apache2 with php
sudo apt-get install apache2 php5 libapache2-mod-php5 php5-cli php5-mysql
- PEAR & imap support - Used by Web-Cyradm & webmail apps
sudo apt-get install php-db php5-imap
- Open Port 80
sudo ufw allow http
- Test Apache+PHP
Browse toecho "
<?php
print_r (phpinfo());
?>" >/tmp/phpinfo.php
sudo mv /tmp/phpinfo.php /var/www
sudo /etc/init.d/apache2 restarthttp://mailserver.example.domain/phpinfo.php - Clean up
sudo rm /var/www/phpinfo.php
MySQL with PAM & Postfix Config
- Install MySQL Server - The installer will ask for that MySQL root password.
sudo apt-get install mysql-server
- Relocate MySQL Socket to Postfix Chroot - Just like we tweaked the saslauthd socket, we need the same for Postfix to access MySQL. Stop MySQL first, as it gets confused when these files change underneath it.
sudo /etc/init.d/mysql stop
and prepend all of the references to
sudo vi /etc/mysql/my.cnf/var/run/mysqldto read/var/spool/postfix/var/run/mysqld. In the current config that affects lines 21, 28, 43 & 44. Lines 19-44 should look like[client]
port = 3306
socket = /var/spool/postfix/var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/spool/postfix/var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#
user = mysql
pid-file = /var/spool/postfix/var/run/mysqld/mysqld.pid
socket = /var/spool/postfix/var/run/mysqld/mysqld.sock - Update
/etc/mysql/debian.cnfsudo vi /etc/mysql/debian.cnf
and change the "socket" lines to the new location, e.g.,# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 8JCDXsC4cUmDn8Pm
socket = /var/spool/postfix/var/run/mysqld/mysqld.sock
[mysql_upgrade]
user = debian-sys-maint
password = 8JCDXsC4cUmDn8Pm
socket = /var/spool/postfix/var/run/mysqld/mysqld.sock
basedir = /usr - Update apparmor
sudo vi /etc/apparmor.d/usr.sbin.mysqld
and make the appropriate mods to the /var/run/mysqld lines at the bottom:/var/spool/postfix/var/run/mysqld/mysqld.pid w,
Then reload the apparmor profile
/var/spool/postfix/var/run/mysqld/mysqld.sock w,
}sudo /etc/init.d/apparmor restart
- Start MySQL and Fix Sockets - Remember that
/etc/init.d/fix-postfix-chrootinit script we installed? MySQL wasn't running when we ran it, so after MySQL starts, we need to run it again.sudo /etc/init.d/mysql restart
should give you
sudo /etc/init.d/fix-postfix-chroot start
sudo ls -l /var/run/saslauthd /var/run/mysqldlrwxrwxrwx 1 root root 33 2008-09-29 12:55 /var/run/mysqld -> /var/spool/postfix/var/run/mysqld
lrwxrwxrwx 1 root root 36 2008-09-29 12:55 /var/run/saslauthd -> /var/spool/postfix/var/run/saslauthd - Configure PAM for mail DB - /etc/pam.d/common-mysqlmail is a new PAM file, to include in other service files.
sudo apt-get install libpam-mysql
Then copy the following into this new file, updating the mysql mail user password from changeme:
sudo vi /etc/pam.d/common-mysqlmail#
# MySQL Web-Cyradm mail database authorization
#
auth sufficient pam_mysql.so user=mail passwd=changeme host=localhost db=mail table=accountuser usercolumn=username passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg logusercolumn=user loghostcolumn=host logpidcolumn=pid logtimecolumn=time
account required pam_mysql.so user=mail passwd=changeme host=localhost db=mail table=accountuser usercolumn=username passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg logusercolumn=user loghostcolumn=host logpidcolumn=pid logtimecolumn=time - Update PAM services - To use the MySQL mail auth
sudo vi /etc/pam.d/imap /etc/pam.d/pop /etc/pam.d/sieve
In each of these files, comment out the@include common-authand@include common-accountlines. Add a@include common-mysqlmailbelow them. The last 3 lines should read#@include common-auth
Add those same 3 lines to a new PAM file,
#@include common-account
@include common-mysqlmail/etc/pam.d/smtpsudo vi /etc/pam.d/smtp
- Configure Postfix for mail DB
sudo apt-get install postfix-mysql
- Update main.cf
sudo vi /etc/postfix/main.cf
and at the bottom add the lines
The setting for virtual_mailbox_mapsbelow is critical to avoid getting tagged as a spammer due to backscatter spam.# Mysql glue
virtual_alias_maps =
mysql:/etc/postfix/mysql-virtual.cf
virtual_mailbox_maps =
mysql:/etc/postfix/mysql-virtual.cf
virtual_mailbox_domains =
mysql:/etc/postfix/mysql-mydestination.cf
sender_canonical_maps =
mysql:/etc/postfix/mysql-canonical.cf
The following 3 MySQL scripts are from http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/postfix-config.html here. - Create
/etc/postfix/mysql-virtual.cfsudo vi /etc/postfix/mysql-virtual.cf
...adding the following and setting "changeme" to the MySQL mail user password:#
# mysql config file for alias lookups on postfix
# comments are ok.
#
# the user name and password to log into the mysql server
hosts = localhost
user = mail
password = changeme
# the database name on the servers
dbname = mail
# the table name
table = virtual
#
select_field = dest
where_field = alias
additional_conditions = and status = '1' - Create
/etc/postfix/mysql-mydestination.cfsudo vi /etc/postfix/mysql-mydestination.cf
...adding the following and setting "changeme" to the MySQL mail user password:# mysql config file for local domain (like sendmail's sendmail.cw) lookups on postfix
# comments are ok.
#
# the user name and password to log into the mysql server
hosts = localhost
user = mail
password = changeme
# the database name on the servers
dbname = mail
# the table name
table = domain
#
select_field = domain_name
where_field = domain_name - Create
/etc/postfix/mysql-canonical.cfsudo vi /etc/postfix/mysql-canonical.cf
...adding the following and setting "changeme" to the MySQL mail user password:# mysql config file for canonical lookups on postfix
# comments are ok.
#
# the user name and password to log into the mysql server
hosts = localhost
user = mail
password = changeme
# the database name on the servers
dbname = mail
# the table name
table = virtual
#
select_field = alias
where_field = username
# Return the first match only
additional_conditions = and status = '1' limit 1 - Restart postfix - ...and make sure it started clean.
sudo /etc/init.d/postfix restart
tail /var/log/mail.log
Update Cyrus & Saslauthd configs
As presently configured, Cyrys & Saslauthd expect to work with simple usernames, not type addresses. For them to work together, and with the PAM to mail db link, the following is needed:- /etc/default/saslauthd - Add a -r flag to the last line, so that it reads:
OPTIONS="-r -c -m /var/spool/postfix/var/run/saslauthd"
- /etc/imapd.conf - Scroll down to the
virtdomainssetting and uncomment the line so it readsvirtdomains: userid
- Restart cyrus & saslauthd
sudo /etc/init.d/saslauthd restart
sudo /etc/init.d/cyrus2.2 restart
Web-Cyradm
Finally, install and config the webapp. You will need the 0.5.5 version as of this writing. Only this (and perhaps upcoming) versions work correctly with Cyrus's virtdomain feature. Get it from the source, or there's a copy here: Web-Cyradm 0.5.5 tarball- Place Web-Cyradm
wget http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz
cd /var/www
sudo tar xzf ~/web-cyradm-svn-0.5.5.tar.gz - Put Passwords in SQL Init Scripts
cd web-cyradm-svn-0.5.5/
sudo vi scripts/insertuser_mysql.sql
sudo vi scripts/create_mysql.sql -
insertuser_mysql.sql, line 2 - change the 'secret' text on line 2 to the password for the MySQL mail db user. This line creates that user with that password. -
create_mysql.sql, line 135 - change 'test' at line 135 to the password for the Web-Cyradm admin account (not the cyrus account, btw.) This will be your first login id for Web-Cyradm when you browse to it, i.e., admin/adminpassword. This line creates that user with that password. -
create_mysql.sql, line 137 - change 'secret' to the password for the cyrus user in the Web-Cyradm 'mail' database. This password will be used in the Web-Cyradm config (covered later.) This line creates that user with that password. - Run SQL init scripts - You'll need your MySQL root password for the first command, and your MySQL mail db password for the second.
mysql -u root -p <scripts/insertuser_mysql.sql
mysql mail -u mail -p <scripts/create_mysql.sql - Web-Cyradm App Config
cd /var/www/web-cyradm-svn-0.5.5/config
and edit the following
sudo cp conf.php.dist conf.php
sudo vi conf.php -
conf.php, line 19 - replacesecretwith the cyrus password (seecreate_mysql.sql, line 137). -
conf.php, line 37 - replacesecretwith the mysql mail password (seeinsertuser_mysql.sql, line 2). -
conf.php, line 89, set$DOMAIN_AS_PREFIX = 1 -
conf.php, line 100, set$FQUN = 1
Mailadmin Site Config
Almost ready to browse. We just need to tell Apache some things about the site and turn it on.- Get the Apache mailadmin config file File - ...install and enable
sudo wget http://morison.biz/technotes/file-fetch/7-mailadmin.conf
sudo cp 7-mailadmin.conf /etc/apache2/sites-available/mailadmin
sudo a2ensite mailadmin
sudo /etc/init.d/apache2 restart - Browse and Login - with the admin password (from
create_mysql.sql, line 135) to http://mailserver.example.domain/mailadmin
Create a Domain, Email Account & Test
If you've successfully browsed and logged in to your mailadmin site you should be looking at:
Web-Cyradm Browse Domains Screen
- Add a Domain - Click on the "Add New Domain" link. In this form be sure to update "Domainname", "Maximum Accounts" (or your account limit for the domain will be zero) and "Standard Folders". "Standard Folders is important, to create the default folders most mail clients expect. This field should read
Drafts,Sent,Junk,Trash
Set the "Default Quota" up or down, as you require and submit the form. Your form should look something like (modified fields circled in red)
Web-Cyradm Add New Domain Screen
- Create an Account - from the Browse Domains screen, click "accounts" in the domain list.
- Test - Tail the mail log, send email to/from the account, retrieve it via imap and/or pop, and reply (with your favorite mail client.) Try with and without TLS.
tail -f /var/log/mail.log
you should see something likeSep 29 13:03:07 mailserver postfix/smtpd[5639]: connect from unknown[192.168.66.194]
Sep 29 13:03:07 mailserver postfix/smtpd[5639]: 8BB0B245F2: client=unknown[192.168.66.194], sasl_method=PLAIN, sasl_username=test@mailserver.morison.org
Sep 29 13:03:07 mailserver postfix/cleanup[5645]: 8BB0B245F2: message-id=<48E1345C.7020804@mailserver.morison.org>
Sep 29 13:03:07 mailserver postfix/qmgr[4654]: 8BB0B245F2: from=<test@mailserver.morison.org>, size=564, nrcpt=1 (queue active)
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: accepted connection
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: lmtp connection preauth'd as postman
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: WARNING: sieve script /var/spool/cyrus/sieve/domain/m/mailserver.morison.org/t/test/defaultbc doesn't exist: No such file or directory
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_check: <48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 0
Sep 29 13:03:07 mailserver postfix/smtpd[5639]: disconnect from unknown[192.168.66.194]
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_check: <48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 0
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: mystore: starting txn 2147483660
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: mystore: committing txn 2147483660
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_mark: <48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 1222718587 2
Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: Delivered: <48E1345C.7020804@mailserver.morison.org> to mailbox: mailserver.morison.org!user.test
Sep 29 13:03:07 mailserver postfix/lmtp[5649]: 8BB0B245F2: to=<test@mailserver.morison.org>, relay=mailserver.morison.org[/var/run/cyrus/socket/lmtp], delay=0.2, delays=0.09/0/0.01/0.1, dsn=2.1.5, status=sent (250 2.1.5 Ok)
Sep 29 13:03:07 mailserver postfix/qmgr[4654]: 8BB0B245F2: removed
You're Up and Running!
Next up, Anti-Spam & Anti-Virus InstallAttached files
| Web-Cyradm 0.5.5 tarball 539,053 bytes, 86 downloads Posted by Rod on Sep. 29 2008 Zoom | |
| Apache mailadmin config file 1,042 bytes, 363 downloads Posted by Rod on Sep. 29 2008 Zoom | |
| IMAP-Error.jpg 82,175 bytes, 71 downloads Posted by Tithtola on Sep. 5 2009 Zoom |
Your comments
I had to manually add a link "sudo ln -s /var/spool/postfix/var/run/mysqld /var/run/mysqld" to make web-cyradm run
Hi,
I cannot create account. The problem is error with imap login. Can you solve it for me? please...
Thanks
IMAP-Error.jpg
Related links
| AppArmor - Wikipedia, the free encyclopedia - (47 clicks) Posted by Rod, on Sep. 29 2008 | |
| AppArmor - Wikipedia, the free encyclopedia - (120 clicks) Posted by Rod, on Sep. 29 2008 | |
| AppArmor - Wikipedia, the free encyclopedia - (29 clicks) Posted by Rod, on Sep. 29 2008 |


