配置 Squirrelmail/Roundcude Webmail Server 与 DNS, Postfix, Dovecot and MySQL on RHEL 6 /CentOS 6

Step 1: Installing and Configuring DNS 
#yum install bind* -y

# vim /etc/named.conf
 do the following changes:

 listen-on port 53 { 127.0.0.1; 192.168.48.135; };

 allow-query     { localhost; 192.168.48.0/24; };

NOTE: 192.168.48.135 is the IP address of your machine and 192.168.48.0/24 is your network address

# vim /etc/named.rfc1912.zones

zone "example.com" IN {
        type master;
        file "frd.zone";
        allow-update { none; };
};

zone "48.168.192.in-addr.arpa" IN {
        type master;
        file "rev.zone";
        allow-update { none; };
};

:wq (save and exit)

Now you need to create zone files 

# cd /var/named/
#vim frd.zone

$TTL 1D
@       IN SOA  mail.example.com. root.mail.example.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
example.com. IN  NS      mail.example.com.
mail.example.com. IN  MX      10      mail.example.com.
example.com. IN  MX      20      mail.example.com.

@       IN      A       192.168.48.135
mail    IN      A       192.168.48.135

:wq (save and exit)

#vim rev.zone
$TTL 1D
@       IN SOA  mail.example.com. root.mail.example.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
       IN  NS      mail.example.com.
135     IN  PTR     mail.example.com.
135     IN  PTR     example.com.

:wq (save and exit)

Now you need to change group ownership to named of both zones 

# chown root:named frd.zone rev.zone

# service named restart
# chkconfig named on

Now you can check your DNS is working or not

# nslookup mail.example.com

# host -t mx mail.example.com
# host -t mx example.com


Step 2: Installing and Configuring Postfix
#yum install postfix*

Now configure postfix Server 

#vim /etc/postfix/main.cf

myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.48.0/24, 127.0.0.0/8
home_mailbox = Maildir/

:wq (save and exit)

Now start/restart postfix server 

# service postfix restart
#chkconfig postfix on


Step 3: Installing and Configuring Dovecot 
#yum install dovecot

Now Configure dovecot Server 

#vim /etc/dovecot/dovecot.conf

Uncomment the following line

protocols = imap pop3 lmtp

:wq (save and exit)


# vim /etc/dovecot/conf.d/10-mail.conf

Uncomment the following line

mail_location = maildir:~/Maildir

:wq (save and exit)

# vim /etc/dovecot/conf.d/10-auth.conf

Uncomment the following lines 

disable_plaintext_auth = no
auth_mechanisms = plain login

:wq (save and exit)


# vim /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {
     #mode = 0600
     user = postfix 
     group = postfix

:wq (save and exit)


# vim /etc/dovecot/conf.d/20-imap.conf

uncomment and change the following

imap_client_workarounds = delay-newmail  tb-extra-mailbox-sep

:wq (save and exit)


#vim 20-pop3.conf

uncomment and change the following

pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls  oe-ns-eoh

:wq (save and exit)

now generate a self signed certificate for dovecot

openssl req -new -x509 -days 365 -nodes -out /etc/pki/dovecot/certs/mycert.pem -keyout /etc/pki/dovecot/private/mykey.pem

Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Delhi
Locality Name (eg, city) [Default City]:New Delhi
Organization Name (eg, company) [Default Company Ltd]:Example, Inc.
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:mail.example.com
Email Address []:[email protected]

#vim 10-ssl.conf
modify the following lines
ssl_cert   =  </etc/pki/dovecot/certs/mycert.pem
ssl_key   =  </etc/pki/dovecot/private/mykey.pem
:wq (save and exit)

Now start/restart your dovecot server 

# service dovecot restart
# chkconfig dovecot on


Step 4: Installing and Configuring Squirrelmail webmail 
#wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
#yum localinstall ~/Downloads/php-common-5.3.3-3.el6_1.3.x86_64.rpm
#yum localinstall ~/Downloads/php-mbstring-5.3.3-3.el6_1.3.x86_64.rpm

NOTE: you need to download "php-common-5.3.3-3.el6_1.3.x86_64.rpm & php-mbstring-5.3.3-3.el6_1.3.x86_64.rpm" packages from Internet. 

# yum install squirrelmail
# service httpd start
# chkconfig httpd on

Now Configure Squirrelmail
# cd /usr/share/squirrelmail/config/
# ./conf.pl

Select option 1 and set organization details.

Press R to return main menu and select option 2. Enter your domain name and select dovecot in the Sendmail or SMTP parameter.

Once you done, press S to save datas and press Q to exit.

Add the following lines in the httpd.conf file at the end.

# vim /etc/httpd/conf/httpd.conf
Alias /squirrelmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
    Options Indexes FollowSymLinks
    RewriteEngine On
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>


# service httpd restart
#chkconfig httpd on
#service iptables stop
#chkconfig iptables off
#setenforce 0
#vim /etc/sysconfig/selinux
SELINUX=permissive

:wq (save and exit)


Create Users

# useradd user1
# useradd user2
#passwd user1
#passwd user2


Open the browser from any clients. Type the following in the address bar.

http://serveripaddress/webmail

or
http://yourdomainname/webmail


Ok, if you not like "squirellmail" web interface, so you can also try "roundcube" webmail interface

to configure "roundcube" please follow these steps:

First you need to stop "squirellmail"

# vim /etc/httpd/conf/httpd.conf

remove the following line which you created for "squirellmail" 

Alias /squirrelmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
    Options Indexes FollowSymLinks
    RewriteEngine On
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>


:wq (save and exit)

Configuring roundcube webmail 
**************************

#yum install roundcube*

#yum install mysql*

#service mysqld start
#chkconfig mysqld on

Now you need to create a Database for "roundcube" 

#mysql

mysql> create database roundcube character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)


mysql> grant all privileges on roundcube.* to roundcube@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

# cd /usr/share/doc/roundcubemail-*/SQL
# mysql -u roundcube -p roundcube < mysql.initial.sql
Enter password:password

Now change the password of "roundcube" user in the following file and database name :
# vi /etc/roundcubemail/db.inc.php
$rcmail_config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcube';

:wq (save and exit)

Now Modify the following line in /etc/roundcubemail/main.inc.php to define settings:
# vim /etc/roundcubemail/main.inc.php

$rcmail_config['default_host'] = 'mail.example.com';

$rcmail_config['default_port'] = 143;

$rcmail_config['mail_domain'] = 'example.com';

$rcmail_config['smtp_server'] = '';

$rcmail_config['smtp_port'] = 25;

$rcmail_config['smtp_user'] = '%u';

$rcmail_config['smtp_pass'] = '%p';

$rcmail_config['smtp_auth_type'] = 'LOGIN';

$rcmail_config['smtp_helo_host'] = 'mail.example.com';


:wq (save and exit )


# vim /etc/httpd/conf.d/roundcubemail.conf


Allow from 127.0.0.1 192.168.48.0/24

#service httpd restart

#chkconfig httpd on


Open the web browser from any client. Type the following in the address bar.

http://serveripaddress/roundcubemail

or
http://yourdomainname/roundcubemail

你可能感兴趣的:(postfix,Dovecot,webmail,roundcube)