installing qmail server by badi ul zaman

26
Installing qmail Server Part 1 Downloading Software mkdir /downloads cd /downloads wget http://www.qmailrocks.org/downloads/qmailrocks.tar.gz tar zxvf qmailrocks.tar.gz Part 2 - Installing Qmail Itself /downloads/qmailrocks/scripts/install/qmr_install_linux-s1.script /downloads/qmailrocks/scripts/util/qmail_big_patches.script cd /usr/src/qmail/qmail-1.03 make man && make setup check ./config-fast mail.froebels.com.pk make cert chown -R vpopmail:qmail /var/qmail/control/clientcert.pem / var/qmail/control/servercert.pem cd /usr/src/qmail/ucspi-tcp-0.88/ patch < /downloads/qmailrocks/patches/ucspi-tcp-0.88.errno.patch make && make setup check

Upload: sadaf-arif

Post on 22-Feb-2015

116 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Installing Qmail Server by Badi Ul Zaman

Installing qmail ServerPart 1 Downloading Softwaremkdir /downloads

cd /downloads

wget http://www.qmailrocks.org/downloads/qmailrocks.tar.gz

tar zxvf qmailrocks.tar.gz

Part 2 ­ Installing Qmail Itself

/downloads/qmailrocks/scripts/install/qmr_install_linux­s1.script 

/downloads/qmailrocks/scripts/util/qmail_big_patches.script

cd /usr/src/qmail/qmail­1.03

make man && make setup check

./config­fast mail.froebels.com.pk

make cert

chown ­R vpopmail:qmail /var/qmail/control/clientcert.pem /var/qmail/control/servercert.pem

cd /usr/src/qmail/ucspi­tcp­0.88/

patch < /downloads/qmailrocks/patches/ucspi­tcp­0.88.errno.patchmake && make setup check

Page 2: Installing Qmail Server by Badi Ul Zaman

cd /package/admin/daemontools­0.76

cd /package/admin/daemontools­0.76/src

patch < /downloads/qmailrocks/patches/daemontools­0.76.errno.patch

cd /package/admin/daemontools­0.76 

package/install

Part 3 – Ezmlm

cd /downloads/qmailrocks/

tar zxvf ezmlm­0.53­idx­0.41.tar.gz

cd ezmlm­0.53­idx­0.41

make && make setup

Part 4 – Autoresponder

cd /downloads/qmailrocks

tar zxvf autorespond­2.0.5.tar.gz

cd autorespond­2.0.5

make && make install

Part 5 ­ Vpopmail w/MySQL 

Page 3: Installing Qmail Server by Badi Ul Zaman

mkdir ~vpopmail/etc 

chown vpopmail:vchkpw ~vpopmail/etc 

echo "localhost|0|hashmi|xxxxxx|vpopmail" > ~vpopmail/etc/vpopmail.mysql

chown vpopmail:vchkpw ~vpopmail/etc/vpopmail.mysql 

chmod 640 ~vpopmail/etc/vpopmail.mysql 

chkconfig ­­level 35 mysqld on

service mysqld start

mysql ­u root

SET PASSWORD FOR root@localhost=PASSWORD('xxxxxx');

quit

mysql ­u root ­p 

CREATE DATABASE vpopmail; GRANT select,insert,update,delete,create,drop ON vpopmail.* TOhashmi@localhost IDENTIFIED BY 'xxxxxx'; 

quit

mysql  ­u hashmi ­p

quit

cd /downloads/qmailrocks 

tar zxvf vpopmail­5.4.13.tar.gz 

Page 4: Installing Qmail Server by Badi Ul Zaman

cd vpopmail­5.4.13

./configure ­­enable­logging=p ­­enable­auth­module=mysql ­­disable­passwd ­­enable­clear­passwd ­­disable­many­domains ­­enable­auth­logging ­­enable­sql­logging ­­enable­valias ­­disable­mysql­limits

 make && make install­strip

Part 6 – Vqadmincd /downloads/qmailrocks

tar zxvf vqadmin­2.3.6.tar.gz

cd vqadmin­2.3.6

./configure ­­enable­cgibindir=/var/www/cgi­bin ­­enable­htmldir=/var/www/html 

make && make install­strip

vi /etc/httpd/conf/httpd.conf

ServerName mail.froebels.com.pkServerAdmin [email protected]

<Directory "/var/www/cgi­bin/vqadmin"> deny from all Options ExecCGI AllowOverride AuthConfig Order deny,allow </Directory>

 chkconfig  ­­level 35 httpd on

Page 5: Installing Qmail Server by Badi Ul Zaman

 service httpd restart

cd /var/www/cgi­bin/vqadmin

vi .htaccess AuthType Basic AuthUserFile /etc/httpd/.htpasswd AuthName vQadmin require valid­user satisfy any

chown apache .htaccess

chmod 644 .htaccess

htpasswd ­bc /etc/httpd/.htpasswd admin xxxxx

chmod 644 /etc/httpd/.htpasswd 

service httpd restart

http://mail.froebels.com.pk/cgi­bin/vqadmin/vqadmin.cgi 

Part 7­ Maildrop

cd /downloads/qmailrocks

tar zxvf maildrop­1.6.3.tar.gz 

cd maildrop­1.6.3

./configure ­­prefix=/usr/local ­­exec­prefix=/usr/local ­­enable­maildrop­uid=root ­­enable­maildrop­gid=vchkpw ­­enable­maildirquota

Page 6: Installing Qmail Server by Badi Ul Zaman

make && make install­strip && make install­man

Part 8 ­ Qmailadmin

cd /downloads/qmailrocks

tar zxvf qmailadmin­1.2.9.tar.gz

cd qmailadmin­1.2.9

./configure ­­enable­cgibindir=/var/www/cgi­bin ­­enable­htmldir=/var/www/html

 http://mail.froebels.com.pk/cgi­bin/qmailadmin 

Part 9 ­ Finalizing Qmail

/downloads/qmailrocks/scripts/finalize/linux/finalize_linux.script

vi /var/qmail/supervise/qmail­pop3d/run

Find "mail.example.com" and change it to mail.froebels.com.pk

vi /var/qmail/supervise/qmail­smtpd/run

Find "mail.example.com" and change it to  mail.froebels.com.pk

qmailctl stop

echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp

qmailctl cdb

echo [email protected]  > /var/qmail/alias/.qmail­root

Page 7: Installing Qmail Server by Badi Ul Zaman

echo [email protected]  > /var/qmail/alias/.qmail­postmasterecho [email protected] > /var/qmail/alias/.qmail­mailer­daemon

ln ­s /var/qmail/alias/.qmail­root /var/qmail/alias/.qmail­anonymous

chmod 644 /var/qmail/alias/.qmail*

Part 10 ­ Uninstalling Sendmail/Postfix 

Removing sendmail rpm ­qa | grep sendmail

service sendmail stop

rpm ­e sendmail­doc

rpm ­e sendmail­cf

 rpm ­e sendmail­8.13.1

 rpm ­e sendmail­devel

mv /usr/lib/sendmail /usr/lib/sendmail.old

mv /usr/sbin/sendmail /usr/sbin/sendmail.old

chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old

Removing postfix

rpm ­qa | grep postfix

service postfix stop

Page 8: Installing Qmail Server by Badi Ul Zaman

rpm ­e postfix

rm /usr/lib/sendmail

rm /usr/sbin/sendmail

ln ­s /var/qmail/bin/sendmail /usr/lib/sendmail

ln ­s /var/qmail/bin/sendmail /usr/sbin/sendmail

Part 11 ­ Starting qmail

/downloads/qmailrocks/scripts/util/qmr_inst_check

qmailctl stop

qmailctl start

qmailctl stat

telnet localhost 110user [email protected] xxxxx

listquit

telnet localhost 25starttls

quit

quit

Page 9: Installing Qmail Server by Badi Ul Zaman

Part 12 ­ Installing Courier­imap/imaps withCourierpassd

cd /downloads/qmailrocks/

tar jxvf courier­authlib­0.55.tar.bz2

cd courier­authlib­0.55

./configure ­­prefix=/usr/local ­­exec­prefix=/usr/local ­­with­authvchkpw ­­without­authldap ­­without­authmysql ­­disable­root­check ­­with­ssl ­­with­authchangepwdir=/usr/local/libexec/authlib ­­with­redhat 

make && make check

make install­strip && make install­configure

vi /etc/rc.local

usr/local/sbin/authdaemond start

cd /downloads/qmailrocks/

tar jxvf courier­imap­4.0.2.tar.bz2

chown ­R bnhashmi:wheel courier­imap­4.0.2

cd /downloads/qmailrocks/courier­imap­4.0.2

su bnhashmi

./configure ­­prefix=/usr/local ­­exec­prefix=/usr/local ­­with­authvchkpw ­­without­authldap ­­without­authmysql ­­disable­root­check ­­with­ssl ­­with­authchangepwdir=/usr/local/libexec/authlib ­­with­redhat 

Page 10: Installing Qmail Server by Badi Ul Zaman

make && make check

exit

make install­strip && make install­configure

/usr/local/sbin/mkimapdcert

vi /usr/local/etc/imapd.cnf

change to [email protected]

vi /usr/local/etc/imapd

change to

IMAPDSTART = YES

vi /usr/local/etc/imapd­ssl

change to 

IMAPDSSLSTART=YES

vi /usr/local/etc/authlib/authdaemonrc

set toauthmodulelist="authvchkpw"

cp /usr/local/libexec/imapd.rc /etc/rc.d/init.d/imap

cp /usr/local/libexec/imapd­ssl.rc /etc/rc.d/init.d/imaps/usr/local/sbin/authdaemond stop

Page 11: Installing Qmail Server by Badi Ul Zaman

/usr/local/sbin/authdaemond start

/etc/rc.d/init.d/imap stop

/etc/rc.d/init.d/imaps stop

/etc/rc.d/init.d/imap start 

/etc/rc.d/init.d/imaps start

telnet localhost 143

a login [email protected]  xxxxx

a logout

cd /downloads/qmailrocks

tar zxvf courierpassd­1.1.0­RC1.tar.gz

cd courierpassd­1.1.0­RC1

./configure

make && make install

cd /etc/xinetd.d

vi courierpassd

service courierpassd { port = 106 socket_type = stream protocol = tcp

Page 12: Installing Qmail Server by Badi Ul Zaman

 user = root server = /usr/local/sbin/courierpassd server_args = ­s imap wait = no only_from = 127.0.0.1 instances = 4 disable = no }

vi /etc/inetd.conf

courierpassd stream tcp nowait root /usr/local/sbin/courierpassd ­s imap

vi /etc/services

below 

# Local Services 

courierpassd 106/tcp #for /etc/xinetd.d/courierpassd

/etc/rc.d/init.d/xinetd restarttelnet localhost 106

user [email protected]

pass xxxxx

newpass redhat

quit

Part 13 ­ Installing Squirrelmail

 cd /usr/share/squirrelmail/config/

Page 13: Installing Qmail Server by Badi Ul Zaman

vi config_local.php

change to$default_folder_prefix  = 'inbox.';./conf.pl

General­­­­­­­1.  Domain                 : mail.froebels.com.pk2.  Invert Time            : false3. Sendmail or SMTP       : SMTP

Organization Preferences4. 1.  Organization Name      : Froebels International5. 2.  Organization Logo      : ../images/sm_logo.png6. 3.  Org. Logo Width/Height : (308/111)7. 4.  Organization Title     : Froebels International Running SquirrelMail $version8. 5.  Signout Page           :9. 6.  Default Language       : en_US10.7.  Top Frame              : _top11.8.  Provider link          : http://www.squirrelmail.org/12.9.  Provider name          : SquirrelMail

SMTP Settings­­­­­­­­­­­­­4.   SMTP Server           : localhost5.   SMTP Port             : 256.   POP before SMTP       : false7.   SMTP Authentication   : login8. Secure SMTP (TLS)     : false

IMAP Settings­­­­­­­­­­­­­­4.  IMAP Server            : localhost5.  IMAP Port              : 1436.  Authentication type    : login

Page 14: Installing Qmail Server by Badi Ul Zaman

7.  Secure IMAP (TLS)      : false8.  Server software        : other9. Delimiter              : detect

Installing Plugins

/usr/share/squirrelmail/plugins

wget http://squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fwww.squirrelmail.org%2Fplugins%2Fchange_pass­2.7­1.4.x.tar.gz

tar zxvf change_pass­2.7­1.4.x.tar.gz

rm ­rf change_pass­2.7­1.4.x.tar.gz

cd /usr/share/squirrelmail/config/

./conf.pl

add plugins

Part 14 ­ Clam Antivirus & SpamAssassin

/downloads/qmailrocks/scripts/util/check_perlmods.script

cd /downloads/qmailrocks/perlmods/source

tar zxvf  Parse­Syslog­1.03.tar.gz

cd Parse­Syslog­1.03

 perl Makefile.PL make make test make install

Page 15: Installing Qmail Server by Badi Ul Zaman

cd /downloads/qmailrocks/perlmods/source

tar zxvf Statistics­Distributions­1.02.tar.gzcd Statistics­Distributions­1.02

perl Makefile.PL make make test make install

cd /downloads/qmailrocks/

rpm ­ivh clamav­0.87­1.i386.rpm clamav­devel­0.87­1.i386.rpm

vi /etc/clamd.conf

change to LogFile  /var/log/clamav/clamd.log LogTimeLogSyslogUser qscand ScanMail

useradd ­c "Qmail­Scanner Account" ­s /bin/false qscand 

chown qscand:qscand /var/log/clamav ­R

vi /etc/logrotate.d/clamd

change to 

create 640 qscand qscand

vi /etc/freshclam.confDatabaseOwner qscand

Page 16: Installing Qmail Server by Badi Ul Zaman

crontab ­e 25 1 * * * /usr/bin/freshclam ­­quiet ­l /var/log/clamav/freshclam.log

chkconfig ­­level 35 clamd onservcie clamd restart

freshclam   ­­­­  update Antivirus

cd /downloads/qmailrocks/perlmods/rpms/

rpm ­Uvh perl­Mail­SpamAssassin­3.0.2­1.i386.rpm ­­force

cd /downloads/qmailrocks/

rpm ­ivh  ­­nodeps –force spamassassin­3.0.2­1.i386.rpm spamassassin­tools­3.0.2­1.i386.rpm –nodeps

groupadd spamd

useradd ­g spamd ­s /home/spamd spamd

vi /etc/sysconfig/spamassassin

SPAMDOPTIONS="­x ­u spamd ­H /home/spamd ­d"

vi /etc/mail/spamassassin/local.cfadd line required_hits 5

chkconfig ­­level 35 spamassassin on service spamassassin  restart

ps aux | grep spamd 

Part 15 ­ qmail­scanner w/qms­analog

Page 17: Installing Qmail Server by Badi Ul Zaman

cd /downloads/qmailrocks

tar zxvf qmail­scanner­1.25.tgz

tar zxvf qms­analog­0.4.2.tar.gz

cd qms­analog­0.4.2

make all

cp qmail­scanner­1.25­st­qms­20050219.patch /downloads/qmailrocks/qmail­scanner­1.25/

cd /downloads/qmailrocks/qmail­scanner­1.25

 patch ­p1 < qmail­scanner­1.25­st­qms­20050219.patch

cd /downloads/qmailrocks/qmail­scanner­1.25

vi qms­config

#!/bin/sh

if [ "$1" != "install" ]; then INSTALL= else INSTALL="­­install" fi

./configure ­­domain froebels.com.pk \ ­­admin postmaster \ ­­local­domains "froebels.com.pk" \

Page 18: Installing Qmail Server by Badi Ul Zaman

 ­­add­dscr­hdrs yes \ ­­dscr­hdrs­text "X­Antivirus­MYDOMAIN" \ ­­ignore­eol­check yes \ ­­sa­quarantine 0 \ ­­sa­delete 0 \ ­­sa­reject no \ ­­sa­subject ":SPAM:" \ ­­sa­delta 0 \ ­­sa­alt yes \ ­­sa­debug no \ ­­notify admin \ "$INSTALL"

chmod 755 qms­config

./qms­config

setuidgid qscand /var/qmail/bin/qmail­scanner­queue.pl ­z

setuidgid qscand /var/qmail/bin/qmail­scanner­queue.pl ­g

chown ­R qscand:qscand /var/spool/qmailscan 

vi /var/qmail/supervise/qmail­smtpd/run

add line in begning

QMAILQUEUE="/var/qmail/bin/qmail­scanner­queue.pl" ; exportQMAILQUEUE

change softlimit to 40000000

qmailctl stop

Page 19: Installing Qmail Server by Badi Ul Zaman

qmailctl start

qmailctl stat 

cd /downloads/qmailrocks/qmail­scanner­1.25/contrib

chmod 755 test_installation.sh

./test_installation.sh ­doit 

QMAILQUEUE was not set, defaulting to /var/qmail/bin/qmail­scanner­queue.plfor this test...

Sending standard test message ­ no viruses...done!

Sending eicar test virus ­ should be caught by perlscanner module...qmail­inject: fatal: qq temporary problem (#4.3.0)Bad error. qmail­inject died

error     

Solution

chmod 4755 /var/qmail/bin/qmail­scanner­queue.pl

QMAILQUEUE was not set, defaulting to /var/qmail/bin/qmail­scanner­queue.plfor this test...

Sending standard test message ­ no viruses...done!

Page 20: Installing Qmail Server by Badi Ul Zaman

Sending eicar test virus ­ should be caught by perlscanner module...done!

Sending eicar test virus with altered filename ­ should only be caught by commercialanti­virus modules (if you have any)...

Sending bad spam message for anti­spam testing ­ In case you are usingSpamAssassin...Done!

Finished test. Now go and check Email for [email protected]

Part 16 ­ QmailAnalog w/qlogtools & qms­analog

cd /downloads/qmailrocks/

tar zxvf qmailanalog­0.70.tar.gz

cd qmailanalog­0.70

patch < /downloads/qmailrocks/patches/0.70­errno.patch

make && make setup check

cd /downloads/qmailrocks/

tar zxvf qlogtools­3.1.tar.gz

cd qlogtools­3.1

patch < /downloads/qmailrocks/patches/qlogtools_errno.patch

mkdir /usr/local/man 

Page 21: Installing Qmail Server by Badi Ul Zaman

make

./installer

cp /downloads/qmailrocks/qms­analog­0.4.2/qmailstats /var/qmail/bin 

vi /var/qmail/bin/qmailstats

chmod 750 /var/qmail/bin/qmailstats

/var/qmail/bin/qmailstats

crontab ­e

0 3 * * * /var/qmail/bin/qmailstats 1>/dev/null 2>/dev/null 

Part 17 ­ Installing Qtrap

cd /home/vpopmail

mkdir ­p qtrap/logs

cd qtrap

cp /downloads/qmailrocks/scripts/qtrap/qtrap­2.0.0 ./qtrap.sh

vi qtrap.sh 

touch /home/vpopmail/qtrap/logs/qtrap.log

chown ­R vpopmail:vchkpw /home/vpopmail/qtrap

chmod ­R 755 /home/vpopmail/qtrap

cd /home/vpopmail/domains/froebels.com.pk/

Page 22: Installing Qmail Server by Badi Ul Zaman

vi .qmail­default

add the line below in the begning of line.| /home/vpopmail/qtrap/qtrap.sh

tail ­f /home/vpopmail/qtrap/logs/qtrap.log

send a mail with the subject sex in object line 

sending mail error   Bad sequence of commands Server replied: 503 AUTH command used whennot advertised ...

Solution  ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­Do the following steps 

chkconfig ­­list|grep on

verify if exim are there and remove exim from startup doing following commands.

chkconfig  exim off

service exim stop

qmailctl start

Part 18  Installing necessary tools for qmail

Installing qmhandle

bunzip2 qmhandle­1.3.0.tar.bz2

tar xvf qmhandle­1.3.0.tar

Page 23: Installing Qmail Server by Badi Ul Zaman

cp qmHandle /sbin

viewing  message queue 

qmHandle ­l

sending messages 

qmHandle ­a

Installing Isoqlog

cd /downloads/

tar zxvf isoqlog­2.2.1.tar.gz

cd isoqlog­2.2.1

./configure make

make install

make clean

cd isoqlog

mkdir /var/www/html/isoqlog

/downloads/isoqlog­2.2.1/data

cp ­pr ./htmltemp/images ./htmltemp/library /var/www/html/isoqlog/

cd /usr/local/etc

Page 24: Installing Qmail Server by Badi Ul Zaman

vi isoqlog.conf#isoqlog 2.1 Configuration file

logtype = "qmail­multilog" #log type qmai­multilog, qmail­syslog, sendmail, postfix logstore = "/var/log/qmail/qmail­send" # domainsfile = "/usr/local/etc/isoqlog.domains" # outputdir = "/var/www/html/isoqlog" #html outpur directory htmldir = "/usr/local/share/isoqlog/htmltemp" langfile = "/usr/local/share/isoqlog/lang/english" hostname = "mail.froebels.com.pk"

maxsender = 100 maxreceiver = 100 maxtotal = 100maxbyte = 100

ln ­s /var/qmail/control/rcpthosts isoqlog.domains

/usr/local/bin/isoqlog

http://mail.frobels.com.pk/isoqlog

Part 19 ­ Maintaining your qmail server

add the following lines in /etc/rc.local

/etc/rc.d/init.d/imap start /etc/rc.d/init.d/imaps start

add  spamassassin  in runlevel 35

chkconfig –level 35 spamassassin  onadd corior IMAP in startup by adding following lines in /etc/rc.local

Page 25: Installing Qmail Server by Badi Ul Zaman

/etc/rc.d/rc.imap start /etc/rc.d/rc.imaps start

Add your HTTP Server in Runlevel 35

chkconfig –level 35 httpd on

Maintaining the qmail queue

qmailctl stat 

qmHandle

Maintaining qmail­scanner

setuidgid qscand /var/qmail/bin/qmail­scanner­queue.pl ­g

Maintaining SpamAssassin

setuidgid qscand /var/qmail/bin/qmail­scanner­queue.pl ­g

Maintaining Clam Antivirus

/usr/bin/freshclam ­­quiet ­l /var/log/clamav/clam­update.log

setuidgid qscand /var/qmail/bin/qmail­scanner­queue.pl ­z

Maintaining the qmail logs

Backing up your qmail server

/home/vpopmail ­ backs up all your domain information, including mailboxes,passwords and the messages themselves.

/var/qmail ­ backs up all of your qmail settings. The /var/qmail/control directory is

Page 26: Installing Qmail Server by Badi Ul Zaman

the most important directory in there to back up, but it won't hurt to just back upthe whole damn qmail directory.