當前位置: 首頁IT技術操作系統(tǒng) → 詳解Linux下的postfix安裝

詳解Linux下的postfix安裝

更多

   郵件系統(tǒng)簡介

   郵件系統(tǒng)組成部分: MTA MSA ,MUA,MDA,MAA

   1 MUA :是Mial User Agent 的簡稱 ,是郵件系統(tǒng)的客戶端程序,它提供了閱讀,發(fā)送和接受電子郵件的用戶接口,如:linux中的Mail ,Windowns中的Foxmail,Outlook 等

   2 MSA :是Mail Submmission Agent的簡稱。是郵件提交代理,負責消息有MTA發(fā)送之前必須完成所有準備工作和錯誤檢測,MSA是在MUA和MTA之間插入了一個頭腦清醒的檢測員,對所有的主機名,從MUA 得到的頭信息等信息進行檢測

   3 MTA:是Mail Transfer Agent 的簡稱,郵件轉發(fā)代理,負責郵件的存儲和轉發(fā);監(jiān)視用戶的代理請求,根據(jù)電子郵件的目標地址找出對應的電子郵件服務器,并將信件在服務器之間傳輸并且將接受到的郵件進行緩沖。Linux 下有sendmail .Postfix,qmail 等

   4 MDA :是Mail Ddlivery Agent 的簡稱。郵件投遞代理,從MTA接受郵件并進行適當?shù)谋镜赝哆f,可以投遞一個本地用戶,一個郵件列表,一個文件或者是一個程序

   5 MAA :是Mail access Agent。郵件訪問代理,用于將用戶連接到系統(tǒng)郵件庫,使用POP或者Imap協(xié)議收取郵件。Linux 下常用的MAA有,Cyrus-IMAP,COURIER-IMAP等郵件中繼,當郵件的目的傳輸是一旦源地址和目的地址都不是本地系統(tǒng),那么本地系統(tǒng)就是郵件中繼站(即是中轉站)

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

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

  記錄了一部分

  或許記錄的不完全,再遇到error時,可以多查找一些資料文件

  第一:安裝cmake工具

  安裝步驟一點點的來,先從LAMP平臺來安裝,先安裝mysql,我這是一臺新安裝的linux系統(tǒng),所以遇到的問題可能會比較多一點

  因為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

  這個安裝好后,要關掉系統(tǒng)自帶的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

  重新創(chuàng)建新編譯的sasl庫文件

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

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.la”的符號鏈接“/usr/lib/libsasl2.la”

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so”的符號鏈接“/usr/lib/libsasl2.so”

  ln: 正在創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so”的符號鏈接“/usr/lib/libsasl2.so”: 文件已存在

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符號鏈接“/usr/lib/libsasl2.so.2”

  ln: 正在創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符號鏈接“/usr/lib/libsasl2.so.2”: 文件已存在

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so.2.0.22”的符號鏈接“/usr/lib/libsasl2.so.2.0.22”

  創(chuàng)建指向“/usr/local/sasl2/lib/sasl2”的符號鏈接“/usr/lib/sasl2”

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

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.la”的符號鏈接“/usr/local/lib/libsasl2.la”

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so”的符號鏈接“/usr/local/lib/libsasl2.so”

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so.2”的符號鏈接“/usr/local/lib/libsasl2.so.2”

  創(chuàng)建指向“/usr/local/sasl2/lib/libsasl2.so.2.0.22”的符號鏈接“/usr/local/lib/libsasl2.so.2.0.22”

  創(chuàng)建指向“/usr/local/sasl2/lib/sasl2”的符號鏈接“/usr/local/lib/sasl2”

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

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/hmac-md5.h”的符號鏈接“/usr/local/include/hmac-md5.h”

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/md5global.h”的符號鏈接“/usr/local/include/md5global.h”

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/md5.h”的符號鏈接“/usr/local/include/md5.h”

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/prop.h”的符號鏈接“/usr/local/include/prop.h”

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/sasl.h”的符號鏈接“/usr/local/include/sasl.h”

  創(chuàng)建指向“/usr/local/sasl2/include/sasl/saslplug.h”的符號鏈接“/usr/local/include/saslplug.h”

  創(chuàng)建指向“/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,之上都已經(jīng)完全安裝了,下面就開始安裝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,發(fā)現(xiàn)是加載上了

  配置虛擬用戶和虛擬域

  編輯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 過后,執(zhí)行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 數(shù)據(jù)庫的監(jiān)聽文件

  MYSQL_PORT 3306 數(shù)據(jù)庫的端口

  MYSQL_DATABASE extmail 數(shù)據(jù)庫

  MYSQL_USER_TABLE mailbox 數(shù)據(jù)庫的表

  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

  為虛擬用戶創(chuàng)建郵箱所在目錄,并修改權限.把其所屬主改為postfix

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

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

  配置SMTP 認證,同樣需要修改在前面創(chuàng)建的/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

  清除防火墻規(guī)則:[確定]

  把 chains 設置為 ACCEPT 策略:filter [確定]

  正在卸載 Iiptables 模塊:[確定]

  應用 iptables 防火墻規(guī)則:[確定]

  載入額外 iptables 模塊:ip_conntrack_netbios_ns [確定]

  第十一安裝extmail

  Ok,安裝完imap后,開始安裝網(wǎng)頁上的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

  之后修改主配置文件(根據(jù)你的實際路徑進行更改)

  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數(shù)據(jù)庫使用的數(shù)據(jù)庫名

  SYS_MYSQL_PASS = extmail 數(shù)據(jù)庫密碼

  SYS_MYSQL_DB = extmail

  SYS_MYSQL_HOST = localhost

  SYS_MYSQL_SOCKET = /data/mysql/mysql.Sock 數(shù)據(jù)庫的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,才能生效

  創(chuàng)建數(shù)據(jù)庫,把docs 目錄下面的導入到數(shù)據(jù)庫中,但是在導入數(shù)據(jù)庫前需要把extmail.sql 文件中的TYPE=MyISAM 改成ENGINE=MyISA

   #mysql –uroot –p

   #mysql –uroot –p

  修改cgi 目錄的屬主

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

  為extman 授權數(shù)據(jù)庫訪問權限

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

熱門評論
最新評論
發(fā)表評論 查看所有評論(0)
昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)