Thursday 26 July 2012

Email Server with Squirrelmail

Proses konfigurasi ip address, seperti dibawah ini :
root@ns:/home/eka# nano /etc/network/interfaces

#isi dari konfigurasi /etc/network/interfaces

# The loopback network interface

auto lo

iface lo inet loopback



# The primary network interface

allow-hotplug eth0

iface eth0 inet static

        address 192.168.1.5

        netmask 255.255.255.0

        network 192.168.1.0

        broadcast 192.168.1.255

        # dns-* options are implemented by the resolvconf package, if installed

        dns-nameservers 192.168.1.5

        dns-search eka.net


Dibawah ini adalah proses konfigurasi hosts, seperti dibawah ini:

root@ns:/home/eka# nano /etc/hosts

#isi dari /etc/hosts

127.0.0.1       localhost

192.168.1.5     eka.net ns



# The following lines are desirable for IPv6 capable hosts

#::1     ip6-localhost ip6-loopback

#fe00::0 ip6-localnet

#ff00::0 ip6-mcastprefix

#ff02::1 ip6-allnodes

#ff02::2 ip6-allrouters


Dibawah ini adalah proses konfigurasi /etc/resolv.conf, seperti dibawah ini:

root@ns:/home/eka# nano /etc/resolv.conf

# isi dari /etc/resolv.conf

# Generated by NetworkManager

domain eka.net        

search eka.net        

nameserver 192.168.1.5

Sesudah konfigurasi diatas dilakukan, silakan hidupkan ulang pc servernya.
Sebelum menginstall paket ke dalam server, terlebih dahulu kita cek daftar repository, apakah mau dari yang default atau mau kita ganti, caranya seperti dibawah ini:

root@eka:/home/eka# nano /etc/apt/sources.list

#keterangan daftar repository
deb http://security.debian.org/ squeeze/updates main contrib

deb-src http://security.debian.org/ squeeze/updates main contrib


root@eka:/home/eka# apt-get update

Get:1 http://security.debian.org squeeze/updates Release.gpg [836 B]

Ign http://security.debian.org/ squeeze/updates/contrib Translation-en

Ign http://security.debian.org/ squeeze/updates/contrib Translation-en_US

Ign http://security.debian.org/ squeeze/updates/main Translation-en

Ign http://security.debian.org/ squeeze/updates/main Translation-en_US

Get:2 http://security.debian.org squeeze/updates Release [86.9 kB]

Get:3 http://security.debian.org squeeze/updates/main Sources [60.5 kB]       

Get:4 http://security.debian.org squeeze/updates/contrib Sources [14 B]       

Get:5 http://security.debian.org squeeze/updates/main i386 Packages [191 kB]  

Get:6 http://security.debian.org squeeze/updates/contrib i386 Packages [674 B]

Fetched 340 kB in 36s (9,380 B/s)                                             

Reading package lists... Done



Install bind9

root@eka:/home/eka# apt-get install bind9

Reading package lists... Done

Building dependency tree      

Reading state information... Done

The following extra packages will be installed:

  bind9-host bind9utils dnsutils libbind9-60 libdns69 libisc62 libisccc60

  libisccfg62 liblwres60

Suggested packages:

  bind9-doc resolvconf ufw rblcheck

The following NEW packages will be installed:

  bind9 bind9utils

The following packages will be upgraded:

  bind9-host dnsutils libbind9-60 libdns69 libisc62 libisccc60 libisccfg62

  liblwres60

8 upgraded, 2 newly installed, 0 to remove and 126 not upgraded.

Need to get 1,679 kB of archives.

After this operation, 1,393 kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://security.debian.org/ squeeze/updates/main bind9-host i386 1:9.7.3.dfsg-1~squeeze4 [67.7 kB]



Sesudah install bind9, maka selanjutnya dilanjutkan dengan pembuatan domain name server, seperti dibawah ini :

root@eka:/home/eka# cd /etc/bind
perintah diatas untuk masuk ke directory bind9









selanjutnya adalah proses langkah2 pembuatan domain, seperti dibawah ini:
root@eka:/etc/bind# nano named.conf.local

#Dibawah ini adalah isi dari konfigurasi name.conf.local

//

// Do any local configuration here

//

// Consider adding the 1918 zones here, if they are not used in your

// organization

//include "/etc/bind/zones.rfc1918";

zone "eka.net" {

type master;

file "/etc/bind/eka.net";

};


zone "1.168.192.in-addr.arpa" {

type master;

file "/etc/bind/db.192";

};

Proses diatas adalah konfigurasi named.conf.local





dibawah ini adalah proses pembuatan konfigurasi eka.net, seperti dibawah ini:

root@eka:/etc/bind# nano eka.net

#isi dari konfigurasi eka.net

;

; BIND reverse data file for local loopback interface

;

$TTL    604800

eka.net.        IN      SOA     ns.eka.net. root.eka.net. (

                              2         ; Serial

                         604800         ; Refresh

                          86400         ; Retry

                        2419200         ; Expire

                         604800 )       ; Negative Cache TTL

;



eka.net.        IN      NS      ns.eka.net.

ns.eka.net.     IN      A       192.168.1.5

www.eka.net.    IN      A       192.168.1.5

mail.eka.net.   IN      A       192.168.1.5


Dibawah ini adalah proses pembuatan konfigurasi db.192
;

; BIND reverse data file for local loopback interface

;

$TTL    604800

1.168.192.in-addr.arpa.         IN      SOA     ns.eka.net. root.eka.net. (

                                                1                    ; Serial

                                                604800          ; Refresh

                                                86400           ; Retry

                                                2419200         ; Expire

                                                604800 )        ; Negative Cache TTL

;



1.168.192.in-addr.arpa.         IN      NS      ns.eka.net.

1.168.192.in-addr.arpa.         IN      PTR     ns.eka.net.

1.168.192.in-addr.arpa.         IN      PTR     www.eka.net.

1.168.192.in-addr.arpa.         IN      PTR     mail.eka.net.









Proses dibawah ini adalah pembuatan konfigurasi named.conf.options

root@eka:/etc/bind# nano named.conf.options
#isi dari named.conf.options

options {

        directory "/var/cache/bind";



        // If there is a firewall between you and nameservers you want

        // to talk to, you may need to fix the firewall to allow multiple

        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113



        // If your ISP provided one or more IP addresses for stable

        // nameservers, you probably want to use them as forwarders.

        // Uncomment the following block, and insert the addresses replacing

        // the all-0's placeholder.



           forwarders {

                192.168.1.5;

           };



        auth-nxdomain no;    # conform to RFC1035

        listen-on-v6 { any; };

};


Sesudah selesai semua konfigurasi bind9, maka lakukan restart bind9, caranya seperti dibawah ini:

root@eka:/etc/bind# /etc/init.d/bind9 restart

Stopping domain name service...: bind9 waiting for pid 3639 to die.

Starting domain name service...: bind9.

Testing konfigurasi  domain yang telah kita buat, caranya seperti dibawah ini

root@eka:/etc/bind# ping eka.net

PING eka.net (192.168.1.5) 56(84) bytes of data.

64 bytes from eka.net (192.168.1.5): icmp_req=1 ttl=64 time=0.031 ms

64 bytes from eka.net (192.168.1.5): icmp_req=2 ttl=64 time=0.028 ms

64 bytes from eka.net (192.168.1.5): icmp_req=3 ttl=64 time=0.026 ms

64 bytes from eka.net (192.168.1.5): icmp_req=4 ttl=64 time=0.024 ms
Keterangan diatas adalah proses ping ke domain eka.net

dibawah ini adalah proses ping ke mail.eka.net
root@eka:/etc/bind# ping mail.eka.net

PING mail.eka.net (192.168.1.5) 56(84) bytes of data.

64 bytes from eka.net (192.168.1.5): icmp_req=1 ttl=64 time=0.020 ms




berikut ini adalah proses installasi LAMP, caranya seperti dibawah ini:

root@ns:/home/eka# apt-get install apache2

Reading package lists... Done

Building dependency tree      

Reading state information... Done

The following extra packages will be installed:

  apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common

Suggested packages:

  apache2-doc apache2-suexec apache2-suexec-custom

The following NEW packages will be installed:

  apache2 apache2-mpm-worker apache2-utils apache2.2-common

The following packages will be upgraded:

  apache2.2-bin

1 upgraded, 4 newly installed, 0 to remove and 125 not upgraded.

Need to get 1,826 kB of archives.

After this operation, 2,695 kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://security.debian.org/ squeeze/updates/main apache2.2-bin i386 2.2.16-6+squeeze3 [1,350 kB]

Get:2 http://security.debian.org/ squeeze/updates/main apache2-utils i386 2.2.16-6+squeeze3 [165 kB]

Proses dibawah ini adalah installasi mysql-server
root@ns:/home/eka# apt-get install mysql-server

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following extra packages will be installed:

  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-common mysql-server-5.1

  mysql-server-core-5.1

Suggested packages:

  libipc-sharedcache-perl libterm-readkey-perl tinyca

The following NEW packages will be installed:

  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-common mysql-server mysql-server-5.1

  mysql-server-core-5.1

0 upgraded, 11 newly installed, 0 to remove and 197 not upgraded.

Need to get 23.3 MB of archives.

After this operation, 55.0 MB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://ftp.debian.org/debian/ squeeze/main mysql-common all 5.1.49-3 [70.9 kB]

Get:2 http://ftp.debian.org/debian/ squeeze/main libnet-daemon-perl all 0.43-1 [46.6 kB]


Sesudah melakukan proses seperti diatas maka akan muncul form seperti dibawah ini, dimana kita dirusuh memasukkan password mysql-server.


Dibawah ini adalah proses pengulangan pembuatan password dari yang diatas

dibawah ini adalah proses installasi paket php, seperti dibawah ini:

root@ns:/home/eka# apt-get install php5 php-pear php5-suhosin
 php5-mysql
Reading package lists... Done

Building dependency tree      

Reading state information... Done

The following extra packages will be installed:

  apache2 apache2-mpm-prefork apache2.2-bin apache2.2-common libapache2-mod-php5 libonig2 libqdbm14 php5-cli php5-common

Suggested packages:

  apache2-doc apache2-suexec apache2-suexec-custom php5-dev

The following packages will be REMOVED:

  apache2-mpm-worker

The following NEW packages will be installed:

  apache2-mpm-prefork libapache2-mod-php5 libonig2 libqdbm14 php-pear php5 php5-cli php5-common php5-suhosin

The following packages will be upgraded:

  apache2 apache2.2-bin apache2.2-common

3 upgraded, 9 newly installed, 1 to remove and 193 not upgraded.

Need to get 8,679 kB of archives.

After this operation, 19.9 MB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://ftp.debian.org/debian/ squeeze/main apache2 i386 2.2.16-6+squeeze4 [1,388 B]         

Get:2 http://ftp.debian.org/debian/ squeeze/main apache2.2-bin i386 2.2.16-6+squeeze4 [1,351 kB]




Dibawah ini adalah proses konfigurasi dari apache server untuk membuat virtualhost mail.eka.net

cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mail.eka.net


Sesudah membuat file mail.eka.net, seperti diatas, maka dilanjutkan dengan proses konfigurasinya, seperti dibawah ini:
root@ns:/etc/apache2/sites-available# nano mail.eka.net

# isi dari mail.eka.net

<VirtualHost *:80>

          ServerAdmin webmaster@localhost

          ServerName mail.eka.net

          DocumentRoot /var/www/squirrelmail

          <Directory />

                   Options FollowSymLinks

                   AllowOverride None

          </Directory>

          <Directory /var/www/squirrelmail/>

                   Options Indexes FollowSymLinks MultiViews

                   AllowOverride None

                   Order allow,deny

                   allow from all

          </Directory>



          ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

          <Directory "/usr/lib/cgi-bin">

                   AllowOverride None

                   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

                   Order allow,deny

                   Allow from all

          </Directory>



          ErrorLog ${APACHE_LOG_DIR}/error.log



          # Possible values include: debug, info, notice, warn, error, crit,

          # alert, emerg.

          LogLevel warn



          CustomLog ${APACHE_LOG_DIR}/access.log combined



    Alias /doc/ "/usr/share/doc/"

    <Directory "/usr/share/doc/">

        Options Indexes MultiViews FollowSymLinks

        AllowOverride None

        Order deny,allow

        Deny from all

        Allow from 127.0.0.0/255.0.0.0 ::1/128

    </Directory>



</VirtualHost>
Sesudah melakukan konfigurasi mail.eka.net seperti diatas, maka dilanjutkan dengan mengaktifkan file mail.eka.net, caranya seperti dibawah ini:

# masuk dahulu ke directory dari apache2, cara seperti dibawah ini
root@ns:/home/eka# cd /etc/apache2/sites-available/

# proses pengaktifkan mail.eka.net, seperti dibawah ini

root@ns:/etc/apache2/sites-available# a2ensite mail.eka.net

Enabling site mail.eka.net.

Run '/etc/init.d/apache2 reload' to activate new configuration!


Sesudah proses pengaktifkan mail.eka.net, maka silakan lakukan restart ulang apache servernya, caranya seperti dibawah ini:

root@ns:/home/eka# /etc/init.d/apache2 restart

Restarting web server: apache2 ... waiting .
















Proses pembuatan mail server

pertama installasi dahulu paket postfix dovecot-common dovecot-imapd dovecot-pop3d squirrelmail, caranya seperti dibawah ini:

root@ns:/home/eka# apt-get install postfix dovecot-common dovecot-imapd dovecot-pop3d squirrelmail
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  libpq5 squirrelmail-locales squirrelmail-viewashtml
Suggested packages:
  ntp postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin resolvconf postfix-cdb ufw squirrelmail-decode php5-recode imap-server imapproxy php5-ldap
The following packages will be REMOVED:
  exim4 exim4-base exim4-config exim4-daemon-light
The following NEW packages will be installed:
  dovecot-common dovecot-imapd dovecot-pop3d libpq5 postfix squirrelmail squirrelmail-locales squirrelmail-viewashtml
0 upgraded, 8 newly installed, 4 to remove and 189 not upgraded.
Need to get 12.6 MB of archives.
After this operation, 29.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://security.debian.org/ squeeze/updates/main postfix i386 2.7.1-1+squeeze1 [1,328 kB]




















Sesudah melakukan perintah diatas,maka akan muncul salah satu popup dari posftfix, pilih yang internet site, lalu OK. Seperti dibawah ini:

sesudah melakukan perintah seperti diatas, maka dibawah ini akan muncul popup, seperti dibawah ini:
keterangan gambar diatas adalah proses pemberian nama domain server pada postfix.

Sesudah melakukan perintah diatas maka lakukan edit pada file maincf, caranya seperti dibawah ini:
root@ns:/home/eka# nano /etc/postfix/main.cf

#isi dari main.cf, seperti dibawah ini


# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = eka.net
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = eka.net, localhost.net, , localhost
relayhost = smtp.telkom.net
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all


Berikut ini akan dilakukan konfigurasi file dovecot.conf, seperti dibawah ini:
root@ns:/home/eka# nano /etc/dovecot/dovecot.conf

#isi dari dovecot.conf, yang dirubah
protocols = pop3 imap
disable_plaintext_auth = no
mail_location = mbox:~/mail:INBOX=/var/mail/%u


Konfigurasi squirrelmail

Sekarang saatnya untuk mengkonfigurasi squirrelmailnya. Ketikkan perintah berikut di console:

root@ns:/home/eka# squirrelmail-configure

Nanti akan muncul tampilan seperti ini lalu ketikkan d dan tekan enter :

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 on
S   Save data
Q   Quit


Command >> D











Kemudian tuliskan dovecot dan tekan enter :
SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others.  If you select your IMAP server, this option will
set some pre-defined settings for that server.


Please note that you will still need to go through and make sure
everything is correct.  This does not change everything.  There are
only a few settings that this will change.


Please select your IMAP server:
    bincimap    = Binc IMAP server
    courier     = Courier IMAP server
    cyrus       = Cyrus IMAP server
    dovecot     = Dovecot Secure IMAP server
    exchange    = Microsoft Exchange IMAP server
    hmailserver = hMailServer
    macosx      = Mac OS X Mailserver
    mercury32   = Mercury/32
    uw          = University of Washington's IMAP server
    gmail       = IMAP access to Google mail (Gmail) accounts


    quit        = Do not change anything
Command >> dovecot

Tekan enter lagi aja :

imap_server_type = dovecot
         default_folder_prefix = <none>
                  trash_folder = Trash
                   sent_folder = Sent
                  draft_folder = Drafts
            show_prefix_option = false
          default_sub_of_inbox = false
show_contain_subfolders_option = false
            optional_delimiter = detect
                 delete_folder = false


Press any key to continue...





Sekarang ketikkan 2 dan tekan enter :

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 on
S   Save data
Q   Quit


Command >> 2

Sekarang ketik 1, tekan enter :

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings


General
-------
1.  Domain                 : trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')))
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 on
S   Save data
Q   Quit


Command >> 1




Isi dengan eka.net lalu Tekan enter lagi, seperti dibawah ini :

The domain name is the suffix at the end of all email addresses.  If
for example, your email address is jdoe@example.com, then your domain
would be example.com.


[trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')))]: eka.net

Sekarang ketik S untuk mengesave, Y untuk mengkonfirmasi.. Lalu ketik Q untuk exit. Tekan enter.

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings


General
-------
1.  Domain                 : eka.net
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 on
S   Save data
Q   Quit


Command >> S

Perintah diatas untuk menyimpan settingan konfigurasi

sesudah melakukan perintah diatas maka akan muncul seperti dibawah ini, maka tekan enter aja.

Data saved in config.php
Press enter to continue...Y











Untuk keluar dari konfigurasi squirrelmail, lakukan perintah seperti dibawah ini.

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings


General
-------
1.  Domain                 : eka.net
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 on
S   Save data
Q   Quit


Command >> Q


Edit file apache2

Ini untuk menampilkan squirrelmailnya di webserver nanti. Caranya ketikkan perintah berikut :

root@ns:/home/eka# echo "Include /etc/squirrelmail/apache.conf" >> /etc/apache2/apache2.conf

Sesudah melakukan perintah seperti diatas, maka restart semua servicenya, supaya efeknya berjalan, kita harus merestart semua service aplikasi.seperti dibawah ini:

root@ns:/home/eka# /etc/init.d/postfix restart
Stopping Postfix Mail Transport Agent: postfix.
Starting Postfix Mail Transport Agent: postfix.
root@ns:/home/eka# /etc/init.d/dovecot restart
Restarting IMAP/POP3 mail server: dovecotIf you have trouble with authentication failures,
enable auth_debug setting. See http://wiki.dovecot.org/WhyDoesItNotWork
This message goes away after the first successful login.
.
root@ns:/home/eka# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .





Terakhir lakukan konfigurasi dengan memberi link antar directory dari /usr/share/squirrelmail /var/www/ seperti dibawah ini, supaya bisa diakses dengan nama mail.eka.net, sebelum sudah dilakukan konfigurasi pada file /etc/apache2/sites-available/default.

root@ns:/home/eka# ln -s /usr/share/squirrelmail /var/www/



Testing lewat browser


















tampilan login dengan user eka dan password 123456

tampilan bahwa user eka berhasil login ke mail.eka.net, seperti dibawah ini:



membuat user account dan password untuk mail server, seperti dibawah ini:

root@ns:/home/eka# adduser demo
Adding user `demo' ...
Adding new group `demo' (1001) ...
Adding new user `demo' (1001) with group `demo' ...
Creating home directory `/home/demo' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for demo
Enter the new value, or press ENTER for the default
          Full Name []: demo
          Room Number []: other
          Work Phone []: -
          Home Phone []: -
          Other []: mail
Is the information correct? [Y/n] y

 Please Trying...Good Luck







No comments:

Post a Comment