Install and Configure PostfixAdmin
It is needed to install httpd,mysql and php for PostfixAdmin.
#
yum install mysql-server php php-mysql php-imap php-mbstring -yOnce all the above packages were installed, make sure httpd and mysqld services are running.
It is needed to create db, db user for PostfixAdmin. Here i am using the following db details. Change the following details as you prefered.
DB: postfixDB User: postfixPassword: postfixThe following command will create the DB for postfix. You can also execute these queries directly in the mysql console.
#
mysql -e "CREATE DATABASE postfix;"#
mysql -e "CREATE USER postfix@localhost IDENTIFIED BY 'postfix';"#
mysql -e "GRANT ALL PRIVILEGES ON postfix.* TO postfix;"To download and fix permissions of PostfixAdmin.
#
yum install -y subversion#
cd /usr/local/The following command will download latest PostfixAdmin package. The '
svn' command is available in the package '
subversion' which we have already installed.
#
svn co http://svn.code.sf.net/p/postfixadmin/code/trunk postfixadmin#
chmod 777 /usr/local/postfixadmin/templates_cEdit the postfixadmin configuration file,
/usr/local/postfixadmin/config.inc.php and update the following lines as shown below.
$CONF['configured'] = true; $CONF['postfix_admin_url'] = '/postfixadmin'; $CONF['database_type'] = 'mysqli'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'postfix'; $CONF['database_name'] = 'postfix'; $CONF['domain_path'] = 'YES'; $CONF['domain_in_mailbox'] = 'NO'; $CONF['encrypt'] = 'cleartext'; $CONF['emailcheck_resolve_domain] = 'NO';Once you have done the above changes, you have to create the following entry in httpd.conf to access postfixadmin via browser.
Alias /postfixadmin /usr/local/postfixadminRestart httpd service
#
/etc/init.d/httpd restartNow you can access postfixadmin using the following url. Setup the postfixadmin as per the given instructon in there.
http://<IP>/postfixadmin/setup.phpOnce the setup is completed successsfully, it is time to install and configure postfix service.
Install and Configure Postfix
There will be a postfix package initiallly in the default installation. Here i am removing it and i am using Postfix-2.9.7. Depending upon the version and architecture, select the postfix version from http://packages.oostergo.net/
To download and install postfix
#
rpm -Uvh http://packages.oostergo.net/postfix-2.9/el6/postfix-2.9.7-1.el6.x86_64.rpmThe following commands will made the changes in /etc/postfix/main.cf. We have to setup it initially.
To set postfix's hostname.
#
postconf -e "myhostname = mail.sudosu.in"#
postconf -e "mydomain = sudosu.in"#
postconf -e "myorigin = "'$'"mydomain"inet_interfaces initially set for listening from localhost only. We need to change it to listen on all interfaces.
#
postconf -e "inet_interfaces = all"#
postconf -e "inet_protocols = ipv4"#
postconf -e "home_mailbox = Maildir/"#
postconf -e "smtpd_banner = "'$'"myhostname ESMTP"To limit an email size 10M
#
postconf -e "message_size_limit = 10485760"To limit mailbox 1G
#
postconf -e "mailbox_size_limit = 1073741824"#
postconf -e "mydestination = "'$'"myhostname, localhost."'$'"mydomain, localhost"Create a user 'vmail' for creating virtual users(mail boxes)
#
groupadd -g 5000 vmail#
useradd -g vmail -u 5000 vmail -d /home/vmail -mIt is needed to create some configuration files to map the domains and mailboxs from mysql. Here are those configuration files.
#
cat /etc/postfix/mysql-domains.cfhosts = localhostuser = postfixpassword = postfixdbname = postfixtable = domainselect_field = domainwhere_field = domainadditional_conditions = and backupmx = '0' and active = '1'#
cat /etc/postfix/mysql-users.cfhosts = localhostuser = postfixpassword = postfixdbname = postfixtable = mailboxselect_field = maildirwhere_field = usernameadditional_conditions = and active = '1'result_format = %sMaildir/#
cat /etc/postfix/mysql-aliases.cfhosts = localhostuser = postfixpassword = postfixdbname = postfixtable = aliasselect_field = gotowhere_field = addressadditional_conditions = and active = '1'The above configuration files and '
vmail' user need to map with postfix.
#
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domains.cf"#
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-users.cf"#
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-aliases.cf"#
postconf -e "virtual_mailbox_base = /home/vmail"#
postconf -e "virtual_uid_maps = static:5000"#
postconf -e "virtual_gid_maps = static:5000"Restart or reload postfix
#
postfix reloador
#
/etc/init.d/postfix restartInstall and Configure Dovecot
#
yum install dovecot dovecot-mysql -yCheck if postfix support dovecot authentication. Check if dovecot is listed in the result.
#
postconf -acyrusdovecotPostfix configuration for Dovecot SMTP-Auth settings
#
postconf -e "smtpd_sasl_local_domain = $myhostname"#
postconf -e "smtpd_sasl_auth_enable = yes"#
postconf -e "broken_sasl_auth_clients = yes"#
postconf -e "smtpd_sasl_type = dovecot"#
postconf -e "smtpd_sasl_path = private/auth"#
postconf -e "smtpd_sasl_security_options = noanonymous"#
postconf -e "smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, permit"#
postconf -e "smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"Create dovecot-mysql.conf file as follows.
[root@server ~]#
cat /etc/dovecot/dovecot-mysql.confdriver = mysqlconnect = host=localhost dbname=postfix user=postfix password=postfixdefault_pass_scheme = PLAINpassword_query = SELECT password FROM mailbox WHERE username = '%u' AND active = '1'Create dovecot.conf file as follows.
[root@server ~]#
cat /etc/dovecot/dovecot.confauth_debug = yesauth_mechanisms = plain loginauth_username_format = %Luauth_verbose = yesmbox_write_locks = fcntlpassdb { driver = pam}passdb { driver = pam}passdb { args = /etc/dovecot/dovecot-mysql.conf driver = sql}service auth { unix_listener /var/spool/postfix/private/auth { group = postfix mode = 0660 user = postfix } user = root}ssl_cert = </etc/pki/dovecot/certs/dovecot.pemssl_key = </etc/pki/dovecot/private/dovecot.pemuserdb { driver = passwd}userdb { driver = passwd}userdb { args = uid=5000 gid=5000 home=/home/vmail/%d/%n driver = static}Once the above settings has been completed, restart postfix and dovecot and verify the installation using telnet.
#
/etc/init.d/dovecot restart#
/etc/init.d/postfix restartInstall and Configure RoundCubeMail
Download RoundCubeMail codeYou can install latest roudcube using git.
#
yum install git -y#
cd /usr/local#
git clone git://github.com/roundcube/roundcubemail.gitYou can find a directory named 'roundcubemail' after the above step.
Install Necessary PackagesInstall the following packages for the working if roundcube.
#
yum install httpd php php-common php-json php-xml php-mbstring php-imap php-pear php-mysql mysql mysql-serverYou have to add the following entries in the httpd.conf to access roundcube via browser.
Alias /roundcube /usr/local/roundcubemailRestart httpd service.
#
/etc/init.d/httpd restartNecessary DataBase setupHere i am using the following details for the DB setup. You can change it as you like.
DB: roundcubemailDB User: roundcubemailPassword: roundcube_pass#
mysql -e "CREATE DATABASE roundcubemail;"# mysql -e "GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'roundcube_pass';"# mysql roundcubemail < /usr/local/roundcubemail/SQL/mysql.initial.sqlYou can now access roundcube using the following url. You have to follow the instruction to complete the installation.
http://<IP>/roundcube/installer/Once the installation completed,
http://<IP>/roundcube allow you to login to the mail accounts.
Reference:
http://www.server-world.info/en/