阿廖 發表
Postfix Mail server 安裝
參考資源程式下載
Postfix 為一套比 sendmail 更容易安裝、調整的郵件系統,選擇 Postfix 的原因是因為容易設定和了解,而且內建也已有郵件過瀘的功能,更重要的是,它被設計和 sendmail 相容!很多在 sendmail 的系統指令,在 postfix 都可以使用!
當初我選了擇 postfix 套件除了容易設定和了解之外,還有一個原因是在小弟讀完了傳說中 sendmail 的兩本天書 ( sendmail 基礎篇 、 sendmail 安裝管理 ) 之後,發現除了 mail 郵件傳遞原理及理論有所吸收外,sendmail 的設定檔簡直不是人看的了!因此才會選擇 postfix 來做為 mail system。
當然,這裡的範例是以 Redhat 來做說明,而且也相信在不同的套件系統安裝也是大同小異,所以就不在做其它系統的示範了。安裝之前,在您的主機上必需要有 GCC 編譯器,和 postfix 的原始碼,postfix 的下載點在 http://www.postfix.org/download.html 有完全的列表,台灣也有 mirror 站台,應該可以下載較快!
關閉 sendmail
看看 sendmail 有無啟動
[root@rhel200 root]# netstat -nutlp | grep :25 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1566/sendmail: acce [root@rhel200 root]# |
[root@rhel200 root]# service sendmail stop Shutting down sendmail: [ OK ] Shutting down sm-client: [ OK ] [root@rhel200 root]# chkconfig sendmail off [root@rhel200 root]# chkconfig sendmail --list sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@rhel200 root]# |
[root@rhel200 root]# netstat -nutlp | grep :25 [root@rhel200 root]# |
[root@rhel200 root]# wget ftp://postfix.cdpa.nsysu.edu.tw/postfix/postfix-release/official/postfix-2.1.5.tar.gz --14:58:05-- ftp://postfix.cdpa.nsysu.edu.tw/postfix/postfix-release/official/postfix-2.1.5.tar.gz => `postfix-2.1.5.tar.gz' Resolving postfix.cdpa.nsysu.edu.tw... done. Connecting to postfix.cdpa.nsysu.edu.tw[140.117.205.30]:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD /postfix/postfix-release/official ... done. ==> PASV ... done. ==> RETR postfix-2.1.5.tar.gz ... done. [ <=> ] 1,971,931 210.41K/s 14:58:14 (210.41 KB/s) - `postfix-2.1.5.tar.gz' saved [1971931] [root@rhel200 root]# |
[root@rhel200 root]# tar -zxf postfix-2.1.5.tar.gz [root@rhel200 root]# |
[root@rhel200 postfix-2.1.5]# groupadd postdrop [root@rhel200 postfix-2.1.5]# useradd postfix -s /bin/false [root@rhel200 postfix-2.1.5]# |
[root@rhel200 root]# cd postfix-2.1.5 [root@rhel200 postfix-2.1.5]# make clean ~ 略 ~ [root@rhel200 postfix-2.1.5]# |
開始編譯
[root@rhel200 postfix-2.1.5]# make ~ 略 ~ [root@rhel200 postfix-2.1.5]# |
開始安裝
[root@rhel200 postfix-2.1.5]# make install Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to other machines. install_root: [/] 這一段是在尋問安裝的根目錄是在那裡。如果您有使用 chroot 則請另外設定。 Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory. tempdir: [/root/postfix-2.1.5] 安裝時的暫存資料夾,這不用擔心,安裝好就會被刪除 Please specify the final destination directory for installed Postfix configuration files. config_directory: [/etc/postfix] postfix 的設定檔要放在那裡 Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users. daemon_directory: [/usr/libexec/postfix] postfix 的 daemon 放在那裡 Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of adminstrative users. command_directory: [/usr/sbin] postfix 的 command 放在裡 Please specify the final destination directory for Postfix queues. queue_directory: [/var/spool/postfix] postfix 的處理信件的 queue 目錄 Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface. sendmail_path: [/usr/sbin/sendmail] sendmail 的程式位置,若不知道請按 [Enter] Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent. newaliases_path: [/usr/bin/newaliases] sendmail 產生別名的程式,若不知道請按 [Enter] Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command. mailq_path: [/usr/bin/mailq] sendmail 查看 mail 佇列的情況程式,若不知道請按 [Enter] Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system. mail_owner: [postfix] postfix 執行期間的使用者 Please specify the group for mail submission and for queue management commands. Specify a group name with a numerical group ID that is not shared with other accounts, not even with the Postfix mail_owner account. You can no longer specify "no" here. setgid_group: [postdrop] postfix 的群組 (SGID) Please specify the destination directory for the Postfix HTML files. Specify "no" if you do not want to install these files. html_directory: [no] Please specify the destination directory for the Postfix on-line manual pages. You can no longer specify "no" here. manpage_directory: [/usr/local/man] Please specify the destination directory for the Postfix README files. Specify "no" if you do not want to install these files. readme_directory: [no] Warning: you still need to edit myorigin/mydestination/mynetworks parameter settings in /etc/postfix/main.cf. See also http://www.postfix.org/faq.html for information about dialup sites or about sites inside a firewalled network. BTW: Check your /etc/aliases file and be sure to set up aliases that send mail for root and postmaster to a real person, then run /usr/bin/newaliases. [root@rhel200 postfix-2.1.5]#
|
[root@rhel200 postfix]# echo "/usr/sbin/postfix start" >> /etc/rc.d/rc.local [root@rhel200 postfix]# |
編輯設定檔
[root@rhel200 postfix]# cd /etc/postfix [root@rhel200 postfix]# vi main.cf ________________________________________________ # 設定本機的 host name myhostname = ms1.abc.com.tw # 設定 domain 網域 mydomain = abc.com.tw # 設定幫忙 relay 的 hosts mynetworks = 192.168.1.0/24, 127.0.0.0/8 # 設定本機要接收的 mail, 同 sendmail 的 local-host-names mydestination = abc.com.tw ________________________________________________ [root@rhel200 postfix]# |
[root@rhel200 postfix]# postfix start postfix/postfix-script: starting the Postfix mail system [root@rhel200 postfix]# |
查看 postfix 是否在聽 25 port
[root@rhel200 postfix]# netstat -ntulp | grep :25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 6462/master [root@rhel200 postfix]# |
POP3 Service
安裝好了 MTA 之後, 那麼現在除了使用 mail, mutt 等套件來開之外, 其實是無法使用 Outlook 或是 Thunderbird 等相關的 MUT 來使用 POP 協定收信, 在這個章節, 我們將示範如何讓你的 Mail Server 也支援 POP 服務.
我們在此, 使用 CentOS 4 來做示範, 其它如 Redhat Enterprise Linux 4, Fedora Core 1 ~ Fedora Core 3 都可以使用.
以 CentOS 4 來做示範的原因, 是因為他的 POP 套件有所更改, 以前要讓系統支援 POP 服務, 只需安裝一個 imap 套件, 並修改 /etc/xinetd.d 裡的 ipop3 設定檔即可, 但自從 Fedora Core 1 開始, 就使用 dovecot 來取代 imap, 當然, 設定方法也有所不同, 不過方便的設, 現在 imap 和 pop 服務都可以在 /etc/dovecot.conf 修改就可以了!
本文章取自小弟的網站: http://www.l-penguin.idv.tw/~steven/article/postfix_install.htm, 若需要轉貼請註明出處: http://www.l-penguin.idv.tw/