当前位置: 首页IT技术操作系统 → 详解Linux下的postfix安装

详解Linux下的postfix安装

更多

   邮件系统简介

   邮件系统组成部分: MTA MSA ,MUA,MDA,MAA

   1 MUA :是Mial User Agent 的简称 ,是邮件系统的客户端程序,它提供了阅读,发送和接受电子邮件的用户接口,如:linux中的Mail ,Windowns中的Foxmail,Outlook 等

   2 MSA :是Mail Submmission Agent的简称。是邮件提交代理,负责消息有MTA发送之前必须完成所有准备工作和错误检测,MSA是在MUA和MTA之间插入了一个头脑清醒的检测员,对所有的主机名,从MUA 得到的头信息等信息进行检测

   3 MTA:是Mail Transfer Agent 的简称,邮件转发代理,负责邮件的存储和转发;监视用户的代理请求,根据电子邮件的目标地址找出对应的电子邮件服务器,并将信件在服务器之间传输并且将接受到的邮件进行缓冲。Linux 下有sendmail .Postfix,qmail 等

   4 MDA :是Mail Ddlivery Agent 的简称。邮件投递代理,从MTA接受邮件并进行适当的本地投递,可以投递一个本地用户,一个邮件列表,一个文件或者是一个程序

   5 MAA :是Mail access Agent。邮件访问代理,用于将用户连接到系统邮件库,使用POP或者Imap协议收取邮件。Linux 下常用的MAA有,Cyrus-IMAP,COURIER-IMAP等邮件中继,当邮件的目的传输是一旦源地址和目的地址都不是本地系统,那么本地系统就是邮件中继站(即是中转站)

  注意:在安装postfix或多或少遇到一些error,我在文档

  http://1413570.blog.51cto.com/1403570/780703

  记录了一部分

  或许记录的不完全,再遇到error时,可以多查找一些资料文件

  第一:安装cmake工具

  安装步骤一点点的来,先从LAMP平台来安装,先安装mysql,我这是一台新安装的linux系统,所以遇到的问题可能会比较多一点

  因为mysql自5.5版本以后都是需要借助工具cmake,所以先从安装cmake工具开始

  解压cmake的包,之后编译安装即可

  [root@server250 cmake-2.8.4]# ./configure && make && make install

  中间过程

  [ 56%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_enum.o

  [ 56%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_int.o

  [ 56%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_ipv4.o

  [ 57%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_num.o

  [ 57%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_regex.o

  Linking C static library libcmForm.a

  第二安装mysql

  Ok,之后开始安装mysql,先建立mysql的用户名,组名

  [root@server250 ~]# groupadd mysql

  [root@server250 ~]# useradd -g mysql -s /sbin/nologin -M mysql

  [root@server250 postfix]# tar zxvf mysql-5.5.19.tar.gz

  [root@server250 mysql-5.5.19]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_TCP_PORT=3306

  cp support-files/my-medium.cnf /etc/my.cnf

  [root@server250 mysql]# chown -R mysql:mysql /usr/local/mysql/

  [root@server250 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/

  Installing MySQL system tables...

  OK

  Filling help tables...

  OK

  [root@server250 ~]# echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf

  [root@server250 ~]# ldconfig -v

  [root@server250 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

  cp:是否覆盖“/etc/init.d/mysqld”? y

  [root@server250 ~]# chmod 755 /etc/init.d/mysqld

  [root@server250 ~]#

  [root@server250 ~]#

  [root@server250 ~]# service mysqld start

  [root@server250 ~]# netstat -anpt | grep 3306

  tcp 0 0 :::3306 :::* LISTEN 27783/mysqld

  设置mysql的密码

  [root@server250 ~]# mysqladmin -u root password "biao_123"

  第三安装cyrus-sasl

  [root@server250 postfix]# tar zxvf cyrus-sasl-2.1.22.tar.gz

  [root@server250 cyrus-sasl-2.1.22]# ./configure --prefix=/usr/local/sasl2 --disable-gssapi --disable-anon --disable-digest --enable-plain --enable-login --enable-sql --with-mysql=/usr/local/mysql/ --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-mysql-libs=/usr/local/mysql/lib --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket

  config.status: creating Makefile

  config.status: creating saslauthd.h

  config.status: executing depfiles commands

  Configuration Complete. Type 'make' to build.

  到这里就可以了

  Make && make install

  gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../lib -I../sasldb -I../include -I/usr/local/mysql//include/mysql -Wall -W -g -O2 -MT sql.lo -MD -MP -MF .deps/sql.Tpo -c sql.c -fPIC -DPIC -o sql.lo

  sql.c:65:19: error: mysql.h: No such file or directory

  解决办法:

  在你的路径:I/usr/local/mysql//include/mysql 下面看看有没有 .h的文件,没有的话,在mysql是上一层目录中,有这些文件,拷贝一份到mysql下

  [root@server250 include]# cp *.sh mysql

  Make && make install

  这个安装好后,要关掉系统自带的sasl2

  mv /usr/lib/libsasl2.a /usr/lib/libsasl2.a.bak

   mv /usr/lib/libsasl2.so.2.0.22 /usr/lib/libsasl2.so.2.0.22.OFF、

  mv /usr/lib/sasl2 /usr/lib/sasl2.OFF

  重新创建新编译的sasl库文件

  [root@server250 ~]# ln -sv /usr/local/sasl2/lib/* /usr/lib/

  创建指向“/usr/local/sasl2/lib/libsasl2.la”的符号链接“/usr/lib/libsasl2.la”

  创建指向“/usr/local/sasl2/lib/libsasl2.so”的符号链接“/usr/lib/libsasl2.so”

  ln: 正在创建指向“/usr/local/sasl2/lib/libsasl2.so”的符号链接“/usr/lib/libsasl2.so”: 文件已存在

  创建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符号链接“/usr/lib/libsasl2.so.2”

  ln: 正在创建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符号链接“/usr/lib/libsasl2.so.2”: 文件已存在

  创建指向“/usr/local/sasl2/lib/libsasl2.so.2.0.22”的符号链接“/usr/lib/libsasl2.so.2.0.22”

  创建指向“/usr/local/sasl2/lib/sasl2”的符号链接“/usr/lib/sasl2”

  [root@server250 ~]# ln -sv /usr/local/sasl2/lib/* /usr/local/lib

  创建指向“/usr/local/sasl2/lib/libsasl2.la”的符号链接“/usr/local/lib/libsasl2.la”

  创建指向“/usr/local/sasl2/lib/libsasl2.so”的符号链接“/usr/local/lib/libsasl2.so”

  创建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符号链接“/usr/local/lib/libsasl2.so.2”

  创建指向“/usr/local/sasl2/lib/libsasl2.so.2.0.22”的符号链接“/usr/local/lib/libsasl2.so.2.0.22”

  创建指向“/usr/local/sasl2/lib/sasl2”的符号链接“/usr/local/lib/sasl2”

  [root@server250 ~]# ln -sv /usr/local/sasl2/include/sasl/* /usr/local/include/

  创建指向“/usr/local/sasl2/include/sasl/hmac-md5.h”的符号链接“/usr/local/include/hmac-md5.h”

  创建指向“/usr/local/sasl2/include/sasl/md5global.h”的符号链接“/usr/local/include/md5global.h”

  创建指向“/usr/local/sasl2/include/sasl/md5.h”的符号链接“/usr/local/include/md5.h”

  创建指向“/usr/local/sasl2/include/sasl/prop.h”的符号链接“/usr/local/include/prop.h”

  创建指向“/usr/local/sasl2/include/sasl/sasl.h”的符号链接“/usr/local/include/sasl.h”

  创建指向“/usr/local/sasl2/include/sasl/saslplug.h”的符号链接“/usr/local/include/saslplug.h”

  创建指向“/usr/local/sasl2/include/sasl/saslutil.h”的符号链接“/usr/local/include/saslutil.h”

  启动

  /usr/local/sasl2/sbin/saslauthd -a shadow pam

  添加到库文件

  [root@server250 local]# echo "/usr/local/sasl2/lib" >>/etc/ld.so.conf

  [root@server250 local]# echo "/usr/local/sasl2/lib/sasl2/" >> /etc/ld.so.conf

  [root@server250 local]#

  [root@server250 local]#

  [root@server250 local]#

  [root@server250 local]# ldconfig -v

  Ok

  第四编译安装apache

  完成以上后,开始安装apache

  [root@server250 postfix]# tar jxvf httpd-2.2.21.tar.bz2

  [root@server250 postfix]# ./configure --prefix=/usr/local/apache --enable-so --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon

  Make makeinstall

  第五编译安装php

  [root@server250 postfix]# tar zxvf php-5.3.6.tar.gz

  [root@server250 php-5.3.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql -with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-png-dir --with-jpeg-dir --with-zlib --with-freetype-dir --with-gd-dir --enable-mbstring=all

  [root@server250 ~]# ln -sv /usr/local/mysql/include/* /usr/local/mysql/include/mysql

  /usr/local/src/php-5.3.5/ext/mysqli/mysqli.c: In function 'zm_startup_mysqli':

  2/usr/local/src/php-5.3.5/ext/mysqli/mysqli.c:644: error: 'MYSQL_RPL_MASTER' undeclared (first use in this function)

  3/usr/local/src/php-5.3.5/ext/mysqli/mysqli.c:644: error: (Each undeclared identifier is reported only once

  4/usr/local/src/php-5.3.5/ext/mysqli/mysqli.c:644: error: for each function it appears in.)

  5/usr/local/src/php-5.3.5/ext/mysqli/mysqli.c:645: error: 'MYSQL_RPL_SLAVE' undeclared (first use in this function)

  6/usr/local/src/php-5.3.5/ext/mysqli/mysqli.c:646: error: 'MYSQL_RPL_ADMIN' undeclared (first use in this function)

  7make: *** [ext/mysqli/mysqli.lo] Error 1

  [root@server250 ~]# ln -sv /usr/local/mysql/include/* /usr/local/mysql/include/mysql

  [root@server250 php-5.3.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql -with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-png-dir --with-jpeg-dir --with-zlib --with-freetype-dir --with-gd-dir --enable-mbstring=all

  Make && make install

  第六,php+apache+mysql的整合

  Ok,安装php之后,则是可以进行修改http的文件,即是php+apache的整合

   AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  [root@localhost htdocs]# vi test.php

  

  phpinfo();

  ?>

  在directory 目录处添加index。Php和index.html在一起

  之后测试

  http://ip/test.php

  如下所示是正确的

  

  第七:安装postfix

  Ok,之上都已经完全安装了,下面就开始安装postfix

  增加用户名

  [root@server250 ~]# groupadd -g 503 postfix

  [root@server250 ~]# useradd -g postfix -u 503 postfix

  [root@server250 ~]#

  [root@server250 ~]# groupadd -g 504 postdrop

  [root@server250 ~]# useradd -g postdrop -u 504 -s /sbin/nologin -M postdrop

  [root@server250 postfix]# tar zxvf postfix-2.8.7.tar.gz

  root@localhost postfix-2.8.7]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl -DUSE_TLS -I/usr/local/ssl/include/openssl ' 'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/ssl/lib -lssl -lcrypto'

  daemon_directory: [/usr/libexec/postfix] /usr/local/postfix/libexec

  data_directory: [/var/lib/postfix] /usr/local/postfix/lib

  html_directory: [no] /var/www/postfix_html

  manpage_directory: [/usr/local/man] /usr/local/postfix/man

  修改配置文件

  /etc/postfix/main.cf

  [root@server250 ~]# /usr/sbin/postfix start

  postfix/postfix-script: starting the Postfix mail system

  [root@server250 postfix-2.8.7]# netstat -anpt | grep 25

  tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3455/master

  修改防火墙的配置文件,添加25端口

  [root@server250 ~]# vi /etc/sysconfig/iptables

   -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT

  重启防火墙

  接下来是验证postfix是否安装成功

  [root@server250 ~]# telnet localhost 25

  Trying 127.0.0.1...

  Connected to localhost.localdomain (127.0.0.1).

  Escape character is '^]'.

  220 mail.ku888.in ESMTP Postfix

  ehlo mail.ku888.in

  250-mail.ku888.in

  250-PIPELINING

  250-SIZE 10240000

  250-VRFY

  250-ETRN

  250-ENHANCEDSTATUSCODES

  250-8BITMIME

  250 DSN

  mail from:root@ku888.in

  250 2.1.0 Ok

  rcpt to:frank@ku888.in

  250 2.1.5 Ok

  data

  354 End data with .

  subject:test!!

  test!!!!!!!!!!

  .

  250 2.0.0 Ok: queued as 048B45CF00A3

  quit

  221 2.0.0 Bye

  Connection closed by foreign host.

  第八,配置postfix的虚拟用户邮箱

  验证ok后,下面开始部署安装postfix的虚拟用户和邮箱设置

  先确认下你的postfix是否支持 cyrus-sasl的认证

  [root@mail2 ~]# postconf -a

  cyrus

  Dovecot

  Ok,支持的

  下面进行设置

  [root@mail2 ~]# vi /etc/postfix/main.cf

  编辑她的配置文件

  在末尾处添加

  ############################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

  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!

  ############################END-CYRUS-SASL############################

  在sasl2的库文件中,添加认证

  [root@mail2 sasl2]# vi smtpd.conf

  pwcheck_method: saslauthd

  mech_list: PLAIN LOGIN

  ~

  重新加载postfix的配置文件,

  重新telnet ,验证下是否有加载上SASL认证

  [root@mail2 ~]# telnet localhost 25

  Trying 127.0.0.1...

  Connected to mail2.51coolbar.com (127.0.0.1).

  Escape character is '^]'.

  220 Welcome to our mail2.51coolbar.com ESMTP,Warning: Version not Available!

  ehlo localhost

  250-mail2.51coolbar.com

  250-PIPELINING

  250-SIZE 10240000

  250-VRFY

  250-ETRN

  250-AUTH PLAIN LOGIN 确保这两行的输出,否则都是有问题的

  250-AUTH=PLAIN LOGIN

  250-ENHANCEDSTATUSCODES

  250-8BITMIME

  250 DSN

  Ok,发现是加载上了

  配置虚拟用户和虚拟域

  编辑postfix的主配置文件

  ########################Virtual Mailbox Settings####################

  virtual_mailbox_base = /var/mailbox/

  virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

  virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

  virtual_alias_domains =

  virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

  virtual_uid_maps = static:509

  virtual_gid_maps = static:513

  virtual_transport = virtual

  maildrop_destination_recipient_limit = 1

  maildrop_destination_concurrency_limit = 1

  ##########################QUOTA Settings########################

  message_size_limit = 14336000

  virtual_mailbox_limit = 20971520

  virtual_create_maildirsize = yes

  virtual_mailbox_extended = yes

  virtual_mailbox_limit_maps = mysql:/etc/postfix/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

  ##############END--############################################

  添加支持虚拟域和虚拟用户所需要的配置文件

  [root@mail2 postfix]# vi mysql_virtual_domains_maps.cf

  user = extmail

  password = extmail

  hosts = localhost

  dbname = extmail

  table = domain

  select_field = description

  where_field = domain

  ~

  [root@mail2 postfix]# vi mysql_virtual_mailbox_limit_maps.cf

  user = extmail

  password = extmail

  hosts = localhost

  dbname = extmail

  table = mailbox

  select_field = quota

  where_field = username

  [root@mail2 postfix]# vi mysql_virtual_mailbox_maps.cf

  user = extmail

  password = extmail

  hosts = localhost

  dbname = extmail

  table = mailbox

  select_field = maildir

  where_field = username

  [root@mail2 postfix]# vi mysql_virtual_alias_maps.cf

  user = extmail

  password = extmail

  hosts = localhost

  dbname = extmail

  table = alias

  select_field = goto

  where_field = address

  ~

  四个配置文件

  第九,安装courier-authlib

  Ok了,下面开始安装

   courier-authlib

  [root@mail2 courier-authlib-0.63.0]# ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --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/inculde/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc CFLAGS="-march=x86-64 -O2 -fexpensive-optimizations" CXXFLAGS="-march=x86-64 -O2 -fexpensive-optimizations"

  其中有一个error,

  提示找不到expect not found - will not be able to change passwds 导致configure: error: --with-authmysql specified but no mysqlclient.so

  解决办法:

  [root@mail2 lib]# cp /usr/local/mysql/lib/libmysqlclient.so /usr/lib/libmysqlclient.so

  之后重新编译即可过去

  ./configure 过后,执行make提示authmysql.h:8:19: 错误:mysql.h:没有那个文件或目录

  authmysql.h:9:20: 错误:errmsg.h:没有那个文件或目录

  make[2]: *** [authmysql.lo] 错误 1

  Vi authmysql.h的文件

   Mysql/mysql.h

  保存即可

  [root@mail2 var]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/

  进入到目录/etc/

  [root@mail2 etc]# cp authdaemonrc.dist authdaemonrc

  [root@mail2 etc]# cp authmysqlrc.dist authmysqlrc

  编辑文件authdaemonrc

  authmodulelistorig="authmysql"

  daemons=10

  authmodulelist="authmysql"

  编辑文件authmysql

   MYSQL_SERVER 127.0.0.1

  MYSQL_USERNAME extmail

  MYSQL_PASSWORD extmail

  MYSQL_SOCKET /data/mysql/mysql.sock 数据库的监听文件

  MYSQL_PORT 3306 数据库的端口

  MYSQL_DATABASE extmail 数据库

  MYSQL_USER_TABLE mailbox 数据库的表

  MYSQL_CRYPT_PWFIELD password 加密的字段

  MYSQL_UID_FIELD 503 邮件服务的属主和属组

  MYSQL_GID_FIELD 503

  MYSQL_HOME_FIELD concat('/var/mailbox/',maildir)

  MYSQL_NAME_FIELD name

  MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)

  ourier-authlib 的库文件搜索路径,并启动courier-authlib

  [root@mail2 postfix]# /usr/local/courier-authlib/sbin/authdaemond start

  [root@mail2 postfix]# echo "/usr/local/courier-authlib/lib/courier-authlib/lib" >> /etc/ld.so.conf

  [root@mail2 postfix]# ldconfig -v

  第十安装IMAP服务,

  安装imap服务

  [root@mail2 postfix]# tar jxvf courier-imap-4.8.0.tar.bz2

  [root@mail2 ~]# ./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode --disable-root-check --with-openssl --with-trashquota --without-ipv6 CPPFLAGS='-I/usr/local/courier-authlib/include' LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'

  Make && make install

  进入到/usr/local/courier-imap/etc下面,去复制imap启动需要的配置文件

  [root@mail2 etc]# cp imapd-ssl.dist imapd-ssl

  [root@mail2 etc]# cp imapd.dist imapd

  [root@mail2 etc]# cp pop3d.dist pop3d

  [root@mail2 etc]# cp pop3d-ssl.dist pop3d-ssl

  配置courier-imap ,为用户提供服务的类型,该处为用户提供的是pop3d 服务,如果为用户提供IMAP 服务,只需要修改对应的选项

  IMAPDSTART=YES

  [root@mail2 etc]# vi pop3d

  POP3DSTART=YES

  将NO改为YES

  为虚拟用户创建邮箱所在目录,并修改权限.把其所属主改为postfix

  [root@localhost mail]# mkdir -pv /var/mailbox/

  [root@localhost mail]# chown -R postfix:postfix /var/mailbox/

  配置SMTP 认证,同样需要修改在前面创建的/usr/local/sasl2/smtpd.conf

  pwcheck_method: authdaemond

  log_level: 3

  mech_list: PLAIN LOGIN

  authdaemond_path: /usr/local/courier-authlib/var/spool/authdaemon/socket

  手动启动imap的服务

  [root@localhost mail]# /usr/local/courier-imap/libexec/pop3d.rc start

  [root@localhost mail]# /usr/local/courier-imap/libexec/imapd.rc start

  查看是否启动ok,两个端口,110和143

  [root@localhost mail]# netstat -anpt | grep 110

  tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 3822/couriertcpd

  tcp 0 20 192.168.225.180:110 89.137.252.99:21639 ESTABLISHED 30768/pop3login

  [root@localhost mail]# netstat -anpt | grep 143

  tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 3816/couriertcpd

  [root@localhost mail]# vi /etc/sysconfig/iptables

  开放110和143端口

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT

  [root@mail2 ~]# service iptables restart

  清除防火墙规则:[确定]

  把 chains 设置为 ACCEPT 策略:filter [确定]

  正在卸载 Iiptables 模块:[确定]

  应用 iptables 防火墙规则:[确定]

  载入额外 iptables 模块:ip_conntrack_netbios_ns [确定]

  第十一安装extmail

  Ok,安装完imap后,开始安装网页上的extmail软件

  [root@mail2 postfix]# tar zxvf 51CTO下载-extmail-1.2.tar.gz

  因为extmail相当于web 版的outlook,因此将其放到了apache下面的

  Mv extmail-1.2 /usr/local/apache/htdocs/extmail

  进入到/usr/local/apache/htdocs/extmail下面

  复制一份主配置文件

  [root@mail2 extmail]# cp webmail.cf.default webmail.cf

  之后修改主配置文件(根据你的实际路径进行更改)

  SYS_CONFIG = /usr/local/apache/htdocs/extmail/

  SYS_LANGDIR = /usr/local/apache/htdocs/extmail/lang

  SYS_TEMPLDIR = /usr/local/apache/htdocs/extmail/html

  SYS_USER_LANG = zh_CN

  SYS_MYSQL_USER = extmail 连接mysql数据库使用的数据库名

  SYS_MYSQL_PASS = extmail 数据库密码

  SYS_MYSQL_DB = extmail

  SYS_MYSQL_HOST = localhost

  SYS_MYSQL_SOCKET = /data/mysql/mysql.Sock 数据库的sock文件

  # table name

  SYS_MYSQL_TABLE = mailbox

  SYS_MYSQL_ATTR_USERNAME = username

  SYS_MYSQL_ATTR_DOMAIN = domain

  SYS_MYSQL_ATTR_PASSWD = password

  SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

  更改完成后,修改apache的配置文件,将其与extmail想结合

  Vi /usr/local/apache/conf/httpd.Conf

  User postfix

  Group postfix

 

   Options Indexes FollowSymLinks +ExecCGI

   AllowOverride None

   Order allow,deny

   Allow from all

 

  安装Unix-Syslog ,因为extmail 会用到DBD:syslog

  下载 Unix-Syslog-1.1.tar.gz

  http://down.51cto.com/data/329992

  下载DBD-mysql-4.020.tar.gz

  http://down.51cto.com/data/329989

  #tar xvf Unix-Syslog-1.1.tar.gz.gz

   #cd Unix-Syslog-1.1

   #perl Makefile.PL

   # make

   #make install

  cd DBD-mysql-4.020

  #perl Makefile.PL

   #make

   #make install

  Ok.之后测试extmail是否可以访问ok

  http://ip/extmail/cgi

  第十二:安装extman

  安装extman和安装extmail的方法是一样的,

  解压,mv

  Mv extman-1.1 /usr/local/apache/htdocs/extman

  复制文件

   cp webman.cf.default webman.Cf

  编辑文件

  extman]# vi webman.Cf

  SYS_CONFIG = /usr/local/apache/htdocs/extman/

  SYS_LANGDIR = /usr/local/apache/htdocs/extman/lang

  SYS_TEMPLDIR = /usr/local/apache/htdocs/extman/html

  SYS_MAILDIR_BASE = /var/mailbox/

  SYS_SESS_DIR = /var/tmp/extman/

  SYS_BACKEND_TYPE = mysql

  SYS_MYSQL_USER = extmail

  SYS_MYSQL_PASS = extmail

  SYS_MYSQL_DB = extmail

  SYS_MYSQL_HOST = 127.0.0.1

  SYS_MYSQL_SOCKET = /data/mysql/mysql.Sock

  保存退出,修改apache文件

 

   Options Indexes FollowSymLinks +ExecCGI

   AllowOverride None

   Order allow,deny

   Allow from all

 

  需重启apache,才能生效

  创建数据库,把docs 目录下面的导入到数据库中,但是在导入数据库前需要把extmail.sql 文件中的TYPE=MyISAM 改成ENGINE=MyISA

   #mysql –uroot –p

   #mysql –uroot –p

  修改cgi 目录的属主

   #chown –R postfix.Postfix /usr/local/apache/htdocs/extman/cgi/

  为extman 授权数据库访问权限

   #mysql -uroot –p

   mysql> grant all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';

  mysql> grant all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';

  之后再测试extman是否可以登录,配置文件提到的几个文件都要建立

  /var/mailbox/

  /var/tmp/extman/

  这两个目录要需要提前建立好

  第十三:搭建图形日志

  之后开始安装postfix图形日志

  下载包Time-HiRes-1.9721.tar.gz

  http://down.51cto.com/data/329630

  下载File-Tail-0.99.3.tar.gz

  http://down.51cto.com/data/329637

  下载cgilib-0.5.tar.gz

  http://down.51cto.com/data/329634

  tar zxvf Time-HiRes-1.9721.tar.gz

   Time-HiRes-1.9721]# perl Makefile.PL

  Time-HiRes-1.9721]# make

  Time-HiRes-1.9721]# make test

  [root@mail Time-HiRes-1.9721]# make test

  PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t

  t/HiRes....ok

  All tests successful.

   Time-HiRes-1.9721]# make install

  postfix]# tar zxvf File-Tail-0.99.3.tar.gz

  [root@mail postfix]# cd File-Tail-0.99.3

  [root@mail File-Tail-0.99.3]# perl Makefile.PL

  [root@mail File-Tail-0.99.3]# make && make install

  [root@mail postfix]# tar zxvf rrdtool-1.4.4.tar.gz

   #./configure --prefix=/usr/local/rrdtool

   #make

   #make install

  从目录/usr/local/apache/htdocs/extman/addon下,拷贝目录

  Cp -r /usr/local/apache/htdocs/extman/addon/mailgraph_ext /usr/local

  启动

  [root@mail ~]# /usr/local/mailgraph_ext/mailgraph-init start

  之后通过extman管理平台查看是否都ok的

热门评论
最新评论
昵称:
表情: 高兴 可 汗 我不要 害羞 好 下下下 送花 屎 亲亲
字数: 0/500 (您的评论需要经过审核才能显示)