/[gentoo]/xml/htdocs/doc/en/virt-mail-howto.xml
Gentoo

Diff of /xml/htdocs/doc/en/virt-mail-howto.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 Revision 1.21
1<?xml version = '1.0' encoding = 'UTF-8'?> 1<?xml version = '1.0' encoding = 'UTF-8'?>
2<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?> 2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/virt-mail-howto.xml,v 1.21 2003/12/07 18:21:26 pylon Exp $ -->
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
3<guide link=" /doc/en/virt-mail-howto.xml" > 5<guide link=" /doc/en/virt-mail-howto.xml" >
4<title>Virtual Mailhosting System Guide</title> 6<title>Virtual Mailhosting System Guide</title>
5<author title="Author" > 7<author title="Author" >
6<mail link="antifa@gentoo.org" >Ken Nowack</mail> 8<mail link="antifa@gentoo.org" >Ken Nowack</mail>
7</author> 9</author>
8<author title="Author" > 10<author title="Author" >
9<mail link="ezra@revoltltd.org" >Ezra Gorman</mail> 11<mail link="ezra@revoltltd.org" >Ezra Gorman</mail>
10</author> 12</author>
11<abstract>This document details how to create a virtual mailhosting system based upon postfix, mysql, courier-imap, and cyrus-sasl. </abstract> 13<abstract>This document details how to create a virtual mailhosting system based upon postfix, mysql, courier-imap, and cyrus-sasl. </abstract>
12<version>1.0.1</version> 14<version>1.0.6</version>
13<date>7 Aug 2003</date> 15<date>December 7, 2003</date>
14<!-- 16<!--
15 17
16Contents 18Contents
17 19
18I. Introduction 20I. Introduction
38<p>A virtual mail system needs to be able to handle email for numerous domains with multiple users over a variety of interfaces. This presents some issues that must be dealt with. For instance, what if you have two users on different domains that want the same user name? If you are providing imap access and smtp-auth, how do combine the various authentication daemons into a single system? How do you provide security for the numerous components that comprise the system? How do you manage it all?</p> 40<p>A virtual mail system needs to be able to handle email for numerous domains with multiple users over a variety of interfaces. This presents some issues that must be dealt with. For instance, what if you have two users on different domains that want the same user name? If you are providing imap access and smtp-auth, how do combine the various authentication daemons into a single system? How do you provide security for the numerous components that comprise the system? How do you manage it all?</p>
39<p>This howto will show you how to set up with a mail system capable of handling mail for as many domains as your hardware can handle, supports virtual mail users that don't require shell accounts, has domain specific user names, can authenticate web, imap, smtp, and pop3 clients against a single database, utilizes ssl for transport layer security, has a web interface, can handle mailing lists for any domain on the machine, and is controlled by a nice, central and easy mysql database. </p> 41<p>This howto will show you how to set up with a mail system capable of handling mail for as many domains as your hardware can handle, supports virtual mail users that don't require shell accounts, has domain specific user names, can authenticate web, imap, smtp, and pop3 clients against a single database, utilizes ssl for transport layer security, has a web interface, can handle mailing lists for any domain on the machine, and is controlled by a nice, central and easy mysql database. </p>
40<p>There are quite a variety of ways to go about setting up a virtual mailhosting system. With so may options, another may be the best choice for your specific needs. Consider investigating <uri>http://www.qmail.org/</uri> and <uri>http://www.exim.org/</uri> to explore your options. </p> 42<p>There are quite a variety of ways to go about setting up a virtual mailhosting system. With so may options, another may be the best choice for your specific needs. Consider investigating <uri>http://www.qmail.org/</uri> and <uri>http://www.exim.org/</uri> to explore your options. </p>
41<p>The following packages are used in this setup: 43<p>The following packages are used in this setup:
42 44
43 apache, courier-imap, pam_mysql, postfix, mod_php, mod_ssl, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and mailman.</p> 45 apache, courier-imap, pam_mysql, postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and mailman.</p>
44<p>Make sure to turn on the following USE variables in <path>/etc/make.conf</path> before compiling the packages: <c>USE=&quot;mysql imap libwww maildir sasl ssl&quot;</c>. Otherwise you will most likely have to recompile things to get the support you need for all the protocols. Further, it's a good idea to turn off any other mail and network variables, like ipv6.</p> 46<p>Make sure to turn on the following USE variables in <path>/etc/make.conf</path> before compiling the packages: <c>USE=&quot;mysql imap libwww maildir sasl ssl&quot;</c>. Otherwise you will most likely have to recompile things to get the support you need for all the protocols. Further, it's a good idea to turn off any other mail and network variables, like ipv6.</p>
45<impo>This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some of the variables in this document will be different. It is recommended that you upgrade. Some other packages included in this howto are version sensitive as well. You are advised to read the documentation included with packages if you run into issues with this.</impo> 47<impo>This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some of the variables in this document will be different. It is recommended that you upgrade. Some other packages included in this howto are version sensitive as well. You are advised to read the documentation included with packages if you run into issues with this.</impo>
46<impo>This document uses apache-1.3.x. Apache-2 has been marked stable in portage. However there are still a number of issues with php integration. Until php support in apache-2.0.x is marked stable, this guide will continue to use the 1.3.x version.</impo> 48<impo>This document uses apache-1.3.x. Apache-2 has been marked stable in portage. However there are still a number of issues with php integration. Until php support in apache-2.0.x is marked stable, this guide will continue to use the 1.3.x version.</impo>
47<impo>You need a domain name to run a public mail server, or at least an MX record for a domain. Ideally you would have control of at least two domains to take advantage of your new virtual domain functionality.</impo> 49<impo>You need a domain name to run a public mail server, or at least an MX record for a domain. Ideally you would have control of at least two domains to take advantage of your new virtual domain functionality.</impo>
48<impo>Make sure <path>/etc/hostname</path> is set to the right hostname for your mail server. Verify your hostname is set correctly with <c>hostname</c>. Also verify that there are no conflicting entries in <path>/etc/hosts</path>.</impo> 50<impo>Make sure <path>/etc/hostname</path> is set to the right hostname for your mail server. Verify your hostname is set correctly with <c>hostname</c>. Also verify that there are no conflicting entries in <path>/etc/hosts</path>.</impo>
285<li>users - all user account information</li> 287<li>users - all user account information</li>
286<li>virtual - virtual domain email alias maps</li> 288<li>virtual - virtual domain email alias maps</li>
287</ul> 289</ul>
288</p> 290</p>
289<pre caption="alias table sample" > 291<pre caption="alias table sample" >
290 id alias destination 292id alias destination
291 1 root foo@bar.com 2931 root foo@bar.com
292 2 postmaster foo@bar.com 2942 postmaster foo@bar.com
293</pre> 295</pre>
294<pre caption="user table sample" > 296<pre caption="user table sample" >
295 id email clear name uid gid homedir maildir quota postfix 297<codenote>Line wrapped for clarity</codenote>
296 10 foo@virt-bar.org $password realname virtid virtid /home/vmail /home/vmail/virt-bar.org/foo/.maildir/ y 298id email clear name uid gid homedir \
297 13 foo@bar.com $password realname localid localid /home/foo /home/foo/.maildir/ y 299 maildir quota postfix
30010 foo@virt-bar.org $password realname virtid virtid /home/vmail \
301 /home/vmail/virt-bar.org/foo/.maildir/ y
30213 foo@bar.com $password realname localid localid /home/foo \
303 /home/foo/.maildir/ y
298</pre> 304</pre>
299<pre caption="transport table sample" > 305<pre caption="transport table sample" >
300 id domain destination 306id domain destination
301 1 bar.com local: 3071 bar.com local:
302 2 virt-bar.org virtual: 3082 virt-bar.org virtual:
303</pre> 309</pre>
304<pre caption="virtual table sample" > 310<pre caption="virtual table sample" >
305 id email destination 311id email destination
306 3 root@virt-bar.org other@email.address 3123 root@virt-bar.org other@email.address
307</pre> 313</pre>
308</body> 314</body>
309</chapter> 315</chapter>
310<chapter> 316<chapter>
311<title>Apache and phpMyAdmin</title> 317<title>Apache and phpMyAdmin</title>
312<body> 318<body>
313<p>Next we'll set up apache and add an interface to interact with the database more easily. </p> 319<p>Next we'll set up apache and add an interface to interact with the database more easily. </p>
314<pre caption="Setting up apache and phpmyadmin" > 320<pre caption="Setting up apache and phpmyadmin" >
315# <i>emerge apache mod_php mod_ssl phpmyadmin</i> 321# <i>emerge apache mod_php phpmyadmin</i>
316</pre> 322</pre>
317<p>There are plenty of guides out there about how to set up apache with php. Like this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also numerous posts on <uri>http://forums.gentoo.org</uri> detailing how to solve problems with the installation (search for 'apache php'). So, that said, I'm not going to cover it here. Set up the apache and php installs, then continue with this howto. Now, a word for the wise: .htaccess the directory that you put phpmyadmin in. If you do not do this, search engine spiders will come along and index the page which in turn will mean that anyone will be able to find your phpmyadmin page via google and in turn be able to come change your database however they want which is <e>BAD!</e> There are many howtos on this including: <uri>http://docs.csoft.net/micro/black-htaccess.html</uri>.</p> 323<p>There are plenty of guides out there about how to set up apache with php. Like this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also numerous posts on <uri>http://forums.gentoo.org</uri> detailing how to solve problems with the installation (search for 'apache php'). So, that said, I'm not going to cover it here. Set up the apache and php installs, then continue with this howto. Now, a word for the wise: .htaccess the directory that you put phpmyadmin in. If you do not do this, search engine spiders will come along and index the page which in turn will mean that anyone will be able to find your phpmyadmin page via google and in turn be able to come change your database however they want which is <e>BAD!</e> There are many howtos on this including: <uri>http://docs.csoft.net/micro/black-htaccess.html</uri>.</p>
318<p>Now we're going to install the Apache certificates we made previously. The Apache-SSL directives that you need to use the resulting cert are: 324<p>Now we're going to install the Apache certificates we made previously. The Apache-SSL directives that you need to use the resulting cert are:
319 <ul> 325 <ul>
320<li>SSLCertificateFile /path/to/certs/new.cert.cert</li> 326<li>SSLCertificateFile /path/to/certs/new.cert.cert</li>
335# <i>/etc/init.d/apache restart</i> 341# <i>/etc/init.d/apache restart</i>
336</pre> 342</pre>
337<note>If you have an existing apache install, you'll likely have to perform a full server reboot to install your new certificates. Check your logs to verify apache restarted successfully.</note> 343<note>If you have an existing apache install, you'll likely have to perform a full server reboot to install your new certificates. Check your logs to verify apache restarted successfully.</note>
338<p>Next, configure phpMyAdmin.</p> 344<p>Next, configure phpMyAdmin.</p>
339<pre caption="Configuring phpMyAdmin" > 345<pre caption="Configuring phpMyAdmin" >
340# <i>nano -w /home/httpd/htdocs/phpmyadmin/config.inc.php</i> 346# <i>nano -w /var/www/localhost/htdocs/phpmyadmin/config.inc.php</i>
341<codenote>Change the following parameters</codenote> 347<codenote>Change the following parameters</codenote>
342 348
343$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname 349$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname
344$cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings 350$cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings
345 // (this user must have read-only 351 // (this user must have read-only
346$cfg['Servers'][$i]['controlpass'] = '$password'; // access to the &quot;mysql/user&quot; 352$cfg['Servers'][$i]['controlpass'] = '$password'; // access to the &quot;mysql/user&quot;
347 // and &quot;mysql/db&quot; tables) 353 // and &quot;mysql/db&quot; tables)
348$cfg['Servers'][$i]['user'] = 'mailsql'; // MySQL user 354$cfg['Servers'][$i]['user'] = 'mailsql'; // MySQL user
349$cfg['Servers'][$i]['password'] = '$password'; // MySQL password 355$cfg['Servers'][$i]['password'] = '$password'; // MySQL password
350</pre> 356</pre>
351<p>Now enter the phpmyadmin page and browse the tables. You'll want to add in your local aliases, edit your user table to add a test user, and change your transport table to add information about your domains. The default values supplied with the dumpfile should be a sufficient guide to what values need to go where. Make sure that if you put information in the database that it is accurate. For instance, make sure the local users home dir exists and that the correct uid/gid values are in place. The maildirs should be created automatically by postfix when the user receives their first email. So, in general, it's a good idea to send a &quot;Welcome&quot; mail to a new user after you setup their account to make sure the .maildir gets created. </p> 357<p>Now enter the phpmyadmin page and browse the tables. You'll want to add in your local aliases, edit your user table to add a test user, and change your transport table to add information about your domains. The default values supplied with the dumpfile should be a sufficient guide to what values need to go where. Make sure that if you put information in the database that it is accurate. For instance, make sure the local users home dir exists and that the correct uid/gid values are in place. The maildirs should be created automatically by postfix when the user receives their first email. So, in general, it's a good idea to send a &quot;Welcome&quot; mail to a new user after you setup their account to make sure the .maildir gets created. </p>
352</body> 358</body>
353</chapter> 359</chapter>
354<chapter> 360<chapter>
368<chapter> 374<chapter>
369<title>Configuring MySQL Authentication and vhosts</title> 375<title>Configuring MySQL Authentication and vhosts</title>
370<body> 376<body>
371<p>Next we'll reconfigure our authentication to use the mailsql database in courier-imap and postfix. In all of the following examples, replace $password with the password you set for the mailsql mysql user.</p> 377<p>Next we'll reconfigure our authentication to use the mailsql database in courier-imap and postfix. In all of the following examples, replace $password with the password you set for the mailsql mysql user.</p>
372<pre> 378<pre>
373# <i>emerge /usr/portage/sys-libs/pam_mysql/pam_mysql-$currentversion.ebuild</i> 379# <i>emerge pam_mysql</i>
374<codenote>This package is currently masked so you'll have to give it an explicit path </codenote>
375<codenote>or unmask the package. This is subject to change when the package is unmasked</codenote>
376<codenote>in the portage tree.</codenote>
377
378# <i>nano -w /etc/pam.d/imap</i> 380# <i>nano -w /etc/pam.d/imap</i>
379<codenote>Comment out the existing auth lines and add the following as shown.</codenote> 381<codenote>Comment out the existing auth lines and add the following as shown.</codenote>
380 382
381#auth required pam_nologin.so 383#auth required pam_nologin.so
382#auth required pam_stack.so service=system-auth 384#auth required pam_stack.so service=system-auth
383#account required pam_stack.so service=system-auth 385#account required pam_stack.so service=system-auth
384#session required pam_stack.so service=system-auth 386#session required pam_stack.so service=system-auth
385 387
386auth optional pam_mysql.so server=localhost db=mailsql user=mailsql \ 388auth optional pam_mysql.so host=localhost db=mailsql user=mailsql \
387 passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0 389 passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0
388account required pam_mysql.so server=localhost db=mailsql user=mailsql \ 390account required pam_mysql.so host=localhost db=mailsql user=mailsql \
389 passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0 391 passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0
390 392
391# <i>nano -w /etc/pam.d/pop3</i> 393# <i>nano -w /etc/pam.d/pop3</i>
392# <i>nano -w /etc/pam.d/smtp</i> 394# <i>nano -w /etc/pam.d/smtp</i>
393<codenote>Make the same changes to the pop3 and smtp files</codenote> 395<codenote>Make the same changes to the pop3 and smtp files</codenote>
540<body> 542<body>
541<pre> 543<pre>
542# <i>emerge squirrelmail</i> 544# <i>emerge squirrelmail</i>
543<codenote>I like to add a link to the htdocs space for a shorter url.</codenote> 545<codenote>I like to add a link to the htdocs space for a shorter url.</codenote>
544 546
545# <i>ln -s /home/httpd/htdocs/squirrelmail/ /home/httpd/htdocs/mail</i> 547# <i>ln -s /var/www/localhost/htdocs/squirrelmail/ /var/www/localhost/htdocs/mail</i>
546# <i>cd /home/httpd/htdocs/mail/conf</i> 548# <i>cd /var/www/localhost/htdocs/mail/conf</i>
547# <i>./conf.pl</i> 549# <i>./conf.pl</i>
548<codenote>Change your Organization, Server, and Folder settings for squirrelmail.</codenote> 550<codenote>Change your Organization, Server, and Folder settings for squirrelmail.</codenote>
549<codenote>Now you should be able to login to squirrelmail, again - with your full email address,</codenote> 551<codenote>Now you should be able to login to squirrelmail, again - with your full email address,</codenote>
550<codenote>and use your new webmail setup.</codenote> 552<codenote>and use your new webmail setup.</codenote>
551</pre> 553</pre>
728<codenote>letting you know that the service is running and ready to respond to requests.</codenote> 730<codenote>letting you know that the service is running and ready to respond to requests.</codenote>
729 731
730Trying 127.0.0.1... 732Trying 127.0.0.1...
731Connected to localhost. 733Connected to localhost.
732Escape character is '^]'. 734Escape character is '^]'.
733* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc. See COPYING for distribution information. 735* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc.
734</pre> 736</pre>
735</body> 737</body>
736</section> 738</section>
737<section> 739<section>
738<title>Step 6: Sometimes only the big guns will give you the information you need: strace.</title> 740<title>Step 6: Sometimes only the big guns will give you the information you need: strace.</title>

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20