Install Postfix, Courier authlib, Courier Imap, MySQL, Squirrelmail

By | 7 March 2011

Install postfix, courier authlib, courier imap, mysql, squirrelmail di mesin CentOS. Sebenarnya ini hanya sebagai catatan saya setelah install mail server postfix, jadi biar tidak lupa langsung saya documentasikan ke web ini. Mungkin tidak begitu detail, hanya sekedar urutannya saja

Bagi yang masih dasar dengan urusan server saya yakin bingung dengan tulisan saya ini..

Uninstall paket email lain bisa sudah ada

rpm -qa | grep sendmail;rpm -qa | grep postfix;rpm -qa | grep cyrus;rpm -qa | grep dovecot

Bila masih menemukan paket tersebut silahkan di uninstall

rpm -e namapaketnya

Install paket yang diperlukan

yum -y install openldap-devel openldap-servers expect-devel gamin-devel httpd* php* mysql* rpm-build* libtool gdbm-devel pam-devel gcc-c++ redhat-rpm-config libtool-ltdl-devel libtool-ltdl postgresql-devel pam-devel

Download paket Mail server

squirrelmail-1.4.19.tar.gz
postfix-2.6.5.tar.gz
cyrus-sasl-2.1.22.tar.gz
courier-packet.rar
postfixadmin-2.3.2.tar.gz

Install Cyrus
set variabelnya..

export CPPFLAGS=”-I/usr/include/mysql”
export LDFLAGS=”-L/usr/lib/mysql -lmysqlclient -lz -lm”

Compile

./configure –enable-anon –enable-plain –enable-login –enable-sql –disable-krb4 –disable-otp –disable-cram –disable-digest –with-mysql=/usr/lib/mysql –without-pam –without-saslauthd –without-pwcheck –prefix=/usr –with-plugindir=/usr/lib/sasl2; make -j2; make install

Install Postfix
Create user dan Group

userdel postfix
groupdel postdrop
groupadd -g 500 postfix
groupadd -g 501 postdrop
useradd -g 500 -G postdrop postfix
id postfix

Compile postfix

make makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_TLS -DUSE_CYRUS_SASL -I/usr/include/sasl’ ‘AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib -lssl -lcrypto -lsasl2’

make install

Buat SSL

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
chmod o= /etc/postfix/ssl/smtpd.key

Configure postfix di /etc/postfix/main.cf

Baca :   Configure Proxy Squid Block Proxifier

nano -w /etc/postfix/main.cf

alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf,hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
#mailbox_size_limit = 10240000
message_size_limit = 1638400
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
mydomain = paidjo.com
myhostname = mx-gw.paidjo.com
myorigin = $mydomain
mynetworks = 192.168.9.0/26,127.0.0.1
mydestination = $myhostname, localhost.$mydomain, localhost
#inet_interfaces = $myhostname, localhost
#transport_maps = hash:/etc/postfix/transport
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtp_host_lookup = dns, native
smtpd_client_restrictions = permit_mynetworks,reject_invalid_hostname,reject_rbl_client combined.njabl.org,reject_rbl_client combined.rbl.msrbl.net,reject_rbl_client cbl.abuseat.org,reject_rbl_client dnsbl.sorbs.net,reject_rbl_client bl.spamcop.net,reject_rbl_client cbl.anti-spam.org.cn,
smtpd_tls_auth_only = no
smtpd_banner = ESMTP mx-gw.paidjo.com
smtpd_delay_reject = no
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_pipelining,reject_unauth_destination,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
local_recipient_maps =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_aliad_domains = $virtual_alias_maps
virtual_gid_maps = static:500
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 500
virtual_transport = virtual
virtual_uid_maps = static:500

NOTE: pada configurasi main.cf, mohon ditulis dalam satu baris dalam setiap barisnya.. walaupun hasilnya panjang

Baca :   Browse Faster Using a Local DNS Cache Fedora 10

Buat file berikut dan tambahkan isinya sesuai yang saya tuliskan

nano -w mysql_virtual_alias_maps.cf
user = postfixuser
password = postfixpass
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address=’%s’ AND active = ‘1’

nano -w mysql_virtual_domains_maps.cf
user = postfixuser
password = postfixpass
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ AND active = ‘1’

nano -w mysql_virtual_mailbox_maps.cf
user = postfixuser
password = postfixpass
hosts = localhost
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username=’%s’ AND active = ‘1’

Install Courier Authlib

cd /usr/local/src –> tergantung dimana anda meletakan filenya
rpmbuild -ta courier-authlib-0.62.4.tar.bz2
cd /usr/src/redhat/RPMS/i386/
rpm -ivh courier-authlib*

Install Courier Imap

Install courier imap dilakukan oleh user biasa

useradd courier
su courier
mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
echo “%_topdir $HOME/rpm” >> $HOME/.rpmmacros
mkdir $HOME/downloads
cd $HOME/downloads
cd /usr/local/src
cp courier-imap* $HOME/downloads
cd $HOME/downloads
rpmbuild -ta courier-imap*

back to root alias kembali ke root.. :D

exit
cd /home/courier/rpm/RPMS/i386
rpm -ivh courier-imap*

buat file baru

nano -w  /etc/authlib/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME postfixuser
MYSQL_PASSWORD postfixpass
MYSQL_PORT 0
MYSQL_OPT 0
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD ‘500’
MYSQL_GID_FIELD ‘500’
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD ‘/var/vmail/’
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir

nano -w /etc/authlib/authdaemonrc
authmodulelist=”authmysql authpam”
DEBUG_LOGIN=1

nano -w /usr/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket

chmod o+x /var/spool/authdaemon

Buat directory untuk user mail atau mailboxnya

mkdir /var/vmail
chown -R postfix:postfix /var/vmail/

Nyalakan service

####Nyalakan courier-authlib
chkconfig –levels 235 courier-authlib on
/etc/init.d/courier-authlib start

####Nyalakan authdaemon
chkconfig –levels 235 courier-imap on
/etc/init.d/courier-imap start

####running postfix
postfix start

Create Database MySQL

mysql -u root -p

create database postfix;

grant all on postfix.* to postfixuser@localhost identified by ‘postfixpass’;

Install squirrelmail

tar -zxvf squirrelmail-1.4.19.tar.gz
mv squirrelmail-1.4.19 webmail
mv webmail /var/www/html/
mkdir -p /var/local/squirrelmail/data/
mkdir -p /var/local/squirrelmail/attach/
chown apache:apache /var/local/squirrelmail/data/
chown apache:apache /var/local/squirrelmail/attach/

cd /var/www/html/webmail
./configure

– Pilih Nomor 2 (Server Settings)
– Pilih Huruf A (Update IMAP Settings)
– Pilih nomor 4 lalu ketikkan alamat IP anda

– Pilih Nomor 6 (Authentification type)

Jawab Pertanyaan dengan menjawab N dan login

– Pilih Nomor 8 (Server Software)

Tulis courier

– Pilih Huruf B (Update SMTP Settings)

– Pilih Nomor 7 (SMTP Authentification)

Jawab Pertanyaan dengan N, login, dan N

– Pilih Huruf S

– Pilih Huruf Q

Mail Server sudah siap digunakan.. nanti lain waktu akan saya tambahkan bagaimana menginstall amavisd dan clamav

Share and Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Comments : *

[+] kaskus emoticons