天天看點

postifx網絡服務的搭建和配置

軟體環境:

    源碼包:

        postfix-2.4.6.tar.gz

        squirrelmail-1.4.13.tar.bz2

      all_locales-1.5.1-20060219.tar.bz2

    RHEL4/5自帶rpm包:——

        cyrus-sasl-2.1.22-4

        httpd-2.2.3-6.el5

        php-5.1.6-5.el5

一、配置主機名、IP位址、預設網關、DNS位址等

1、配置主機名

vi /etc/sysconfig/network 

NETWORKING=yes

HOSTNAME=mail.benet.com

vi /etc/hosts    #//添加主機名到IP位址的映射

重新開機一下網卡

    2、配置IP位址、預設網關、DNS位址等(略)

二、安裝配置Postfix

    1、解壓安裝

shell> groupadd -g 10000 postdrop

shell> useradd  -u 1000 -s /sbin/nologin postfix

shell> tar zxvf postfix-2.4.6.tar.gz

shell> make(提示你安裝db4-devel)

shell> make install    #//對安裝過程中的提示資訊,可以直接回車接受預設值即可。(不用修改,直接回車就行了)

2、建立main.cf主配置檔案

shell> cd /etc/postfix/

shell> postconf -n > main.cf(如果main.cf檔案有的話,就不用做這一步了)

shell> vi /etc/postfix/main.cf

myhostname = mail.456.com(與郵箱有關)

mydomain = example.com

myorigin = $mydomain   僞裝

inet_interfaces = all

mydestination = $myhostname, $mydomain, localhost

mynetworks = 127.0.0.0/8 10.100.100.0/8

home_mailbox = Maildir/    #//郵件存儲使用Maildir方式

message_size_limit = 31457280    #//限制郵件大小30MB

mailbox_size_limit = 524288000    #//限制郵箱空間500MB

    3、啟動postfix

postfix start

三、為postfix提供SMTP認證支援

    1、配置saslauthd服務(cyrus-sasl)

shell> vi /usr/lib/sasl2/smtpd.conf  該檔案預設不存在

pwcheck_method:saslauthd

shell> vi /etc/sysconfig/saslauthd

SOCKETDIR=/var/run/saslauthd    确認這三行

MECH=shadow

FLAGS=

shell> service saslauthd start

    2、修改postfix配置檔案

shell> vi /etc/postfix/main.cf    #//添加相關認證選項

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_unauth_pipelining, reject_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_local_domain = $myhostname

smtpd_sasl_security_options = noanonymous

smtpd_banner = $myhostname ESMTP "Require SMTP Auth."

    3、重新加載服務

shell> postfix reload

四、安裝配置Dovecot(提供POP3和IMAP服務)(對源碼包不熟悉的,就安裝rpm包)

 也可安裝rpm包(先裝mysql)

shell> useradd -s /sbin/nologin dovecot

shell> tar zxvf dovecot-1.1.4.tar.gz

shell> cd dovecot-1.1.4

shell> ./configure --sysconfdir=/etc

shell> make

shell> make install

    2、調整dovecot.conf配置檔案

shell> cp /etc/dovecot-example.conf /etc/dovecot.conf

shell> vi /etc/dovecot.conf

disable_plaintext_auth = no    #//允許使用明文密碼登入

ssl_disable = yes

protocols = pop3 imap

    3、啟動dovecot

shell> dovecot -c /etc/dovecot.conf (service dovecot start)

裝到這裡需要用用oe等測試工具試一下收發郵件.

特别提示:postfix需要/etc/aliases.db的支援,用newaliases來生成

五、安裝配置Squirrelmail(提供使用郵件系統的Web界面,需要用到SMTP、IMAP)

shell> tar jxvf squirrelmail-1.4.13.tar.bz2 -C /var/www/html/

/var/www/html/squirrelmail-1.4.13/ 

shell> cd /var/www/html/

shell> mv squirrelmail-1.4.13 squirrelmail

shell> cd /var/www/html/squirrelmail

shell> mkdir -p attach  放附件

shell> chown -R apache:apache attach/ data/    #//假設httpd的運作使用者群組身份為"apache"

shell> chmod 730 attach/

 讓linux支援中文:

下載下傳了語言包all_locales-1.4.9-20070106.tar.bz2

tar  xjvf all_locales-1.4.9-20070106.tar.bz2

進入解壓目錄  cp   *     /var/www/html/squirrelmail/locale/

cd /var/www/html/webmail/config  ./conf.pl

選擇10 設定語言為zh_CN

預設字元集為gb2312

儲存退出,重新重新整理webmail頁面,就成中文了

    2、調整config.php配置

      需要運作/var/www/html/squirrelmail/config/config.pl,然後根據提示進行設定,依次來生成config.php

    3、配置啟動httpd服務

    配置網頁目錄使用“DocumentRoot "/var/www/html/squirrelmail"”,…… ——過程略。

本文轉自 gehailong 51CTO部落格,原文連結:http://blog.51cto.com/gehailong/263912,如需轉載請自行聯系原作者