Install dovecot using openldap for authentication on freebsd.

1 ) Install dovecot with LDAP option.

# cd /usr/ports/mail/dovecot2

# make config

Select LDAP protocol support as below.

dovecot01

 

# make install clean

2) Configure dovecot authentication using Openldap.

# mkdir /usr/local/etc/dovecot/conf.d

# vi /usr/local/etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

listen = *

mail_plugins = fts fts_solr

!include conf.d/*.conf

 

 

# vi /usr/local/etc/dovecot/dovecot-ldap.conf.ext

hosts = 10.0.0.1

dn = cn=admin,ou=users,dc=nganthao,dc=com

dnpass = 123

tls = no

auth_bind = yes

auth_bind_userdn = cn=admin,ou=users,dc=nganthao,dc=com

ldap_version = 3

base = o=hosting, dc=nganthao,dc=com

deref = never

scope = subtree

user_attrs = homeDirectory=home, uidNumber=uid, gidNumber=gid, mailLocation=mailbox

user_filter = (&(objectClass=mAccount)(mail=%u))

pass_attrs = userPassword

pass_filter = (&(objectClass=mAccount)(mail=%u))

default_pass_scheme = CRYPT

 

# vi /usr/local/etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no

auth_mechanisms = plain login

!include auth-ldap.conf.ext

# vi /usr/local/etc/dovecot/conf.d/10-logging.conf

log_path = syslog

syslog_facility = mail

auth_debug = yes

# vi /usr/local/etc/dovecot/conf.d/10-mail.conf

namespace inbox {

inbox = yes

}

mail_uid = vmail

mail_gid = vmail

 

# vi /usr/local/etc/dovecot/conf.d/10-master.conf

service imap-login {

inet_listener imap {

port = 143

}

}

service pop3-login {

inet_listener pop3 {

port = 110

}

}

service auth {

unix_listener auth-userdb {

mode = 0600

user = vmail

group = vmail

}

}

# vi /usr/local/etc/dovecot/conf.d/10-ssl.conf

ssl = no

 

# vi /usr/local/etc/dovecot/conf.d/15-mailboxes.conf

namespace inbox {

mailbox Drafts {

special_use = \Drafts

}

mailbox Junk {

special_use = \Junk

}

mailbox Trash {

special_use = \Trash

}

 

mailbox Sent {

special_use = \Sent

}

mailbox “Sent Messages” {

special_use = \Sent

}

}

# vi /usr/local/etc/dovecot/conf.d/90-plugin.conf

plugin {

fts = solr

fts_solr = break-imap-search url=http://localhost:8983/solr/

fts_autoindex = yes

}

# vi /usr/local/etc/dovecot/conf.d/auth-ldap.conf.ext

passdb {

driver = ldap

args = /usr/local/etc/dovecot/dovecot-ldap.conf.ext

}

 

userdb {

driver = ldap

args = /usr/local/etc/dovecot/dovecot-ldap.conf.ext

}

3) Create Maildir folder.

# mkdir /home/vmail

# mkdir /home/vmail/hosting

# mkdir /home/vmail/hosting/nganthao.com

# mkdir /home/vmail/hosting/nganthao.com/nganthao

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Deleted Items

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Drafts

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Trash

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Spam

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Sent Items

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Sent

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.Junk E-mail

# maildrop-maildirmake /home/vmail/hosting/nganthao.com/nganthao/Maildir/.INBOX

4) Start dovecot.

# echo dovecot_enable=”YES” >> /etc/rc.conf

# /usr/local/etc/rc.d/dovecot start

 

5) Index mailbox

# doveadm fts rescan -u nmtam@nganthao.com

# doveadm index -u nmtam INBOX

 

6) Convert from Courier to Dovecot

# fetch http://www.dovecot.org/tools/courier-dovecot-migrate.pl

# ./courier-dovecot-migrate.pl –to-dovecot –recursive /home

7) Install Apache24

# cd /usr/ports/www/apache24

# make install clean

8) Install PHP

# cd /usr/ports/lang/php56

# make install clean

9) Install PHP Extension.

# cd /usr/ports/lang/php56-extensions

# make install clean

10) Install mod_php56

# cd /usr/ports/www/mod_php56

# vi /usr/local/etc/apache24/Includes/php.conf

<FilesMatch “\.php$”>

SetHandler application/x-httpd-php

</FilesMatch>

<FilesMatch “\.phps$”>

SetHandler application/x-httpd-php-source

</FilesMatch>

11) Configure Virtual host

# vi /usr/local/etc/apache24/extra/httpd-vhosts.conf

<VirtualHost *:80>

DocumentRoot   /usr/local/www/roundcube

ServerName      roundcube.nganthao.com

DirectoryIndex index.php

<Directory “/usr/local/www/roundcube”>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

 

ErrorLog /var/log/roundcube-error_log

CustomLog /var/log/roundcube-access_log common

</VirtualHost>

 

12) Install mysql56 server

# cd /usr/port/database/mysql56-server

# make install clean

13) Install roundcube

# cd /usr/ports/mail/roundcube

# make install clean

 

 

 

 

 

 

 

 

 

Be the first to comment

Leave a Reply