The Perfect Server - CentOS 6.3 x86_64 (nginx, Courier, ISPConfig 3) - Page 4

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2012-07-29 19:51. ::

11 Install Courier-IMAP, Courier-Authlib, And Maildrop

Unfortunately there are no rpm packages for Courier-IMAP, Courier-Authlib, and Maildrop, therefore we have to build them ourselves.

First remove Dovecot:

yum remove dovecot dovecot-mysql

Then install the prerequisites that we need to build Courier rpm packages:

yum install rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel libidn-devel

RPM packages should not be built as root; courier-imap will even refuse to compile if it detects that the compilation is run as the root user. Therefore we create a normal user account now (falko in this example) and give him a password:

useradd -m -s /bin/bash falko
passwd falko

We will need the sudo command later on so that the user falko can compile and install the rpm packages. But first, we must allow falko to run all commands using sudo:

Run

visudo

In the file that opens there's a line root ALL=(ALL) ALL. Add a similar line for falko just below that line:

[...]
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
falko   ALL=(ALL)       ALL
[...]

Now we are ready to build our rpm package. First become the user falko:

su falko

Next we create our build environment:

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/BUILDROOT
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
mkdir $HOME/rpm/RPMS/x86_64

echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

Now we create a downloads directory and download the source files from http://www.courier-mta.org/download.php:

mkdir $HOME/downloads
cd $HOME/downloads

wget --no-check-certificate https://sourceforge.net/projects/courier/files/authlib/0.64.0/courier-authlib-0.64.0.tar.bz2/download
wget --no-check-certificate https://sourceforge.net/projects/courier/files/imap/4.9.3/courier-imap-4.9.3.tar.bz2/download
wget --no-check-certificate https://sourceforge.net/projects/courier/files/maildrop/2.5.5/maildrop-2.5.5.tar.bz2/download

(Please note that I use Courier-IMAP 4.9.3 here instead of the newer 4.10.0 because 4.10.0 depends on systemctl which exists for Fedora, but not for CentOS.)

Now (still in $HOME/downloads) we can build courier-authlib:

sudo rpmbuild -ta courier-authlib-0.64.0.tar.bz2

After the build process, the rpm packages can be found in /root/rpmbuild/RPMS/x86_64 (/root/rpmbuild/RPMS/i686 if you are on an i686 system). The command

sudo ls -l /root/rpmbuild/RPMS/x86_64

shows you the available rpm packages:

[falko@server1 downloads]$ sudo ls -l /root/rpmbuild/RPMS/x86_64
total 524
-rw-r--r-- 1 root root 125304 Jul 11 19:09 courier-authlib-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 263700 Jul 11 19:09 courier-authlib-debuginfo-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  37804 Jul 11 19:09 courier-authlib-devel-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  17264 Jul 11 19:09 courier-authlib-ldap-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13864 Jul 11 19:09 courier-authlib-mysql-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13004 Jul 11 19:09 courier-authlib-pgsql-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root   8240 Jul 11 19:09 courier-authlib-pipe-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  34644 Jul 11 19:09 courier-authlib-userdb-0.64.0-1.el6.x86_64.rpm
[falko@server1 downloads]$

Select the ones you want to install, and install them like this:

sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-0.64.0-1.el6.x86_64.rpm /root/rpmbuild/RPMS/x86_64/courier-authlib-mysql-0.64.0-1.el6.x86_64.rpm /root/rpmbuild/RPMS/x86_64/courier-authlib-devel-0.64.0-1.el6.x86_64.rpm

Now we go back to our downloads directory:

cd $HOME/downloads

Run the following commands to create required directories/change directory permissions (because otherwise the build process for Courier-Imap will fail):

sudo mkdir -p /var/cache/ccache/tmp
sudo chmod o+rwx /var/cache/ccache/
sudo chmod 777 /var/cache/ccache/tmp

Now run rpmbuild again, this time without sudo, otherwise the compilation will fail because it was run as root:

rpmbuild -ta courier-imap-4.9.3.tar.bz2

After the build process, the rpm packages can be found in $HOME/rpm/RPMS/x86_64 ($HOME/rpm/RPMS/i686 if you are on an i686 system):

cd $HOME/rpm/RPMS/x86_64

The command

ls -l

shows you the available rpm packages:

[falko@server1 x86_64]$ ls -l
total 1108
-rw-rw-r-- 1 falko falko 331736 Jul 12 15:17 courier-imap-4.9.3-1.x86_64.rpm
-rw-rw-r-- 1 falko falko 800664 Jul 12 15:17 courier-imap-debuginfo-4.9.3-1.x86_64.rpm
[falko@server1 x86_64]$

You can install courier-imap like this:

sudo rpm -ivh courier-imap-4.9.3-1.x86_64.rpm

Now we go back to our downloads directory:

cd $HOME/downloads

and run rpmbuild again, this time to build a maildrop package:

sudo rpmbuild -ta maildrop-2.5.5.tar.bz2

After the build process, the rpm packages can be found in /root/rpmbuild/RPMS/x86_64 (/root/rpmbuild/RPMS/i686 if you are on an i686 system). The command

sudo ls -l /root/rpmbuild/RPMS/x86_64

shows you the available rpm packages:

[falko@server1 downloads]$ sudo ls -l /root/rpmbuild/RPMS/x86_64
total 1708
-rw-r--r-- 1 root root 125316 Jul 12 15:08 courier-authlib-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 263720 Jul 12 15:08 courier-authlib-debuginfo-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  37804 Jul 12 15:08 courier-authlib-devel-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  17264 Jul 12 15:08 courier-authlib-ldap-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13864 Jul 12 15:08 courier-authlib-mysql-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  13008 Jul 12 15:08 courier-authlib-pgsql-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root   8244 Jul 12 15:08 courier-authlib-pipe-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  34648 Jul 12 15:08 courier-authlib-userdb-0.64.0-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 286476 Jul 12 15:25 maildrop-2.5.5-1.x86_64.rpm
-rw-r--r-- 1 root root 751216 Jul 12 15:25 maildrop-debuginfo-2.5.5-1.x86_64.rpm
-rw-r--r-- 1 root root 102096 Jul 12 15:25 maildrop-devel-2.5.5-1.x86_64.rpm
-rw-r--r-- 1 root root  65928 Jul 12 15:25 maildrop-man-2.5.5-1.x86_64.rpm
[falko@server1 downloads]$

You can now install maildrop like this:

sudo rpm -ivh /root/rpmbuild/RPMS/x86_64/maildrop-2.5.5-1.x86_64.rpm

After you have compiled and installed all needed packages, you can become root again by typing

exit

Now start Courier-IMAP/-POP3 as follows:

/etc/init.d/courier-imap start

 

12 Install Postfix

Postfix can be installed as follows:

yum install postfix

Then turn off Sendmail and start Postfix:

chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
/etc/init.d/sendmail stop
/etc/init.d/postfix restart

 

13 Install Getmail

Getmail can be installed as follows:

yum install getmail

 

14 Install Amavisd-new, SpamAssassin And ClamAV

To install amavisd-new, spamassassin and clamav, run the following command:

yum install amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql

Then we start freshclam, amavisd, and clamd.amavisd:

sa-update
chkconfig --levels 235 amavisd on
chkconfig --del clamd
chkconfig --levels 235 clamd.amavisd on
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd.amavisd start


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by teraxit (registered user) on Wed, 2012-08-01 12:03.
If you get mail error (which I got) saying "postfix/smtpd[5229]: fatal: no SASL authentication mechanisms", use these commands to fix it:
 
yum install cyrus-sasl-plain
service saslauthd stop
service postfix stop
service saslauthd start
service postfix start
 
And also, should you wish to keep an archive of all email on your server, you can use the script that I customized for ISPconfig, but with little modifications it should work on other systems using Courier-IMAP too. Instructions how to install it can be found here: http://hosting.bluewhaleseo.com/kb/using-ispconfig/archiving-email-postfix-courier-imap-ispconfig
Submitted by Anonymous (not registered) on Mon, 2012-10-08 13:12.

thanks teraxit your trick corrected my postfix.