- Postfix
- Dovecot
ติดตั้งตามขั้นตอนจากแผ่นจนจบ แล้วต่อด้วย
1. Enable root account
#sudo passwd root
แล้วแปลงตัวเป็น root
#sudo su
2. Config the network
#nano /etc/network/interfaces
กำหนดค่า ip เป็น static
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
#/etc/init.d/networking restart
3. Edit /etc/apt/sources.list and update
#nano /etc/apt/sources.list
Comment out or remove the installation CD from the file
#aptitude update
#aptitude upgrade
4. Change default shell
#rm -f /bin/sh
#ln -s /bin/bash /bin/sh
5. Install ssh server
#aptitude install ssh openssh-server
6. Edit /etc/hosts, /etc/hostname
#nano /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.100 server1.example.com server1
#nano /etc/hostname
server1.sample.com
7. Install base software
#aptitude install build-essential linux-headers-`uname -r`
#aptitude install binutils cpp flex gcc libarchive-zip-perl libc6-dev
libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev
lynx m4 make ncftp nmap openssl perl perl-modules
unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev
g++
8. Restart system
#reboot
9. Install mysql
#aptitude install mysql-server mysql-client libmysqlclient15-dev
#nano /etc/mysql/my.cnf
comment out the line bind-address = 127.0.0.1
#/etc/init.d/mysql restart
#mysqladmin -u root password “newpassword”
#mysqladmin -h server1.sample.com -u root password “newpassword”
10. Install postfix
เมื่อติดตั้ง mysql ตัว postfix จะถูกติดตั้งมาด้วยโดยอัตโนมัติ ให้ทำการ reconfig โดย
#dpkg-reconfigure postfix
ให้ enter ผ่านไปทั้งหมด
11. Install bind9
#aptitude install bind9
เมื่อติดตั้งเสร็จก็หยุดมันซะก่อน
#/etc/init.d/bind9 stop
จับขังคุกซะด้วย
#nano /etc/default/bind9
แก้ไขบรรทัด OPTIONS=”-u bind -t /var/lib/named”
สร้างกรงขังซะด้วย
#mkdir -p /var/lib/named/etc
#mkdir /var/lib/named/dev
#mkdir -p /var/lib/named/var/cache/bind
#mkdir -p /var/lib/named/var/run/bind/run
#mv /etc/bind /var/lib/named/etc
#ln -s /var/lib/named/etc/bind /etc/bind
#mknod /var/lib/named/dev/null c 1 3
#mknod /var/lib/named/dev/random c 1 8
#chmod 666 /var/lib/named/dev/null /var/lib/named/dev/random
#chown -R bind:bind /var/lib/named/var/*
#chown -R bind:bind /var/lib/named/etc/bind
แก้ไขการบันทึก log
#nano /etc/default/syslogd
แก้ไขบรรทัด SYSLOGD=”-a /var/lib/named/dev/log” ตามนี้
เปิดก๊อกได้
#/etc/init.d/syslogd restart
#/etc/init.d/bind9 start
แต่ตอนนี้ยังไม่ได้สร้าง zone ของตัวเองเด้อ
12. สร้าง certificate file
#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
13. ปรับแต่ง postfix
#nano /etc/postfix/main.cf แก้ไขให้เป็นไปตามนี้
# General parameters
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
#delay_warning_time = 4h
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
mynetworks = 127.0.0.0/8
mydomain = example.com
myhostname = server1.example.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, $mydomain
home_mailbox = Maildir/
mailbox_command =
# Relayhost parameters
relayhost = [mail.isp.com]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
# SASL parameters
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
# TLS parameters
smtpd_use_tls = yes
smtpd_tls_auth_only = no
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
tls_random_source = dev:/dev/urandom
มีการกำหนดให้ relay mail ไปที่ [mail.isp.com] จึงต้องสร้างไฟล์สำหรับเก็บ authen ของ [mail.isp.com] ตามนี้
#nano /etc/postfix/sasl_passwd
[mail.isp.com] username@isp.com:password
#chmod 600 /etc/postfix/sasl_passwd
#chown root:root /etc/postfix/sasl_passwd
#postmap /etc/postfix/sasl_passwd
14. Install dovecot
#aptitude install dovecot-common dovecot-imapd dovecot-pop3d
ปรับแต่ง /etc/dovecot/dovecot.conf เท่าที่จำเป็นก่อน ตามนี้
- protocols = imap imaps pop3 pop3s
- default_mail_env = maildir:~/Maildir
- ssl_cert_file = /etc/postfix/ssl/smtpd.crt
- ssl_key_file = /etc/postfix/ssl/smtpd.key
- ssl_disable = no
- disable_plaintext_auth = no
- auth default {
mechanisms = plain login
passdb pam {
}
userdb passwd {
}
socket listen {
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}
}
เริ่มต้นทำงานได้
#/etc/init.d/dovecot start
#/etc/init.d/postfix restart
15. เพิ่ม user vmail
#useradd -r -u 150 -g mail -d /home/vmail -s /sbin/nologin -c “Virtual mailbox” vmail
#mkdir /home/vmail
#chmod 770 /home/vmail
#chown vmail:mail /home/vmail
16.
17. ติดตั้ง apache
#aptitude install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
แก้ไข /etc/apache2/mods-available/dir.conf ตามนี้
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml
แก้ไข /etc/apache2/ports.conf ตามนี้
Listen 80
Listen 443
Enable some apache modules
#a2enmod ssl
#a2enmod rewrite
#a2enmod suexec
#a2enmod include
18. ติดตั้ง php
#aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
#/etc/init.d/apache restart
Powered by ScribeFire.