The Perfect Server - CentOS 5.2 [ISPConfig 3]-3

10 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.

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 (compileuser in this example) and give him a password:

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

We will need the sudo command later on so that the user compileuser can compile and install the rpm packages. But first, we must allow compileuser 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 compileuser just below that line:

[...]
root    ALL=(ALL)       ALL
compileuser   ALL=(ALL)       ALL
[...]

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

su compileuser

Next we create our build environment:

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

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

Now we download the source files from http://www.courier-mta.org/download.php:

cd /tmp
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.62.1.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.4.1.tar.bz2
wget http://prdownloads.sourceforge.net/courier/maildrop-2.0.4.tar.bz2

Now (still in /tmp) we can build courier-authlib:

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

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

cd $HOME/rpm/RPMS/i386

The command

ls -l

shows you the available rpm packages:

[compileuser@server1 i386]$ ls -l
total 584
-rw-r--r-- 1 root root 140978 Feb 26 03:00 courier-authlib-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root 309196 Feb 26 03:00 courier-authlib-debuginfo-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root  34672 Feb 26 03:00 courier-authlib-devel-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root  17855 Feb 26 03:00 courier-authlib-ldap-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root  14048 Feb 26 03:00 courier-authlib-mysql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root  13214 Feb 26 03:00 courier-authlib-pgsql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root   8175 Feb 26 03:00 courier-authlib-pipe-0.62.1-1.i386.rpm
-rw-r--r-- 1 root root  35927 Feb 26 03:00 courier-authlib-userdb-0.62.1-1.i386.rpm
[compileuser@server1 i386]$

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

sudo rpm -ivh courier-authlib-0.62.1-1.i386.rpm courier-authlib-mysql-0.62.1-1.i386.rpm courier-authlib-devel-0.62.1-1.i386.rpm

Now we go back to the /tmp directory and run rpmbuild again, this time without sudo, otherwise the compilation will fail because it was run as root:

Click here to find out more!
 

cd /tmp
rpmbuild -ta courier-imap-4.4.1.tar.bz2

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

cd $HOME/rpm/RPMS/i386

The command

ls -l

shows you the available rpm packages:

[compileuser@server1 i386]$ ls -l
total 1868
-rw-r--r-- 1 root        root        140978 Feb 26 03:00 courier-authlib-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root        309196 Feb 26 03:00 courier-authlib-debuginfo-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         34672 Feb 26 03:00 courier-authlib-devel-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         17855 Feb 26 03:00 courier-authlib-ldap-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         14048 Feb 26 03:00 courier-authlib-mysql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         13214 Feb 26 03:00 courier-authlib-pgsql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root          8175 Feb 26 03:00 courier-authlib-pipe-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         35927 Feb 26 03:00 courier-authlib-userdb-0.62.1-1.i386.rpm
-rw-rw-r-- 1 compileuser compileuser 395137 Feb 26 03:13 courier-imap-4.4.1-1.i386.rpm
-rw-rw-r-- 1 compileuser compileuser 906775 Feb 26 03:13 courier-imap-debuginfo-4.4.1-1.i386.rpm
[compileuser@server1 i386]$

You can install courier-imap like this:

sudo rpm -ivh courier-imap-4.4.1-1.i386.rpm

Now we go back to the /tmp directory and run rpmbuild again, this time to build a maildrop package:

cd /tmp
sudo rpmbuild -ta maildrop-2.0.4.tar.bz2

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

cd $HOME/rpm/RPMS/i386

The command

ls -l

shows you the available rpm packages:

[compileuser@server1 i386]$ ls -l
total 3096
-rw-r--r-- 1 root        root        140978 Feb 26 03:00 courier-authlib-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root        309196 Feb 26 03:00 courier-authlib-debuginfo-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         34672 Feb 26 03:00 courier-authlib-devel-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         17855 Feb 26 03:00 courier-authlib-ldap-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         14048 Feb 26 03:00 courier-authlib-mysql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         13214 Feb 26 03:00 courier-authlib-pgsql-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root          8175 Feb 26 03:00 courier-authlib-pipe-0.62.1-1.i386.rpm
-rw-r--r-- 1 root        root         35927 Feb 26 03:00 courier-authlib-userdb-0.62.1-1.i386.rpm
-rw-rw-r-- 1 compileuser compileuser 395137 Feb 26 03:13 courier-imap-4.4.1-1.i386.rpm
-rw-rw-r-- 1 compileuser compileuser 906775 Feb 26 03:13 courier-imap-debuginfo-4.4.1-1.i386.rpm
-rw-r--r-- 1 root        root        303104 Feb 26 03:25 maildrop-2.0.4-1.i386.rpm
-rw-r--r-- 1 root        root        739326 Feb 26 03:25 maildrop-debuginfo-2.0.4-1.i386.rpm
-rw-r--r-- 1 root        root        134387 Feb 26 03:25 maildrop-devel-2.0.4-1.i386.rpm
-rw-r--r-- 1 root        root         58837 Feb 26 03:25 maildrop-man-2.0.4-1.i386.rpm
[compileuser@server1 i386]$

You can now install maildrop like this:

sudo rpm -ivh maildrop-2.0.4-1.i386.rpm

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

exit

 

11 Apply Quota Patch To Postfix

We have to get the Postfix source rpm, patch it with the quota patch, build a new Postfix rpm package and install it.

cd /usr/src
wget http://ftp-stud.fht-esslingen.de/pub/Mirrors/centos/5.2/os/SRPMS/postfix-2.3.3-2.src.rpm
rpm -ivh postfix-2.3.3-2.src.rpm

The last command will show some warnings that you can ignore:

warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root

cd /usr/src/redhat/SOURCES
wget http://vda.sourceforge.net/VDA/postfix-2.3.3-vda.patch.gz
gunzip postfix-2.3.3-vda.patch.gz
cd /usr/src/redhat/SPECS/

Now we must edit the file postfix.spec:

vi postfix.spec

Change %define MYSQL 0 to %define MYSQL 1, add Patch0: postfix-2.3.3-vda.patch to the # Patches stanza, and finally add %patch0 -p1 -b .vda to the %setup -q stanza:

[...]
%define MYSQL 1
[...]
# Patches

Patch0: postfix-2.3.3-vda.patch
Patch1: postfix-2.1.1-config.patch
Patch3: postfix-alternatives.patch
Patch6: postfix-2.1.1-obsolete.patch
Patch7: postfix-2.1.5-aliases.patch
Patch8: postfix-large-fs.patch
Patch9: postfix-2.2.5-cyrus.patch
[...]
%setup -q
# Apply obligatory patches
%patch0 -p1 -b .vda
%patch1 -p1 -b .config
%patch3 -p1 -b .alternatives
%patch6 -p1 -b .obsolete
%patch7 -p1 -b .aliases
%patch8 -p1 -b .large-fs
%patch9 -p1 -b .cyrus
[...]

Then we build our new Postfix rpm package with quota and MySQL support:

rpmbuild -ba postfix.spec

Our Postfix rpm package is created in /usr/src/redhat/RPMS/i386 (/usr/src/redhat/RPMS/x86_64 if you are on an x86_64 system), so we go there:

cd /usr/src/redhat/RPMS/i386

The command

ls -l

shows you the available packages:

[root@server1 i386]# ls -l
total 11292
-rw-r--r-- 1 root root 3820393 Feb 27 18:16 postfix-2.3.3-2.i386.rpm
-rw-r--r-- 1 root root 7666204 Feb 27 18:16 postfix-debuginfo-2.3.3-2.i386.rpm
-rw-r--r-- 1 root root   50539 Feb 27 18:16 postfix-pflogsumm-2.3.3-2.i386.rpm
[root@server1 i386]#

Pick the Postfix package and install it like this:

rpm -ivh postfix-2.3.3-2.i386.rpm

Then turn off Sendmail and start Postfix, saslauthd, and courier-authlib:

chkconfig --levels 235 courier-authlib on
/etc/init.d/courier-authlib start

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

 

12 Configure Courier

Now we create the system startup links for courier-imap:

chkconfig --levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

When courier-imap is started for the first time, it automatically creates the certificate files /usr/lib/courier-imap/share/imapd.pem and /usr/lib/courier-imap/share/pop3d.pem from the /usr/lib/courier-imap/etc/imapd.cnf and /usr/lib/courier-imap/etc/pop3d.cnf files. Because the .cnf files contain the line CN=localhost, but our server is named server1.example.com, the certificates might cause problems when you use TLS connections. To solve this, we delete both certificates...

cd /usr/lib/courier-imap/share/
rm -f imapd.pem
rm -f pop3d.pem

... and replace the CN=localhost lines in /usr/lib/courier-imap/etc/imapd.cnf and /usr/lib/courier-imap/etc/pop3d.cnf with CN=server1.example.com:

vi /usr/lib/courier-imap/etc/imapd.cnf

[...]
CN=server1.example.com
[...]

vi /usr/lib/courier-imap/etc/pop3d.cnf

[...]
CN=server1.example.com
[...]

Then we recreate both certificates...

./mkimapdcert
./mkpop3dcert

... and restart courier-authlib and courier-imap:

/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

 

13 Install Getmail

Getmail can be installed as follows:

yum install getmail

你可能感兴趣的:(centos,server,the,perfect,ispconfig)