This is simple doc to install Mail server on RHEL 5 with courier-imap.
1. First of all install rhel5 on the system.
2. Copy the Server directory from ISO/CD to the location:
/var/www/html/
#rsync –avz /media/RHEL_5.6/Server /var/www/html/Server/
3. Create yum on the freshly created system.
# vim /etc/yum.repos.d/server.repo
[server]
name=test
baseurl=file:///var/www/html/Server/
esc :wq
4. Now install the following packages using yum.
# yum install *mysql* *php* *rpm* *http* *system-sw* -y
5. Download postfixadmin-2.2.1.1.tar.gz.
6. [root@mail~] # mkdir /var/www/html/mailadmin
7. [root@mail~] # cp Dosktop/postfixadmin-2.2.1.1.tar.gz /var/www/html/
8. [root@mail html] # tar -zxf /postfixadmin-2.2.1.1.tar.gz
9. [root@mail postfixadmin-2.2.1.1] # cp config.inc.php config.inc.php-org
10. [root@mail postfixadmin-2.2.1.1]# vi config.inc.php
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfix';
$CONF['database_name'] = 'postfix';
$CONF['admin_email'] = 'postmaster@iic.com';
$CONF['encrypt'] = 'cleartext';
// Default Aliases
// The default aliases that need to be created for all domains.
$CONF['default_aliases'] = array (
'abuse' => 'abuse@fooster.com',
'hostmaster' => 'hostmaster@iic.com',
'postmaster' => 'postmaster@iic.com',
'webmaster' => 'webmaster@iic.com'
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['vacation_domain'] = 'autoreply.change-this-toyour.domain.tld';
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'www.dell.com';
$CONF['footer_link'] = 'www.dell.com';
CONF['emailcheck_resolve_domain']='YES';
11. [root@mail html]# mv postfixadmin-2.2.1.1 mailadmin
12. [root@mail mailadmin]# service httpd restart
13. [root@mail mailadmin]# service mysqld restart
14. [root@mail html]# mysqladmin password "postfix" (set password database user)
15. [root@mail html]# mysql -u root -p
Enter password:
mysql>
mysql> CREATE DATABASE postfix;
mysql> CREATE USER 'postfix'@'localhost' IDENTIFIED BY 'postfix';
mysql> GRANT ALL PRIVILEGES ON `postfix` . * TO 'postfix'@'localhost';
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| postfix |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> quit
16. [root@mail mailadmin]# /etc/init.d/httpd restart
17. Now open web-browser and enter the following address.
18. Click on the SETUP link on the page opened.
19. [root@mail mailadmin]# vim config.inc.php
$CONF['configured'] = false;
20. Now add the account of the super user at the end and rename the setup.php file in mailadmin/.
21. [root@mail mailadmin]# mv setup.php setup.php-org
22. [root@mail mailadmin]# service httpd restart
23. Create a new user, to build the rpms.
# useradd rpmbuild
# passwd rpmbuild
24. Download the source rpm from internet and copy to home directory of user.
# cp Desktop/postfix-2.5.5-1.src.rpm /home/rpmbuild/
# chown rpmbuild.rpmbuild /home/rpmbuild/postfix-2.5.5-1.src.rpm
25. Now switch to new user and create following directory set:
# su - rpmbuild
[rpmbuild@mail ~]$ mkdir rpm
[rpmbuild@mail ~]$ mkdir rpm/SOURCES
[rpmbuild@mail ~]$ mkdir rpm/SPECS
[rpmbuild@mail ~]$ mkdir rpm/BUILD
[rpmbuild@mail ~]$ mkdir rpm/SRPMS
[rpmbuild@mail ~]$ mkdir rpm/RPMS
[rpmbuild@mail ~]$ mkdir rpm/RPMS/x86_64
[rpmbuild@mail ~]$ echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros
26. Now install the source RPM that was downloaded.
[rpmbuild@mail ~]$ rpm -ivh postfix-2.5.5-1.src.rpm
27. Now edit the postfix.spec file, that is automatically created under rpm/SPECS/
[rpmbuild@mail ~]$ cd rpm/SPECS
[rpmbuild@mail SPECS]$ ls
postfix.spec
[rpmbuild@mail SPECS]$ vim postfix.spec
%define with_mysql_redhat 1
%define with_sasl 2
%define with_vda 1
{Replace every occurrence of rhel4 with rhel5 in the file.}
28. Now build the rpm using RPMBUILD.
[rampal@mail SPECS]$ rpmbuild -ba postfix.spec
29. This will create rpms on following locations:
/home/rampal/rpm/RPMS/i386/postfix-2.5.5-1.rhel5.i386.rpm
/home/rampal/rpm/RPMS/i386/postfix-debuginfo-2.5.5-1.rhel5.i386.rpm
[rampal@mail SPECS]$ logout
30. Install these packages as root.
[root@mail i386]# rpm -Uvh postfix-2.5.5-1.rhel5.i386.rpm
[root@mail i386]# rpm -Uvh postfix-debuginfo-2.5.5-1.rhel5.i386.rpm
[root@mail i386]# postconf -m
btree
cidr
environ
hash
ldap
mysql
nis
proxy
regexp
static
unix
31. Download courier-imap-4.4.1.tar.bz2 from internet and copy this to home directory of the user. Change the user ownership of the file.
32. Also download the file courier-authlib-0.61.0.tar.bz2 and copy this file also to the home directory of the user, also change the ownership.
[root@mail Desktop]# cp courier-imap-4.1.1.tar.bz2 /home/rampal/
[root@mail Desktop]# chown rampal.rampal /home/rampal/courier-imap-4.1.1.tar.bz2
[root@mail Desktop]# cp courier-authlib-0.58.tar.bz2 /home/rampal/
[root@mail Desktop]# chown rampal.rampal /home/rampal/courier-authlib-0.58.tar.bz2
33. Now switch to user and build the rpm using rpmbuild.
[root@mail Desktop]# su - rampal
[rampal@mail ~]$ rpmbuild -ta courier-authlib-0.58.tar.bz2
[rampal@mail~]$ logout
34. Install the dependencies of the rpmbuild as the root user using yum.
[root@mail Desktop]# yum install *libtool*
[root@mail Desktop]# yum install *postgresql-devel*
[root@mail Desktop]# yum install *gdbm-devel*
[root@mail Desktop]# yum install *pam-devel
[root@mail Desktop]# yum install *expect*
[root@mail Desktop]# yum install *gcc-c++*
[root@mail Desktop]# su - rampal
[rampal@mail ~]$ rpmbuild -ta courier-authlib-0.58.tar.bz2
[rampal@mail~]$ logout
35. Now packages are created on the following location. Install these packages.
[root@mail ~]$ cd /home/rampal/rpm/RPMS/i386/
[root@mail i386]$ rpm -ivh courier-authlib-0.58-1.5Server.i386.rpm
[root@mail i368]$ rpm -ivh courier-authlib-debuginfo-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-devel-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-ldap-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-mysql-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-pgsql-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-pipe-0.58-1.5Server.i386.rpm
[root@mail i386]$ rpm -ivh courier-authlib-userdb-0.58-1.5Server.i386.rpm
[root@mail ~]# su - rampal
36. Now untar the courier-imap file , make following changes in the file and copy it to rpm/SPEC/ location.
[rampal@mail ~]$ tar -jxvf courier-imap-4.1.1.tar.bz2
[rampal@mail ~]$ cd courier-imap-4.1.1
[rampal@mail courier-imap-4.1.1]$ cp courier-imap.spec courier-imap.spec-org
[rampal@mail courier-imap-4.1.1]$ vi courier-imap.spec
BuildPreReq: rpm >= 3.0.5 /usr/bin/sed openldap2 openldap2-devel
%else
BuildPreReq: rpm >= 4.0.2 sed openldap-devel openldap-servers
%endif
{remove every thing except these in the above lines in the file}
37. Now run the rpmbuild command to build the rpm packages. If it shows some dependencies, install those dependencies using yum as root. When the command completes building packages, install those packages as root.
[rampal@mail] courier-imap-4.1.1]$ cp courier-imap.spec /home/rampal/rpm/SPECS/
[rampal@mail]courier-imap-4.1.1]$ cp courier-imap-4.1.1.tar.bz2 /home/rampal/rpm/SOURCES
[rampal@mail~]$ cd rpm/SPECS/
[rampal@mail] SPECS]$ rpmbuild -ba courier-imap.spec
dependencies: openldap* rpm
[ramapl@mail~] logout
[root@mail~]# yum install openldap*
[root@mail~]# su - rampal
[rampal@mail] SPECS]$ rpmbuild -ba courier-imap.spec
[rampal@mail] SPECS]$ logout
[root@mail ~] cd /home/rampal/rpm/RPMS/i386/
[root@mail i386]# rpm -ivh courier-imap-4.1.1-1.5Server.i386.rpm
[root@mail i386]# rpm -ivh courier-imap-debuginfo-4.1.1-1.5Server.i386.rpm
38. Now add a virtual user with uid=1001 and gid=1001.
[root@mail ~]# useradd virtual ( useradd only virtual uid-1001 gid-1001)
[root@mail ~]# passwd virtual
virtual:x:1001:1001::/home/virtual:/bin/bash
[root@mail ~]# vi /etc/passwd
virtual:x:1001:
[root@mail ~]# vi /etc/group
[root@mail ~]# chmod -R 777 /home/virtual/
[root@mail ~]# chown virtual.virtual /home/virtual
39. Now copy the main.cf file to a temp file and make following changes in the file.
[root@mail postfix]# cp /etc/postfix/main.cf main.cf_org
[root@mail postfix]# vi /etc/postfix/main.cf
Add these line in the end of file :
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:1001
virtual_mailbox_base = /home/virtual
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 1001
virtual_transport = virtual
virtual_uid_maps = static:1001
#Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf
mynetworks = 192.168.0.0/24, 127.0.0.0/8
[root@mail postfix]# postmap hash:/etc/postfix/aliases
[root@mail postfix]# service postfix restart
40. Add following files in the /etc/postfix directory:
[root@mail ~]# vi /etc/postfix/mysql_relay_domains_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
[root@mail ~]# vi /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT quota FROM mailbox WHERE username='%s'
[root@mail ~]# vi /etc/postfix/mysql_virtual_alias_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address='%s' AND active = 1
[root@mail ~]# vi /etc/postfix/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
# [root@mail~]# vi /etc/postfix/mysql_virtual_domains_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s'
#optional query to use when relaying for backup MX
#query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '0' and active = '1'
41. Also make changes in following files:
/etc/authlib/authmysqlrc:
[root@mail ~]# cd /etc/authlib/
[root@mail authlib]# cp authmysqlrc authmysqlrc_org
[root@mail authlib]# vi authmysqlrc ( This file authentusen file mysql and database
MYSQL_SERVER localhost
MYSQL_USERNAME postfix
MYSQL_PASSWORD postfix
MYSQL_PORT 0
MYSQL_OPT 0
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
#MYSQL_CRYPT_PWFILED crypt
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 1001
MYSQL_GID_FIELD 1001
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD '/home/virtual'
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
[root@mail ~]# vim /etc/authlib/authdaemonrc
authmodulelist=" authmysql "
[root@mail ~]# /etc/init.d/courier-authlib restart
[root@mail ~]# /etc/init.d/courier-imap restart
[root@mail ~]# /etc/init.d/httpd restart
42. Open web-browser and open following url:
http://localhost/mailadmin/
login email = user name@domain name
password= ******
43. Now you can add new mailbox, domains and send mails to user from your server.
No comments:
Post a Comment