Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3926998
  • 博文数量: 421
  • 博客积分: 685
  • 博客等级: 上将
  • 技术积分: 3670
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-18 14:20
文章分类

全部博文(421)

文章存档

2012年(5)

2011年(52)

2010年(83)

2009年(67)

2008年(65)

2007年(149)

分类: LINUX

2009-05-14 16:05:24

7、安装 postfix
[root @ test root] # groupadd -g 2525 postfix
[root @ test root] # useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root @ test root] # groupadd -g 2526 postdrop
[root @ test root] # useradd -g postdrop -u 2526 -s /bin/false -M postdrop
[root @ test root] # service sendmail stop
[root @ test root] # mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
[root @ test root] # mv /usr/bin/mailq /usr/bin/mailq.OFF
[root @ test root] # mv /usr/bin/newaliases /usr/bin/newaliases.OFF
[root @ test root] # tar zxvf postfix-2.4.5.tar.gz
[root @ test root] #cd postfix-2.4.5
[root @ test postfix-2.4.5] # make makefiles 'CCARGS=-DHAS_MYSQL
-I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl -I/usr/local/BerkeleyDB/include  -DUSE_TLS -I/usr/local/ssl/include/openssl ' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/BerkeleyDB/lib -L/usr/local/ssl/lib -lssl -lcrypto'
[root @ test postfix-2.4.5] # make
//**************************** 注 意 ***********************************
注意:在编译时出现如下错误:

这是由于 postfix 找不到 mysql 的头文件所致,解决方法:
[root @test postfix-2.4.5] # mkdir /usr/local/mysql/include/mysql
[root @test postfix-2.4.5] # ln –s /usr/local/mysql/include/* /usr/local/mysql/include/mysql
[root @ test postfix-2.4.5] # chown –R mysql.mysql /usr/local/mysql/include/mysql
3、        出现如下错误:

这是由于 postfix 找不到 mysql 的库文件引起,解决方法:
[root @test ~] # mkdir /usr/local/mysql/lib/mysql
[root @test ~] # ln –s /usr/local/mysql/lib/* /usr/local/mysql/lib/mysql
[root @test ~] # chown –R mysql.msyql /usr/local/mysql/lib/mysql
*******************************************************************\\\\\
[root @ test postfix-2.4.5] # make install
Install_root: [/]
tempdir: [/root/ postfix-2.4.5]
config_directory: [/etc/postfix]
daemon_directory: [/usr/libexec/postfix]
command_directory: [/usr/sbin]
queue_directory: [/var/spool/postfix]
sendmail_path: [/usr/sbin/sendmail]
newaliases_path: [/usr/bin/newaliases]
mailq_path: [/usr/bin/mailq]
mail_owner: [postfix]
setgid_group: [postdrop]   
html_directory: [no]
manpages: [/usr/local/man]   
readme_directory: [no]
上面的选项全部保持默认,直接回车即可。

/////************************* 注 意 ***********************************
在这一步如果出现在:
tempdir: [/root/ postfix-2.4.5]
config_directory: [/etc/postfix]
daemon_directory: [/usr/libexec/postfix]
command_directory: [/usr/sbin]
queue_directory: [/var/spool/postfix]
sendmail_path: [/usr/sbin/sendmail]
newaliases_path: [/usr/bin/newaliases]
mailq_path: [/usr/bin/mailq]
mail_owner: [postfix]
setgid_group: [postdrop]   
html_directory: [no]
manpages: [/usr/local/man]   
readme_directory: [no]
在 [ ] 没有内容显示的情况下,那么请注意看 postfix 的报错,如下图所示

如图中红色框选处所示, postfix 提示在在加载共享库文件 libssl.so.0.9.8 时,发生错误,错误的原因是没有此文件,此时你就在系统中找一下,是否存在此文件啦,如果没有的话,就要安装啦,这个库文件与 openssl 有关。本例中此文件存放于 /usr/local/ssl/lib/ 目录下,这里需要将此目录写入到 /etc/ld.so.conf 文件中,然后运行 ldconfig 命令加载。步骤如下:
[root @test ~] # echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
[root @test ~] # ldconfig
********************************************************************\\\\\\

生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:
[root @ test postfix-2.4.5] #  newaliases
配置 postfix
[root @ test postfix-2.4.5] # vi /etc/postfix/main.cf
myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
inet_interfaces = all
mynetworks = 192.168.98.0/24, 127.0.0.0/8
#================Virtual Setting ====================
virtual_mailbox_base = /var/mailbox/
virtual_mailbox_maps= mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains=mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:2525
virtual_gid_maps = static:2525
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
#=================Quota Setting ====================
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry,the user's maildir has overdrawn his diskspace quota,please Tidy your mailbox and try again later.
virtual_overquota_bounce = yes
#=================== Cyrus-sasl=====================
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname,reject_non_fqdn_hostname, reject_unknown_sender_domain,reject_non_fqdn_sender, reject_non_fqdn_recipient,reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination, permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP, Warning:Version not Available!
[root @ test postfix-2.4.5] # mkdir -p /etc/postfix/mysql
[root @ test postfix-2.4.5] # cd /etc/postfix/mysql
[root @ test mysql] # vi mysql_virtual_alias_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
[root @ test mysql] #   vi mysql_virtual_mailbox_limit_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = quota
where_field = username
[root @ test mysql] # vi mysql_virtual_domains_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = description
where_field = domain
[root @ test mysql] # vi mysql_virtual_mailbox_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username

8、安装 courier-authlib
[root @ test root] #  tar jxvf courier-authlib-0.58.tar.bz2
[root @ test root] #  cd courier-authlib-0.58
[root @ test courier-authlib-0.58] # ./configure     --prefix=/usr/local/courier-authlib         --without-authpam --without-authldap --without-authpwd     —without-authshadow --without-authvchkpw --without-authpgsql –with-authmysql  —with-mysql-libs=/usr/local/mysql/lib/mysql —with-mysql-includes=/usr/local/mysql/include/mysql —with-redhat
CFLAGS="-march=i686 -O2 -fexpensive-optimizations"  \
  CXXFLAGS="-march=i686 -O2 -fexpensive-optimizations"

////**************************** 注 意 *****************************
注:如在此步中出现以下错误:

这是由于 courier-atuhlib 默认是从 /usr/lib 寻找 mysql 的库文件
解决方法:将 –with-authmysql 后面设置参数,例:--with-authmysql=/usr/local/mysql/lib/mysql
*************************************************************\\\\\\\\\\\\

[root @ test courier-authlib-0.58] # make
[root @ test courier-authlib-0.58] # make install

[root @ test courier-authlib-0.58] # chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[root @ test courier-authlib-0.58] # cp /usr/local/courier-authlib/etc/authlib/authdaemonrc.dist  /usr/local/courier-authlib/etc/authlib/authdaemonrc
[root @ test courier-authlib-0.58] # cp /usr/local/courier-authlib/etc/authlib/authmysqlrc.dist  /usr/local/courier-authlib/etc/authlib/authmysqlrc

修改authdaemonrc 文件
[root @ test courier-authlib-0.58] # vi /usr/local/courier-authlib/etc/authlib/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10

编辑authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的UID和GID。
[root @ test courier-authlib-0.58] # vi /usr/localcourier-authlib/etc/authlib/authmysqlrc
MYSQL_SERVER localhost
MYSQL_PORT 3306                   (指定你的mysql监听的端口,这里使用默认的3306)
MYSQL_USERNAME  extmail      (这时为后文要用的数据库的所有者的用户名)
MYSQL_PASSWORD extmail        (密码)
MYSQL_SOCKET  /tmp/mysql.sock
MYSQL_DATABASE  extmail
MYSQL_USER_TABLE  mailbox
MYSQL_CRYPT_PWFIELD  password
MYSQL_UID_FIELD  '2525'
MYSQL_GID_FIELD  '2525'
MYSQL_LOGIN_FIELD  username
MYSQL_HOME_FIELD  concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD  name
MYSQL_MAILDIR_FIELD  concat('/var/mailbox/',maildir)
注:这个文件中不能出现空格,或者会出现 FAQ 中的示例4 中的错误。
设置 courier-authlib 自启动
[root @ test courier-authlib-0.58] # cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root @ test courier-authlib-0.58] # chmod 755 /etc/init.d/courier-authlib
[root @ test courier-authlib-0.58] # chkconfig —add courier-authlib
[root @ test courier-authlib-0.58] # chkconfig —level 2345 courier-authlib on
[root @ test courier-authlib-0.58] #echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
[root @ test courier-authlib-0.58] # ldconfig
[root @ test courier-authlib-0.58] # service courier-authlib start   (启动服务)

9、安装Courier-IMAP

[root @ test root] # tar jxvf courier-imap-4.1.3.tar.bz2
[root @ test root] # cd courier-imap-4.1.3
[root @ test courier-imap-4.1.3] #./configure   —prefix=/usr/local/imap   —with-redhat   —enable-unicode   —disable-root-check   —with-trashquota   CPPFLAGS='-I/usr/local/ssl/include/openssl  -I/usr/local/courier-authlib/include'   
  LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib'  
  COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'
[root @ test courier-imap-4.1.3] # make

/////***************************** 注 意 *****************************
如果在这一步出现以下错误不:

因为编译安装的openssl的头文件链接指定问题。默认情况下,courier-imap编译时到/usr/include下查找openssl的头文 件,到/usr/lib 下查找 openssl 的库文件,这里你要查找在这两个目录下是否存在 openssl 的库文件与头文件,openssl 的头文件是 /usr/include/openssl 该文件是链接到 /urs/local/ssl/include/openssl 。openssl的库文件是 /usr/lib/libssl.so 该文件是链接到 /usr/local/ssl/lib/libssl.so.0.9.8 。如没有的,请自行链接,如下:
[root @test ~] # ln –s /usr/local/ssl/include/openssl /urs/include/openssl
[root @test ~] # ln –s /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
*********************************************************\\\\\\\
[root @ test courier-imap-4.1.3] # make install
[root @ test courier-imap-4.1.3] # cp /usr/local/imap/etc/imapd.dist /usr/local/imap/etc/imapd
[root @ test courier-imap-4.1.3] # cp /usr/local/imap/etc/imapd-ssl.dist /usr/local/imap/etc/imapd-ssl
[root @ test courier-imap-4.1.3] # cp /usr/local/imap/etc/pop3d.dist /usr/local/imap/etc/pop3d
[root @ test courier-imap-4.1.3] # cp /usr/local/imap/etc/pop3d-ssl.dist /usr/local/map/etc/pop3d-ssl
配置Courier-IMAP,为用户提供pop3服务:
[root @ test courier-imap-4.1.3]  # vi /usr/local/imap/etc/pop3d
POP3DSTART=YES

注:如果你想为用户提供IMAP服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes";其它类同;

新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
[root @ test courier-imap-4.1.3]  # mkdir –p /var/mailbox
[root @ test courier-imap-4.1.3]  #chown –R postfix /var/mailbox

[root @ test courier-imap-4.1.3]  # cp courier-imap.sysvinit /etc/rc.d/init.d/imapd
[root @ test courier-imap-4.1.3]  # chmod 755 /etc/rc.d/init.d/imapd
[root @ test courier-imap-4.1.3]  # chkconfig —add imapd
[root @ test courier-imap-4.1.3]  # chkconfig —level 2345 imapd on
[root @ test courier-imap-4.1.3]  # service imapd start

接下来重新配置SMTP 认证,编辑 /usr/local/lib/sasl2/smtpd.conf ,确保其为以下内容:
[root @ test courier-imap-4.1.3]  # vi /usr/local/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
10、安装 extmail
[root @test root] # tar zxvf extmail-1.0.2.tar.gz
[root @test root] # mkdir -pv /var/www/extsuite
[root @test root] # mv extmail-1.0.2 /var/www/extsuite/extmail
[root @test root]# cp /var/www/extsuite/extmail/webmail.cf.default  /var/www/extsuite/extmail/webmail.cf
修改主配置文件
[root @test root] # vi /var/www/extsuite/extmail/webmail.cf

部分修改选项的说明:

SYS_MESSAGE_SIZE_LIMIT = 5242880
用户可以发送的最大邮件

SYS_USER_LANG = en_US
语言选项,可改作:
SYS_USER_LANG = zh_CN

SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /var/mailbox/

SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail

SYS_MYSQL_HOST = localhost
指明数据库服务器主机名,这里默认即可

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
连接数据库的sock文件位置,这里修改为:
SYS_MYSQL_SOCKET = /tmp/mysql.sock


SYS_MYSQL_TABLE = mailbox
SYS_MYSQL_ATTR_USERNAME = username
SYS_MYSQL_ATTR_DOMAIN = domain
SYS_MYSQL_ATTR_PASSWD = password
以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称;这里默认即可

SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
此句用来指明authdaemo socket文件的位置,这里修改为:
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket


apache相关配置
[root @test root] # vi /usr/local/apache/conf/httpd.conf
将 User daemon
Group daemon
改为
User postfix
Group postfix
将Include conf/extra/httpd-vhosts.conf
前的注释去掉,打开 apache 的虚拟主机功能。
# virtual hosts
Include conf/extra/httpd-vhosts.conf

编辑虚拟主机配置文件
[root @test root]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf

ServerName mail.test.com
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html


依赖关系的解决

extmail将会用到perl的DBD::Mysql和Unix::syslogd功能,您可以去搜索下载原码包进行安装。
[root @ test root] # tar zxvf Unix-Syslog-0.100.tar.gz
[root @ test root] # cd Unix-Syslog-0.100
[root @ test Unix-Syslog-0.100] # perl Makefile.PL
[root @ test Unix-Syslog-0.100] # make
[root @ test Unix-Syslog-0.100] # make install

DBD-Mysql目前最新的版本为DBD-mysql-4.005,但它和系统中的perl结合使用时会造成extmail无法正常使用,因此我们采用3的版本:
[root @ test root] # tar zxvf DBD-mysql-3.0002_4.tar.gz  
[root @ test root] # cd DBD-mysql-3.0002_4
[root @ test DBD-mysql-3.0002_4] # perl Makefile.PL   (此步骤中如果出现类同Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.的错误是因为您的mysql的bin目录没有输出至$PATH环境变量)
[root @ test DBD-mysql-3.0002_4] # make

//////************************** 注 意 *******************************
如编译时出现如下错误:
        这是由于 DBD-mysql 默认是从 /usr/lib/mysql 查找 mysql 的库文件,而我们的 mysql 的库文件是存放在 /usr/local/mysql/lib/mysql 目录下,解决方法:
[root @test ~] # mv /usr/llib/mysql /usr/lib/mysql.bak
[root @test ~] # mkdir /usr/lib/mysql
[root @test ~] # ln –s /usr/local/mysql/lib/* /usr/lib/mysql
***********************************************************\\\\\\\\\\\\\\\\\\\
[root @ test DBD-mysql-3.0002_4] # make install

好了,到此为止,您的Webmail已经可以使用了,可以在浏览器中输入指定的虚拟主机的名称进行访问,如下:

注:要在 DNS 服务器已经配置好,并运行正常的情况下才可以用域名访问,如果没有配置 DNS 服务,直接输入 IP 就行了



以下这些博文,你可能同样感兴趣:

    
阅读(1688) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~