歡迎您光臨本站 註冊首頁

RedHAT 4+Postfix+dovecot+SASL+Apache+Openwebmail 完全安裝配置與測試

之前就該問題進行過提問,不過已經得到解決,現將步驟分享出來

RedHAT 4+Postfix+dovecot+SASL+Apache+Openwebmail 完全安裝配置與測試

1、安裝Postfix
# rpm -ivh postfix-2.2.10-1.2.1.el4_7.i386.rpm
warning: postfix-2.2.10-1.2.1.el4_7.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ###########################################
   1:postfix                ###########################################
postfix: warning: My hostname shanghai is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
postfix: fatal: config variable inet_interfaces: host not found: localhost


2、進入到/etc/init.d目錄啟動Postfix服務
# ./postfix start
Starting postfix:                                          [  OK  ]
# ./postfix start
Starting postfix:                                          
是由於配置文件的問題
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost    ---把這個註釋掉即可成功啟動

3、查看系統是否有安裝dovecot軟體包,若沒有則安裝,可考慮從自帶的ISO鏡像盤裝,也可去google搜一下
   個人認為像這些老外開發的軟體去google搜比較容易找到
# rpm -qa|grep dovecot
dovecot-0.99.11-9.EL4

4、進入到/etc/init.d目錄啟動dovecot服務
# ./dovecot start
Starting Dovecot Imap:                                     [  OK  ]

5、進入到/etc目錄修改dovecot.conf文件
# vi dovecot.conf

# Protocols we want to be serving:
#  imap imaps pop3 pop3s
#protocols = imap imap3
更改為:
protocols = imap imap3 pop3 pop3s
# ./dovecot restart
Stopping Dovecot Imap:                                     [  OK  ]
Starting Dovecot Imap: Fatal: Unknown protocol imap3                 ---啟動失敗是因為不支持imap3的協議,取消掉即可
                                                           
把protocols = imap pop3 pop3s的imap3去掉即可啟來
# ./dovecot start
Starting Dovecot Imap:                                     [  OK  ]


6、進入到/etc/postfix目錄下對main.cf文件進行修改
# other configuration parameters.
#
#myhostname = host.domain.tld         8%的地方
更改為:            
myhostname = mail.test.com            (指定運行Postfix郵件系統的主機名稱)
#myhostname = virtual.domain.tld


# parameters.
#
#mydomain = domain.tld                8%的地方
更改為:                        
mydomain = test.com                   (指定Postfix郵件系統使用的域名比例: test.com)

# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
#myorigin = $mydomain                  10%的地方
更改為:
myorigin = test.com                   (指定發件人所在的域名比例:test.com)

# RECEIVING MAIL

# Note: you need to stop/start Postfix when this parameter changes.
#
#inet_interfaces = all                   12%的地方
更改為:
inet_interfaces = all                 (指定Postfix郵件系統監視的網路介面)


#mydestination = $myhostname, localhost.$mydomain, localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
更改為:                                  22%的地方
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
        mail.$mydomain, www.$mydomain, ftp.$mydomain

# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#mynetworks_style = class
#mynetworks_style = subnet
#mynetworks_style = host                   33%的地方
更改為:
mynetworks_style = host


7、埠25測試
# telnet mail.test.com 25
Trying 192.168.1.106...
Connected to mail.test.com (192.168.1.106).
Escape character is '^]'.
220 mail.test.com ESMTP Postfix
quit
221 Bye
Connection closed by foreign host.
#

8、啟動 apache
# service httpd start
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 192.168.1.106 for ServerName
                                                           [  OK  ]
#


9、安裝openwebmail前需要安裝如下軟體,且這三個軟體都是自帶ISO里的
# ls -l perl-suidperl*
-r--r--r--  73 root root 113911 Apr  3 00:40 perl-suidperl-5.8.5-49.el4.i386.rpm
# ls -l perl-Compress*
-r--r--r--  204 root root 55299 Jul 13  2007 perl-Compress-Zlib-1.42-1.el4.i386.rpm
# ls -l perl*
-r--r--r--   73 root root 12360272 Apr  3 00:40 perl-5.8.5-49.el4.i386.rpm

以下兩個軟體需要在google里搜到
# ls -l perl-Text*
ls: perl-Text*: No such file or directory
# ls -l perl-CGI*
ls: perl-CGI*: No such file or directory

# rpm -ivh perl-suidperl-5.8.5-49.el4.i386.rpm
warning: perl-suidperl-5.8.5-49.el4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ###########################################
   1:perl-suidperl          ###########################################
# rpm -ivh perl-Compress-Zlib-1.42-1.el4.i386.rpm
warning: perl-Compress-Zlib-1.42-1.el4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ###########################################
        package perl-Compress-Zlib-1.42-1.el4 is already installed
# rpm -ivh perl-5.8.5-49.el4.i386.rpm
warning: perl-5.8.5-49.el4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ###########################################
        package perl-5.8.5-49.el4 is already installed
# rpm -ivh perl-CGI-SpeedyCGI-2.22-1.2.el4.rf.i386.rpm
warning: perl-CGI-SpeedyCGI-2.22-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing...                ###########################################
   1:perl-CGI-SpeedyCGI     ###########################################
# rpm -ivh perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm
warning: perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing...                ###########################################
   1:perl-Text-Iconv        ###########################################
#

# rpm -ivh openwebmail-2.51-1.i386.rpm
warning: openwebmail-2.51-1.i386.rpm: V3 DSA signature: NOKEY, key ID cfb164d8
Preparing...                ###########################################
   1:openwebmail            ###########################################

You may login with non-root account from
http://shanghai/cgi-bin/openwebmail/openwebmail.pl
# cd /var/www/cgi-bin/openwebmail/
# ls
auth                      openwebmail-main.pl     openwebmail-vdomain.pl
etc                       openwebmail.pl          openwebmail-viewatt.pl
misc                      openwebmail-prefs.pl    openwebmail-webdisk.pl
modules                   openwebmail-read.pl     preload.pl
openwebmail-abook.pl      openwebmail-saprefs.pl  quota
openwebmail-advsearch.pl  openwebmail-send.pl     shares
openwebmail-cal.pl        openwebmail-spell.pl    userstat.pl
openwebmail-folder.pl     openwebmail-tool.pl     vacation.pl
# ./openwebmail --init     --第一次自己裝的時候執行到這步就任何反應,所以就往下執行
  Please change './etc/dbm.conf' from
   
     dbm_ext            .db
     dbmopen_ext          none
     dbmopen_haslock        no
   
     to
   
     dbm_ext            .db
     dbmopen_ext          .db
     dbmopen_haslock        no
   
   
     And execute './openwebmail-tool.pl --init' again!
   
     ps: If you are running openwebmail in persistent mode,
       don't forget to 'touch openwebmail*.pl', so speedycgi
       will reload all scripts, modules and conf files in --init.
理論上執行了上述命令後會出現以上信息,但我這次沒出現,先不管它

10、修改 /var/www/cgi-bin/openwebmail/etc/openwebmail.conf 文件:

# To set options on per user basis, please put them in users.conf/username
#
releasedate                     20050228
domainnames        auto
更改為:
domainnames                     test.com      (更改為自己定義的域名)


# Personal Information
default_language                en              21%的地方
更改為:
default_language                zh_CN.GB2312
default_timeoffset              auto


# Display Preference
default_style                   Default
default_iconset                 Cool3D.Englist   34%的地方
更改為:
default_iconset                 Cool3D.Chinese.Simplified



11、修改/var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf文件:
# host dependent configuration
##############################################################################
domainnames             auto
smtpserver            127.0.0.1       6%的地方
更改為:
smtpserver            192.168.1.106 (更改smtp伺服器的地址)



pop3_usessl_by_default  no
authpop3_server            localhost         49%的地方
更改為:
authpop3_server         192.168.1.106
authpop3_port           110


12、修改/var/www/cgi-bin/openwebmail/etc/defaults/dbm.conf文件:
dbmopen_ext            none
更改為:
dbm_ext                 .db
dbmopen_ext              .db

dbmopen_haslock            no
更改為:
dbmopen_haslock            yes
smtpserver              192.168.1.106        (添加smtp伺服器的地址)

最好將dbm.conf拷貝一份到/var/www/cgi-bin/openwebmail/etc目錄下

13、再次執行命令並解決問題
# ./openwebmail-tool.pl --init
# ls
在這裡仍然沒出來所需要的界面,需要修改如下地方:
# more /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled        ---修改成disabled,原來是enforcing
重新再執行上面命令

# ./openwebmail-tool.pl --init

creating db /var/www/cgi-bin/openwebmail/etc/maps/b2g ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar ...done.
Welcome to the Open WebMail!

This program is going to send a short message back to the developer,
so we could have the idea that who is installing and how many sites are
using this software, the content to be sent is:

OS: Linux 2.6.9-89.ELsmp i686
Perl: 5.008005
WebMail: Open WebMail 2.51 20050228

Send the site report?(Y/n)
sending report...

Thank you.

# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

14、用IE訪問http://192.168.1.106/cgi-bin/openwebmail/openwebmail.pl,即可看到成功打開openwebmail的登陸界面


15、增加限制用戶發送電子郵件的許可權
Fandy:不受發送限制(可以無限制的發送和接收Internal、internet的電子郵件)
Yer、Biao:受到發送限制(只可以發送和接收Internal內的電子郵件);

# useradd fandy
# useradd yer
# useradd biao
# passwd yer
Changing password for user yer.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# passwd fandy
Changing password for user fandy.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# passwd biao
Changing password for user biao.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
#


16、在main.cf文件中增加以下的代碼:
# vi /etc/postfix/main.cf   
     # restrictions
     smtpd_restriction_classes = local_only
     local_only = check_recipient_access hash:/etc/postfix/local_domains, reject

     smtpd_recipient_restrictions =check_sender_access hash:/etc/postfix/local_senderspermit_mynetworks,permit_sasl_authenticated,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unauth_destination,reject_unauth_pipelining,reject_invalid_hostname


# vi local_senders

yer@test.com      local_only
biao@test.com     local_only
~

# vi local_domains
test.com       OK
mail.test.com  OK

為local_senders、local_domains兩個文件建立hash:
# postmap hash:/etc/postfix/local_senders
# postmap hash:/etc/postfix/local_domains
#

當yer@test.com和biao@test.com兩個用戶向其它域發送郵件時會出現以下的
錯誤信息:
   
554 5.7.1 <yer@test.com>: Sender address rejected: Access denied
554 5.7.1 <biao@test.com>: Sender address rejected: Access denied

17、測試webmail方式收發郵件
http://mail.test.com/cgi-bin/openwebmail/openwebmail.pl
http://192.168.1.106/cgi-bin/openwebmail/openwebmail.pl




18、網路配置
# vi ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29:B9:04:E4
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=localhost.localdomain
IPADDR=192.168.1.106
NETMAST=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.254

# more /etc/resolv.conf
#search test.com
nameserver 192.168.1.106
nameserver 202.96.209.6
#

這樣的話,就可以通過這台虛擬機ping www.sina.com(外)和ping www.test.com(內)

使用fandy發郵件到caowei@shbeilian.com, 這個時候caowei可以收到所發的郵件
《解決方案》

使用yum 實現的一些配置應該是比較的便捷的
《解決方案》

:em21: yum方便了我們,但換個系統沒有yum就又糊塗了
《解決方案》

呵呵,這種搭配在 CU上到處都是
《解決方案》

:m01: :m01: :m01:
《解決方案》

不錯,不過最好換成虛擬用戶的,現在一般都用虛擬用戶

[火星人 ] RedHAT 4+Postfix+dovecot+SASL+Apache+Openwebmail 完全安裝配置與測試已經有696次圍觀

http://coctec.com/docs/service/show-post-21565.html