Qmail installation

First you need to install the libraries that is needed for qmail

yum install gcc
yum install make
yum install groff
yum install patch
yum install openssl openssl-devel
yum install pam pam-devel

the following are the source file need to be downloaded
cd /usr/local
wget http://www.qmail.org/netqmail-1.06.tar.gz
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://cr.yp.to/checkpwd/checkpassword-0.90.tar.gz
wget http://downloads.sourceforge.net/project/vpopmail/vpopmail-stable/5.4.30/vpopmail-5.4.30.tar.gz?use_mirror=nchc
wget http://www.dovecot.org/releases/1.2/dovecot-1.2.11.tar.gz

mkdir /package
mv -iv /usr/local/daemontools-0.76.tar.gz /package

Adding needed Users/Groups

———————————
groupadd nofiles
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
useradd -g nofiles -d /var/qmail/alias alias
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails

Installing qmail

—————–
tar -xzvf netqmail-1.06.tar.gz
cd netqmail-1.06/
make setup check
./config-fast –> hostname of the server

Qmail aliases.

—————–
useradd adminmails;
cd ~alias;
echo “adminmails” > .qmail-postmaster
echo “adminmails” > .qmail-mailer-daemon
echo “adminmails” > .qmail-root
echo “adminmails” > .qmail-postmaster
echo “adminmails” > .qmail-abuse
chmod 644 ~alias/.qmail*
su – adminmails
/var/qmail/bin/maildirmake ~/Maildir

————-

Make a script /var/qmail/rc with following contents

########
#!/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`”
########

chmod 755 /var/qmail/rc
echo ./Maildir/ >/var/qmail/control/defaultdelivery

Linking Qmail to sendmail binaries

——————————————-
chmod 000 /usr/lib/sendmail ### Only if sendmail exist
chmod 000 /usr/sbin/sendmail ### Only if sendmail exist
mv /usr/lib/sendmail /usr/lib/sendmail.bak ### Only if sendmail exist
mv /usr/sbin/sendmail /usr/sbin/sendmail.bak ### Only if sendmail exist
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

Install ucspi-tcp

——————
tar -xzvf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch < /usr/local/netqmail-1.06/other-patches/ucspi-tcp-0.88.errno.patch
make
make setup check

Install checkpassword

—————————
cd /usr/local
tar -xzvf checkpassword-0.90.tar.gz
cd checkpassword-0.90
patch < /usr/local/netqmail-1.06/other-patches/checkpassword-0.90.errno.patch
make
make setup check

Install daemontools

————————
tar -xzvf daemontools-0.76.tar.gz
cd /package/admin/daemontools-0.76/src
patch < /usr/local/netqmail-1.06/other-patches/daemontools-0.76.errno.patch
cd ..
package/install

qmailctl

————
cd /var/qmail/bin/
wget http://lifewithqmail.org/qmailctl-script-dt70
mv -iv qmailctl-script-dt70 qmailctl
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin

qmail-send & qmail-smtpd scripts & qmail-pop3d-> run/log

———————————————-
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log

1,make file /var/qmail/supervise/qmail-send/run with below given content
##########
#!/bin/sh
exec /var/qmail/rc

##########

2,make file /var/qmail/supervise/qmail-send/log/run with below given content
###########
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
###########

3,make file /var/qmail/supervise/qmail-smtpd/run with below given content
###########
#!/bin/sh

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`

if [ -z “$QMAILDUID” -o -z “$NOFILESGID” -o -z “$MAXSMTPD” -o -z “$LOCAL” ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi

if [ ! -f /var/qmail/control/rcpthosts ]; then
echo “No /var/qmail/control/rcpthosts!”
echo “Refusing to start SMTP listener because it’ll create an open relay”
exit 1
fi

exec /usr/local/bin/softlimit -m 9000000 \
/usr/local/bin/tcpserver -v -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD” \
-u “$QMAILDUID” -g “$NOFILESGID” 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
###########

echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming

4,Make file /var/qmail/supervise/qmail-smtpd/log/run with below given content
#########
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd ##
#########

 

5,Make file /var/qmail/supervise/qmail-pop3d/run with below given content

 

########

#!/bin/sh
exec /usr/local/bin/tcpserver -H -R -v -c100 0 110 /var/qmail/bin/qmail-popup server.domain.com \
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1

#######

 

6,make a file /var/qmail/supervise/qmail-pop3d/log/run

########     
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s100000 n20 /var/log/qmail/qmail-pop3d 2>&1

########

mkdir -p /var/log/qmail/smtpd

mkdir -p /var/log/qmail/pop3d
chown qmaill /var/log/qmail
chown qmaill /var/log/qmail/smtpd

chown qmail /var/log/qmail/pop3d
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
ln -s /var/qmail/supervise/qmail-send /service/qmail-send
ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd
ln -s /var/qmail/supervise/qmail-pop3d /service/qmail-pop3d

Install Vpopmail

——————-
groupadd vchkpw
useradd -g vchkpw vpopmail
tar -xzvf vpopmail-5.4.30.tar.gz
cd vpopmail-5.4.30
./configure
make
make install-strip

Install Dovecot

——————
useradd dovecot
tar -xzvf dovecot-1.2.11.tar.gz
cd dovecot-1.2.11
./configure –with-ioloop=IOLOOP –with-notify=NOTIFY –with-ssl=openssl –with-passwd –with-passwd-file –with-shadow –with-pam –with-checkpassword –with-vpopmail –with-static-userdb
make
make install

Cert Generation
cd /usr/local/src/build/dovecot-1.2.5/doc/
sh mkcert.sh

make file /etc/pam.d/dovecot with the below content

auth required pam_unix.so nullok
account required pam_unix.so

Get Dovecot configuration file
wget 216.67.251.5/qmail/dovecot.conf -O /usr/local/etc/dovecot.conf
id -u vpopmail #### this will print out the userID
first_valid_uid = VPOPUID #### replace VPOPUID with user Id from the above command

Get dovecot startup script
wget http://216.67.251.5/qmail/dovecot-start -O /etc/init.d/dovecot
chmod 755 /etc/init.d/dovecot
/etc/init.d/dovecot start

qmailctl stop
qmailctl start
/etc/init.d/dovecot restart
Useful Commands

##############

 

qmailctl start

qmailctl stop

qmailctl reload —> use this command after making changes in qmail configuration files

/var/qmail/bin/qmail-showctl —> check the status of qmail

 

/var/qmail/control/rcpthosts —> contains list of domain names that a qmail server is allowed to send/receive emails with out SMTP authentication.

 

/etc/tcp.smtp → relaying options

 

type the foolowing command after making changes in cp.smtp

tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp

 

To add a domain in qmail server

 

/home/vpopmail/bin/vadddomain userdomain

 

to add a mail account

 

/home/vpopmail/bin/vadduser mailaccount

 

 

To send mail

 

echo to” tester2mail@gmail.com | /var/qmail/bin/qmail-inject

 

Log files

=======

var/log/qmail/current

/var/logqmail/smtpd/current

 

Errors

=====

 

1,If you find any error with smtp-auth

 

Try to apply the patch

 

wget http://members.elysium.pl/brush/qmail-smtpd-auth/dist/qmail-smtpd-auth-0.31.tar.gz
tar -xvzf qmail-smtpd-auth-0.31.tar.gz
cd qmail-smtpd-auth-0.31
patch -d ‘qmail installing directory’ < auth.patch

 

2,while compiling qmail if you find any error related to errno.h,follow the steps

 

Replace “extern int errno;” with “#include <errno.h>” in error.h

 

Please note: you can download thefollowing script and check whether you instalation is correct.

 

==========

wget http://lifewithqmail.org/inst_check

==========

run the script from the shell if the installtion is correct, you will get a message like your installtion looks good.

Nagios installation

yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel

/usr/sbin/useradd -m nagios
passwd nagios

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

cd /usr/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

cd /usr/src
tar xzf nagios-3.2.1.tar.gz
cd nagios-3.2.1
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
vi /usr/local/nagios/etc/objects/contacts.cfg
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart

cd /usr/src
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install

chkconfig –add nagios
chkconfig nagios on
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start

See if SELinux is in Enforcing mode.
getenforce
Put SELinux into Permissive mode.
setenforce 0

File does not exist: /usr/local/nagios/share/sys_cpanel

I have installed the nagios in the server and tried to call  nagios using
the url http://serverip/nagios. But I was getting the following error

=============
File does not exist: /usr/local/nagios/share/sys_cpanel,
=============

fix : I tried to install it under the domain. I have copied the
directory /usr/local/nagios/ to the public_html of the  domain and then I
changed the ownership to that of the user.

T=remote_smtp defer (-53): retry time not reached for any host

This can be caused by multiple things, however if it happens for each email, it’s likely your exim databases are corrupt; to resolve this you should:

/usr/sbin/exim_tidydb -t 1d /var/spool/exim retry > /dev/null
/usr/sbin/exim_tidydb -t 1d /var/spool/exim reject > /dev/null
/usr/sbin/exim_tidydb -t 1d /var/spool/exim wait-remote_smtp > /dev/null

/scripts/courierup — force
/scripts/eximup –force

FTp over ssl

SFTP is only available to cpanel users and not to virtual ftp users for secure connection, but you can use FTP over SSL/TLS.

For this

1) Please enable TLS Encryption Support from WHM

Main>>  FTP Server Configuration

TLS Encryption Support>>  optional

2) On the FTP client use server type as

Host: domain or Ip

Port : 21

Server Type : FTPES -FTP over explicit TLS/SSL