[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Monday, 20 August 2001 | Author: Henry Chen |
Published to: enhance_articles_sysadmin/Sysadmin | Page: 2/4 - [Printable] |
Install and Test Qmail with POP, IMAP and WebMail
Kill Sendmail? Are you kidding me? Well, no. In this first run original article Henry Chen provides us with free detailed step-by-step instructions for installing Qmail with Redhat 7.1, an alternative open source solution to your mail management needs.
|
<< Page 2 of 4 >> | |
Install Qmail (SMTP, POP)As we are migrating from another server, we started with a clean Red Hat Linux 7.1 server installation with just the Web Server module. I downloaded all the software into my home directory on the server. Note: for the truly lazy (or just very bad typist), copy the commands and paste them into your console window. From your home directory, unpack the tarballs: tar -xzf qmail-1.03.tar.gz tar -xzf ucspi-tcp-0.88.tar.gz tar -xzf checkpassword-0.90.tar.gz There should now be subdirectories of these packages. We start by doing Qmail. su umask 022 mkdir /var/qmail ln -s /usr/local/man /var/qmail/man I decided to leave the mkdir /etc/qmail ln -s /etc/qmail /var/qmail/control ln -s /usr/sbin /var/qmail/bin Now, we need to setup the Qmail groups and users: /usr/sbin/groupadd nofiles /usr/sbin/useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent /usr/sbin/useradd qmaild -g nofiles -d /var/qmail -s /nonexistent /usr/sbin/useradd qmaill -g nofiles -d /var/qmail -s /nonexistent /usr/sbin/useradd qmailp -g nofiles -d /var/qmail -s /nonexistent /usr/sbin/groupadd qmail /usr/sbin/useradd qmailq -g qmail -d /var/qmail -s /nonexistent /usr/sbin/useradd qmailr -g qmail -d /var/qmail -s /nonexistent /usr/sbin/useradd qmails -g qmail -d /var/qmail -s /nonexistent The following will build Qmail from the sources: cd qmail-1.03 make setup check ./config For us, ./config-fast the.full.hostname Qmail is done. Now we do ucspi-tcp. You should still be the root user. Note: $username is your username. cd ~$username/ucspi-tcp-0.88 make make setup check ucspi-tcp is done. This will install ucspi-tcp into the mkdir -p /package chmod 1755 /package cd /package tar -xzf ~$username/daemontools-0.76.tar.gz cd admin/daemontools-0.76 package/install daemontools is done. At this point in time, you should see a few cd ~$username/checkpassword-0.90 make make setup check checkpassword is done. We have made all the binaries that we need to run Qmail. Next, we need create some configuration directories and files so that Qmail will run properly. ConfigureWe are following the configuration suggestions made by Dave Sill (in Life with Qmail). We have further made the decision to use Maildir instead of the other two less fancy options. I am only going to discuss Maildir and not the other options. Life with Qmail covers this configuration topic very well and very thoroughly. I do not need to reinvent the wheel here. In this section, you will need to create some files. I use vi. If you hate vi, anytime you see vi, just replace it with your favorite editor. You are still be the root user. First, we kill sendmail: vi hint: hit /etc/init.d/sendmail stop rpm -e --nodeps sendmail Removing sendmail completely is quite safe. Qmail is more than capable of taking over for sendmail. Now, we create all the directories that we need: mkdir -p /var/log/qmail/smtpd mkdir -p /var/log/qmail/pop3d chown -R qmaill /var/log/qmail mkdir -p /var/qmail/supervise/qmail-send/log chmod +t /var/qmail/supervise/qmail-send mkdir -p /var/qmail/supervise/qmail-smtpd/log chmod +t /var/qmail/supervise/qmail-smtpd mkdir -p /var/qmail/supervise/qmail-pop3d/log chmod +t /var/qmail/supervise/qmail-pop3d Now we create a #!/bin/sh # Using stdout for logging # Using control/defaultdelivery from qmail-local to deliver messages by default exec env - PATH="/var/qmail/bin:$PATH" \ qmail-start "`cat /var/qmail/control/defaultdelivery`" Make this file executable, then create the chmod 755 /var/qmail/rc echo ./Maildir/ > /var/qmail/control/defaultdelivery Create the #!/bin/sh # For Red Hat chkconfig # chkconfig: - 30 80 # description: the qmail MTA PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin export PATH QMAILDUID=`id -u qmaild` NOFILESGID=`id -g qmaild` case "$1" in start) echo "Starting qmail" if svok /service/qmail-send ; then svc -u /service/qmail-send else echo qmail-send service not running fi if svok /service/qmail-smtpd ; then svc -u /service/qmail-smtpd else echo qmail-smtpd service not running fi if [ -d /var/lock/subsys ]; then touch /var/lock/subsys/qmail fi if svok /service/qmail-pop3d ; then svc -u /service/qmail-pop3d else echo qmail-pop3d service not running fi ;; stop) echo "Stopping qmail..." echo " qmail-smtpd" svc -d /service/qmail-smtpd echo " qmail-send" svc -d /service/qmail-send if [ -f /var/lock/subsys/qmail ]; then rm /var/lock/subsys/qmail fi echo " qmail-pop3d" svc -d /service/qmail-pop3d ;; stat) svstat /service/qmail-send svstat /service/qmail-send/log svstat /service/qmail-smtpd svstat /service/qmail-smtpd/log qmail-qstat svstat /service/qmail-pop3d svstat /service/qmail-pop3d/log ;; doqueue|alrm|flush) echo "Sending ALRM signal to qmail-send." svc -a /service/qmail-send ;; queue) qmail-qstat qmail-qread ;; reload|hup) echo "Sending HUP signal to qmail-send." svc -h /service/qmail-send ;; pause) echo "Pausing qmail-send" svc -p /service/qmail-send echo "Pausing qmail-smtpd" svc -p /service/qmail-smtpd echo "Pausing qmail-pop3d" svc -p /service/qmail-pop3d ;; cont) echo "Continuing qmail-send" svc -c /service/qmail-send echo "Continuing qmail-smtpd" svc -c /service/qmail-smtpd echo "Continuing qmail-pop3d" svc -c /service/qmail-pop3d ;; restart) echo "Restarting qmail:" echo "* Stopping qmail-smtpd." svc -d /service/qmail-smtpd echo "* Sending qmail-send SIGTERM and restarting." svc -t /service/qmail-send echo "* Restarting qmail-smtpd." svc -u /service/qmail-smtpd echo "* Restarting qmail-pop3d." svc -t /service/qmail-pop3d ;; cdb) tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp chmod 644 /etc/tcp.smtp.cdb echo "Reloaded /etc/tcp.smtp." ;; help) cat <<HELP stop -- stops mail service (smtp connections refused, nothing goes out) start -- starts mail service (smtp connection accepted, mail can go out) pause -- temporarily stops mail service (smtp connections accepted, but nothing leaves) cont -- continues paused mail service stat -- displays status of mail service cdb -- rebuild the tcpserver cdb file for smtp restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it doqueue -- sends qmail-send ALRM, scheduling queued messages for delivery reload -- sends qmail-send HUP, rereading locals and virtualdomains queue -- shows status of queue alrm -- same as doqueue flush -- same as doqueue hup -- same as reload HELP ;; *) echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}" exit 1 ;; esac exit 0 Make chmod 755 /var/qmail/bin/qmailctl ln -s /var/qmail/bin/qmailctl /etc/init.d/qmail ln -s /var/qmail/bin/qmailctl /usr/bin/qmailctl ln -s ../init.d/qmail /etc/rc0.d/K30qmail ln -s ../init.d/qmail /etc/rc1.d/K30qmail ln -s ../init.d/qmail /etc/rc2.d/S80qmail ln -s ../init.d/qmail /etc/rc3.d/S80qmail ln -s ../init.d/qmail /etc/rc4.d/S80qmail ln -s ../init.d/qmail /etc/rc5.d/S80qmail ln -s ../init.d/qmail /etc/rc6.d/K30qmail Now we do the supervise scripts for send. First, #!/bin/sh exec /var/qmail/rc Then send's log, #!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail Now we do the supervise scripts for smtpd. First, #!/bin/sh QMAILDUID=`id -u qmaild` NOFILESGID=`id -g qmaild` MAXSMTPD=`cat /var/qmail/control/concurrencyincoming` exec /usr/local/bin/softlimit -m 2000000 \ /usr/local/bin/tcpserver -v -R -l 0 -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \ -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1 Then, create the echo 20 > /var/qmail/control/concurrencyincoming Then smtpd's log, #!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd Now we do the supervise scripts for pop3d. First, #!/bin/sh exec /usr/local/bin/softlimit -m 2000000 \ /usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \ FQDN /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir 2>&1 FQDN is the Fully Qualified Domain Name of the server that you are working on. Then pop3d's log, #!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/pop3d Now make all these files executable: chmod 755 /var/qmail/supervise/qmail-send/run chmod 755 /var/qmail/supervise/qmail-send/log/run chmod 755 /var/qmail/supervise/qmail-smtpd/run chmod 755 /var/qmail/supervise/qmail-smtpd/log/run chmod 755 /var/qmail/supervise/qmail-pop3d/run chmod 755 /var/qmail/supervise/qmail-pop3d/log/run Before we start up Qmail, we need to disallow relay from remote hosts (we will deal with relay control later) and setup some aliases. echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp qmailctl cdb echo $username > /var/qmail/alias/.qmail-root echo $username > /var/qmail/alias/.qmail-postmaster ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster These are the bare minimum aliases. Feel free to create more.
You should also see localhost hostname of your server For virtual domains, you will need to populate We have removed sendmail before. Now, we replace it with Qmail's sendmail: ln -s /var/qmail/bin/sendmail /usr/lib ln -s /var/qmail/bin/sendmail /usr/sbin Lastly (phew!), we link the ln -s /var/qmail/supervise/qmail-send /service ln -s /var/qmail/supervise/qmail-smtpd /service ln -s /var/qmail/supervise/qmail-pop3d /service Once these links are created, wait for a minute or two and Qmail will start running and you will have SMTP (send and receive) and POP. For now, you also need to know these to start, stop and restart Qmail: qmailctl start qmailctl stop qmailctl restart TestingThat's it for Qmail. Now comes the fun part of testing. Before you
start testing, you need to create the proper "mailbox" for
yourself, which is really a directory. If you are still root, type cd /var/qmail/bin/maildirmake Maildir This will create a Follow the instructions in Also remember that you can only receive via POP now. If you try to
send anything via POP, Qmail will stop you (and you should test this to make
sure). If things does not work for you, don't freak out. Check
the
| |
<< Page 2 of 4 >> |