jazznuno

Archive for March 2011

Setup Postfix Mail Server On CentOS

with 2 comments

# yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gsspi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot

Loaded plugins: fastestmirror
Determining fastest mirrors

lokal                                                                                                                                                               | 2.1 kB     00:00

Setting up Install Process<!–more–>
Package cyrus-sasl-2.1.22-5.el5.i386 already installed and latest version
No package cyrus-sasl-gsspi available.
Package cyrus-sasl-md5-2.1.22-5.el5.i386 already installed and latest version
Package cyrus-sasl-plain-2.1.22-5.el5.i386 already installed and latest version
Resolving Dependencies
—&gt; Running transaction check
—&gt; Package cyrus-sasl-devel.i386 0:2.1.22-5.el5 set to be updated
—&gt; Package dovecot.i386 0:1.0.7-7.el5 set to be updated
—&gt; Processing Dependency: libmysqlclient.so.15 for package: dovecot
—&gt; Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: dovecot
—&gt; Package postfix.i386 2:2.3.3-2.1.el5_2 set to be updated
—&gt; Running transaction check
—&gt; Package mysql.i386 0:5.0.77-3.el5 set to be updated
—&gt; Processing Dependency: perl(DBI) for package: mysql
—&gt; Running transaction check
—&gt; Package perl-DBI.i386 0:1.52-2.el5 set to be updated
—&gt; Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package                                             Arch                                Version                                      Repository                                 Size
=========================================================================================

Installing:
cyrus-sasl-devel             i386      2.1.22-5.el5           lokal           1.4 M
dovecot                      i386      1.0.7-7.el5            lokal           1.6 M
postfix                      i386      2:2.3.3-2.1.el5_2      lokal           3.6 M
Installing for dependencies:
mysql                        i386      5.0.77-3.el5           lokal           4.8 M
perl-DBI                     i386      1.52-2.el5             lokal           600 k
Transaction Summary
=========================================================================================
Install      5 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 12 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): perl-DBI-1.52-2.el5.i386.rpm                                    | 600 kB     00:00
(2/5): cyrus-sasl-devel-2.1.22-5.el5.i386.rpm                          | 1.4 MB     00:00
(3/5): dovecot-1.0.7-7.el5.i386.rpm                                | 1.6 MB     00:00
(4/5): postfix-2.3.3-2.1.el5_2.i386.rpm                                | 3.6 MB     00:00
(5/5): mysql-5.0.77-3.el5.i386.rpm                                     | 4.8 MB     00:00
—————————————————————————————–
Total                                              1.1 MB/s |  12 MB     00:11
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : perl-DBI                                                      1/5
Installing     : mysql                                             2/5
Installing     : cyrus-sasl-devel                                                   3/5
Installing     : postfix                                                4/5
Installing     : dovecot                                                              5/5
Installed:
cyrus-sasl-devel.i386 0:2.1.22-5.el5
dovecot.i386 0:1.0.7-7.el5
postfix.i386 2:2.3.3-2.1.el5_2

Dependency Installed:
mysql.i386 0:5.0.77-3.el5
perl-DBI.i386 0:1.52-2.el5
Complete!

# postconf -e ‘smtpd_sasl_local_domain =’
# postconf -e ‘smtpd_sasl_auth_enable = yes’
# postconf -e ‘smtpd_sasl_security_option = noanonymous’
# postconf -e ‘broken_sasl_auth_client = yes’
# postconf -e ‘smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination’
# postconf -e ‘inet_interfaces = all’

Edit smtpd.conf
# vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
mect_list: plain login
# mkdir /etc/postfix/ssl
# cd /etc/postfix/ssl/
# openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
216 semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
…………++++++
………..++++++
e is 65537 (0x10001)
Enter pass phrase for smtpd.key:
Verifying – Enter pass phrase for smtpd.key:
# chmod 600 smtpd.key
# openssl reg -new -key smtpd.key -out smtpd.csr
# openssl req -new -key smtpd.key -out smtpd.csr
Enter pass phrase for smtpd.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [GB]:IN
State or Province Name (full name) [Berkshire]:Jakarta
Locality Name (eg, city) [Newbury]:Kebayoran
Organization Name (eg, company) [My Company Ltd]:Infopratama
Organizational Unit Name (eg, section) []:it
Common Name (eg, your name or your server’s hostname) []:infopratama
Email Address []:admin@suyanto.linux
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:infopratama
# openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
Signature ok
subject=/C=IN/ST=Jakarta/L=Kebayoran/O=Infopratama/OU=it/CN=infopratama/emailAddress=admin@suyanto.linux
Getting Private key
Enter pass phrase for smtpd.key:
# openssl rsa -in smtpd.key -out smtpd.key.unencrypted
Enter pass phrase for smtpd.key:
writing RSA key
# mv -f smtpd.key.unencrypted smtpd.key
# openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
Generating a 1024 bit RSA private key
..++++++
…………++++++
writing new private key to ‘cakey.pem’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [GB]:IN
State or Province Name (full name) [Berkshire]:Jakarta
Locality Name (eg, city) [Newbury]:Kebayoran
Organization Name (eg, company) [My Company Ltd]:Infopratama
Organizational Unit Name (eg, section) []:it
Common Name (eg, your name or your server’s hostname) []:infopratama
Email Address []:admin@suyanto.linux
# postconf -e ‘smtpd_tls_auth_only = no’
# postconf -e ‘smtp_use_tls = yes’
# postconf -e ‘smtpd_use_tls = yes’
# postconf -e ‘smtp_tls_note_starttls_offer = yes’
# postconf -e ‘smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key’
# postconf -e ‘smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.cert’
# postconf -e ‘smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem’
# postconf -e ‘smtpd_tls_loglevel = 1’
# postconf -e ‘smtpd_tls_received_header = yes’
# postconf -e ‘smtpd_tls_session_cache_timeout = 3600s’
# postconf -e ‘tls_random_source = dev:/dev/urandom’

Edit main.cf
# vi /etc/postfix/main.cf
# vi /etc/dovecot.conf
# chkconfig –level 235 postfix on
# chkconfig –level 235 postfix on
# chkconfig –level 235 saslauthd on
# chkconfig –level 235 dovecot on

# /etc/init.d/saslauthd start
Starting saslauthd:                                        [  OK  ]

# /etc/init.d/postfix start
Starting postfix:                                          [  OK  ]

# /etc/init.d/dovecot start
Starting Dovecot Imap:                                     [  OK  ]

[root@thenuno ~]# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 thenuno.suyanto.linux ESMTP Postfix
ehlo localhost
250-thenuno.suyanto.linux
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH DIGEST-MD5 PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.

[root@thenuno ~]# yum install squirrelmail
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
—&gt; Running transaction check
—&gt; Package squirrelmail.noarch 0:1.4.8-5.el5.centos.7 set to be updated
—&gt; Processing Dependency: php-mbstring for package: squirrelmail
—&gt; Running transaction check
—&gt; Package php-mbstring.i386 0:5.1.6-23.2.el5_3 set to be updated
—&gt; Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package                      Arch      Version                Repository      Size
=========================================================================================
Installing:
squirrelmail                 noarch  1.4.8-5.el5.centos.7   lokal           4.2 M
Installing for dependencies:
php-mbstring                 i386      5.1.6-23.2.el5_3       lokal           994 k
Transaction Summary
=========================================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): php-mbstring-5.1.6-23.2.el5_3.i386.rpm                          | 994 kB     00:00
(2/2): squirrelmail-1.4.8-5.el5.centos.7.noarch.rpm                    | 4.2 MB     00:00
—————————————————————————————–
Total                                                         5.8 MB/s | 5.2 MB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : php-mbstring                                                        1/2
Installing     : squirrelmail                                                         2/2
Installed:
squirrelmail.noarch 0:1.4.8-5.el5.centos.7
Dependency Installed:
php-mbstring.i386 0:5.1.6-23.2.el5_3
Complete!
# cd /usr/share/squirrelmail/config/
# ./conf.pl
SquirrelMail Configuration : Read: config.php (1.4.0)
———————————————————
Main Menu —
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages
D.  Set pre-defined settings for specific IMAP servers
C   Turn color off
S   Save data
Q   Quit
Command &gt;&gt; 2
SquirrelMail Configuration : Read: config.php (1.4.0)
———————————————————
Server Settings
General
——-
1.  Domain                 : suyanto.linux
2.  Invert Time            : false
3.  Sendmail or SMTP       : SMTP
A.  Update IMAP Settings   : localhost:143 (dovecot)
B.  Update SMTP Settings   : localhost:25
R   Return to Main Menu
C   Turn color off
S   Save data
Q   Quit
Command &gt;&gt;
Data saved in config.php
Exiting conf.pl.
You might want to test your configuration by browsing to
http://your-squirrelmail-location/src/configtest.php
Happy SquirrelMailing!
[root@thenuno config]# yum install mod_ssl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
–&gt; Running transaction check
—&gt; Package mod_ssl.i386 1:2.2.3-31.el5.centos set to be updated
–&gt; Processing Dependency: libdistcache.so.1 for package: mod_ssl
–&gt; Processing Dependency: libnal.so.1 for package: mod_ssl
–&gt; Running transaction check
—&gt; Package distcache.i386 0:1.4.5-14.1 set to be updated
–&gt; Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package                      Arch      Version                Repository      Size
=========================================================================================
Installing:
mod_ssl                      i386      1:2.2.3-31.el5.centos  lokal           88 k
Installing for dependencies:
distcache                    i386      1.4.5-14.1             lokal           119 k
Transaction Summary
=========================================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 207 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): mod_ssl-2.2.3-31.el5.centos.i386.rpm                            |  88 kB     00:00
(2/2): distcache-1.4.5-14.1.i386.rpm                                   | 119 kB     00:00
—————————————————————————————–
Total                                                         1.0 MB/s | 207 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : distcache                                                            1/2
Installing     : mod_ssl                                                              2/2
nstalled:
mod_ssl.i386 1:2.2.3-31.el5.centos
Dependency Installed:
distcache.i386 0:1.4.5-14.1
Complete!
Tambahkan sebelum vitrualhost pada httpd.conf
# vi /etc/httpd/conf/httpd.conf
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/Webmail(.*)$ https://localhost/webmail/$1 [L,R]

Written by jazznuno

March 26, 2011 at 05:22

Posted in Just Share