基于centos5.0的企业级完全邮件系统

系统CentOS5.0   linux text方式最小化安装

1.删除cyrus-sasl和sendmail以免出现冲突

yum remove sendmail cyrus-sasl-plain cyrus-sasl -y

yum update -y

yum install gcc gcc-c++ libtermcap-devel zlib-devel libxml2-devel libpng-devel db4-devel libXpm gd tcl-devel libart_lgpl libart_lgpl-devel pcre-devel gdbm-devel perl-libwww-perl perl-URI perl-Digest-HMAC -y

libtermcap-devel  MYSQL需要, zlib-devel OPENSSL需要,db4-devel POSTFIX需要,libxml2-devel libpng-devel PHP需要,libXpm gd PERL-GD需要,tcl-devel libart_lgpl libart_lgpl-devel MAILGRAPH和QMONITOR需要,pcre-devel gdbm-devel MAILDROP需要

2.数据库安装

groupadd mysql

useradd -g mysql -s /bin/false -M mysql

tar xzvf mysql-5.1.22-rc.tar.gz

cd mysql-5.1.22-rc

./configure --prefix=/usr/local/mysql --enable-thread-safe-client --enable-local-infile --with-charset=utf8 --enable-assembler --with-extra-charsets=gbk,gb2312 --with-low-memory --with-unix-socket-path=/tmp/mysql.sock --with-mysqld-ldflags=-all-static --localstatedir=/usr/local/mysql/var

make

make install

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

cd /usr/local/mysql

chown -R mysql .

chgrp -R mysql .

bin/mysql_install_db --user=mysql

chown -R root .

chown -R mysql var

bin/mysqld_safe --user=mysql &

cd /usr/local/src/mysql-5.1.22-rc/

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod 700 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --level 3 mysqld on

/usr/local/mysql/bin/mysqladmin  ping

/usr/local/mysql/bin/mysqladmin  version

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

ldconfig -v

ln -s /usr/local/mysql/bin/* /usr/bin/

3.数据库安装

tar xzvf openssl-0.9.8e.tar.gz

cd openssl-0.9.8e

./config shared zlib

make

make test

make install

mv /usr/bin/openssl /usr/bin/openssl.OFF

rm -rf /usr/lib/libssl3.so

ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/ssl/include/openssl /usr/include/openssl

ln -s /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so

echo "/usr/local/ssl/lib" >> /etc/ld.so.conf

ldconfig -v

openssl version

4. cyrus-sasl安装

tar xzvf cyrus-sasl-2.1.22.tar.gz

cd cyrus-sasl-2.1.22

./configure --prefix=/usr/local/sasl2 --disable-gssapi --disable-anon --disable-sample --disable-digest --enable-plain --enable-login --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket

cp mac/libdes/public/des.h .

make

make install

mv /usr/lib/libsasl2.so.2  /usr/lib/libsasl2.so.2.OFF

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

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

ln -s /usr/local/sasl2/lib/*  /usr/lib

ln -s /usr/local/sasl2/lib/*  /usr/local/lib

ln -s /usr/local/sasl2/include/sasl/*  /usr/local/include

mkdir -p /var/state/saslauthd

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

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

/usr/local/sasl2/sbin/testsaslauthd -u root -p root密码

echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf

echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf

ldconfig -v

echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local

5.apache安装

tar xzvf httpd-2.2.6.tar.gz

cd httpd-2.2.6

./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/var/www --with-mpm=worker

make

make install

ln -s /usr/local/apache/bin/* /usr/bin/

echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local

6.PHP安装(可选)

tar xzvf php-5.2.4.tar.gz

cd php-5.2.4

./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-xml --with-png --with-jpeg --with-zlib --with-freetype --with-gd --enable-track-vars --enable-mbstring=all

make

make test

make install

cp php.ini-dist /usr/local/php/lib/php.ini

7.postfix邮件mta安装

groupadd -g 2525 postfix

useradd -g postfix -u 2525 -s /sbin/nologin -M postfix

groupadd -g 2526 postdrop

useradd -g postdrop -u 2526 -s /bin/false -M postdrop

tar xzvf postfix-2.5-20071006.tar.gz

cd postfix-2.5-20071006

make -f Makefile.init 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/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/ssl/lib -lssl -lcrypto'

make

make install

(tempdir: [/usr/local/src/postfix-2.5-20071006] /tmp

html_directory: [no] /var/www/postfix_html其他默认)

mv /etc/aliases /etc/aliases.OFF

ln -s /etc/postfix/aliases /etc/aliases

newaliases

postconf -n > /etc/postfix/main.cf.tmp

mv /etc/postfix/main.cf /etc/postfix/main.cf.backup

mv /etc/postfix/main.cf.tmp /etc/postfix/main.cf

vi /etc/postfix/main.cf

添加以下

##########################User Specified############################

myhostname = mail.eyaotong.com

myorigin = eyaotong.com

mydomain = eyaotong.com

mydestination =

mynetworks = 127.0.0.0/8

inet_interfaces = all

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

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

virtual_mailbox_base = /mail/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:2525

virtual_gid_maps = static:2525

virtual_transport = maildrop

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

content_filter=amavisfeed:[127.0.0.1]:10024

vi /etc/postfix/master.cf

修改为以下

maildrop  unix  -       n       n       -       -       pipe

flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}

在最后添加

# ==========================================================================

# service type  private unpriv  chroot  wakeup  maxproc command + args

#               (yes)   (yes)   (yes)   (never) (100)

# ==========================================================================

#

amavisfeed unix    -       -       n       -       2     smtp

-o smtp_data_done_timeout=1200

-o smtp_send_xforward_command=yes

-o disable_dns_lookups=yes

-o max_use=20

#

127.0.0.1:10025 inet n    -       n       -       -     smtpd

-o content_filter=

-o smtpd_delay_reject=no

-o smtpd_client_restrictions=permit_mynetworks,reject

-o smtpd_helo_restrictions=

-o smtpd_sender_restrictions=

-o smtpd_recipient_restrictions=permit_mynetworks,reject

-o smtpd_data_restrictions=reject_unauth_pipelining

-o smtpd_end_of_data_restrictions=

-o smtpd_restriction_classes=

-o mynetworks=127.0.0.0/8

-o smtpd_error_sleep_time=0

-o smtpd_soft_error_limit=1001

-o smtpd_hard_error_limit=1000

-o smtpd_client_connection_count_limit=0

-o smtpd_client_connection_rate_limit=0

-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters

-o local_header_rewrite_clients=

echo "/usr/sbin/postfix start" >> /etc/rc.d/rc.local

postconf  -a

cyrus

dovecot

8. courier-authlib认证安装

tar xjvf courier-authlib-0.60.2.tar.bz2

cd courier-authlib-0.60.2

./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/include/mysql --with-RedHat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc CFLAGS="-march=i686 -O2 -fexpensive-optimizations" CXXFLAGS="-march=i686 -O2 -fexpensive-optimizations"

make

make install

chmod 755 /usr/local/courier-authlib/var/spool/authdaemon

cp /etc/authdaemonrc.dist  /etc/authdaemonrc

cp /etc/authmysqlrc.dist  /etc/authmysqlrc

vi /etc/authdaemonrc

编辑以下

authmodulelist="authmysql"

authmodulelistorig="authmysql"

daemons=10

vi /etc/authmysqlrc

编辑以下

MYSQL_SERVER localhost

MYSQL_PORT 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  '1001'

MYSQL_GID_FIELD  '1001'

MYSQL_LOGIN_FIELD  username

MYSQL_HOME_FIELD  concat('/mail/mailbox/',homedir)

MYSQL_NAME_FIELD  name

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

cp courier-authlib.sysvinit /etc/init.d/courier-authlib

chmod 755 /etc/init.d/courier-authlib

chkconfig --add courier-authlib

chkconfig --level 3 courier-authlib on

echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf

ldconfig -v

service courier-authlib start

9.imap接受邮件

tar xjvf courier-imap-4.2.1.tar.bz2

cd courier-imap-4.2.1

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

make

make install

cp /usr/local/courier-imap/etc/imapd.dist /usr/local/courier-imap/etc/imapd

cp /usr/local/courier-imap/etc/imapd-ssl.dist /usr/local/courier-imap/etc/imapd-ssl

cp /usr/local/courier-imap/etc/pop3d.dist /usr/local/courier-imap/etc/pop3d

cp /usr/local/courier-imap/etc/pop3d-ssl.dist /usr/local/courier-imap/etc/pop3d-ssl

vi /usr/local/courier-imap/etc/pop3d

编辑以下

POP3DSTART=YES

vi /usr/local/courier-imap/etc/imapd

编辑以下

IMAPDSTART=YES

cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imapd

chmod 755 /etc/rc.d/init.d/courier-imapd

chkconfig --add courier-imapd

chkconfig --level 3 courier-imapd on

service courier-imapd start

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

相关推荐