Postfix免費郵件系統(tǒng)方案
1、系統(tǒng)目標
Maildir郵件存儲格式
smtp認證
郵件地址和系統(tǒng)帳號分開
多域支持
web管理帳號、別名、域等資料
pop3/imap支持
webmail支持
集成mysql數據庫
2、TODO
集成垃圾郵件過濾
集成防病毒
Project:xx公司郵件系統(tǒng)解決方案
Date:
Author:
1、系統(tǒng)目標
Maildir郵件存儲格式
smtp認證
郵件地址和系統(tǒng)帳號分開
多域支持
web管理帳號、別名、域等資料
pop3/imap支持
webmail支持
集成mysql數據庫
2、TODO
集成垃圾郵件過濾
集成防病毒
3、系統(tǒng)架構
+---------------------------------------------------+
| |
| 25/25 25/25 110/993 143/995 80/443 |
| Incoming Outgoing POP3 IMAP WEB-MAIL |
| / / / / / |
| || || || || || |
| / / / / / |
+-------------------+---------------+---------------+
| Postfix | | Squirrelmail |
| | +---------------+
| | Courier-imap |
| +-----------+-------------------------------+
| + Courier-authlib +
| |-------------------------------------------|
| | Cyrus-SASL |
|-------+-------------------------------------------+
| MySQL |
+---------------------------------------------------+
4、系統(tǒng)安裝
操作系統(tǒng)采用debian 3.1(sarge),下面沒有獨立安裝的gcc,make,db,glibc等基本庫和軟件,郵件系統(tǒng)需要的全部用 apt-get install 包名稱 來安裝
mail~#apt-get install gcc make
mail~#apt-get install libdb4-*
mail~#apt-get install curses*
mail~#apt-get install termcap*
..............
4.1、mysql
mail~#wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.12.tar.gz/from/http://mysql.cbn.net.id/
mail~#groupadd mysql
mail~#useradd -g mysql mysql
mail~#tar zxvf /usr/src/mail/mysql-4.1.12.tar.gz -C /tmp
mail~#cd /tmp/mysql-4.1.12
mail~#./configure --prefix=/opt/mysql --localstatedir=/opt/mysql/data --with-unix-socket-path=/tmp/mysql.sock --with-mysql-user=mysql --with-charset=gb2312 --with-extra-charsets=all
mail~#make
mail~#make install
mail~#chown -R mysql:mysql /opt/mysql/data/
如果沒有/opt/mysql/var/mail.err,就手動創(chuàng)建一個
mail~#mkdir /opt/mysql/var
mail~#touch /opt/mysql/var/mail.err
mail~#/opt/mysql/bin/mysqld_safe --user=mysql & #起動mysql服務
mail~#/opt/mysql/bin/mysql #起動mysql客戶端
mail~#vi /etc/ld.so.conf,添加
/opt/mysql/lib/mysql
mail~#ldconfig
mail~#cp /opt/mysql/share/mysql/mysql.server /etc/init.d/mysqld
mail~#chmod 755 /etc/init.d/mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc3.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc5.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc0.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc1.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc2.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc4.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc6.d/K25mysqld
4.2、apahce
mail~#wget http://apache.justdn.org/httpd/apache_1.3.33.tar.gz
mail~#goupadd www
mail~#useradd -g www -d /dev/null -s /bin/false www
mail~#tar zxvf /usr/src/mail/apache_1.3.33.tar.gz -C /tmp
mail~#cd /tmp/apache_1.3.33
mail~#./configure --prefix=/opt/apache --enable-module=rewrite --enable-shared=rewrite --enable-module=proxy --enable-shared=proxy --enable-module=so --server-uid=www --server-gid=www
mail~#make
mail~#make install
mail~#/opt/mysql/var# /opt/apache/bin/apachectl start #起動apache服務器
mail~#cd /opt/apache/bin/
mail~#cp apachectl /etc/init.d/httpd
mail~#cd /etc/init.d/
mail~#chmod 755 httpd
mail~#ln -s /etc/init.d/httpd /etc/rc3.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc5.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc0.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc1.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc2.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc4.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc6.d/K15httpd
4.3、php4
mail~#wget http://cn2.php.net/get/php-4.3.11.tar.gz/from/cn.php.net/mirror
mail~#tar zxvf /usr/src/mail/php-4.3.11.tar.gz -C /tmp
mail~#cd /tmp/php-4.3.11
mail~#./configure --prefix=/opt/php4 --with-xml --with-mysql=/opt/mysql --with-mysql-sock=/tmp/mysqld.php4.sock --with-apxs=/opt/apache/bin/apxs
mail~#make
mail~#make install
mail~#cp php.ini-dist /opt/php4/lib/php.ini
修改/opt/apache/conf/httpd.conf,添加php4支持,添加內容如下:
#php 4
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
另更改
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
為
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
mail~#vi /opt/apache/htdocs/test.php,內容如下
<?php
phpinfo();
?>
mail~#/opt/mysql/var# /opt/apache/bin/apachectl restart #重啟apache服務器
使用lynx或常用的瀏覽器如IE、firefox,瀏覽http://ip/test.php,看到了PHP的信息頁面,OK
4.4、openssl
mail~#wget http://www.openssl.org/source/openssl-0.9.8.tar.gz
mail~#tar zxvf /usr/src/mail/openssl-0.9.8.tar.gz -C /tmp
mail~#cd /tmp/openssl-0.9.8
mail~#./configure --prefix=/opt/openssl
mail~#make
mail~#make install
mail~#ln -s /opt/openssl/include/openssl /usr/include/openssl
4.5、cyrus-sasl2
mail~#wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
mail~#tar zxvf /usr/src/mail/cyrus-sasl-2.1.21.tar.gz -C /tmp
mail~#cd /tmp/cyrus-sasl-2.1.21
mail~#./configure --prefix=/opt/sasl2 --enable-login --enable-plain --enable-sql --enable-pwcheck --disable-anon --disable-digest --with-mysql=/opt/mysql --with-mysql-includes=/opt/mysql/include/mysql --with-mysql-libs=/opt/mysql/lib/mysql --with-saslauthd=/var/run
mail~#make
如果出現(xiàn)下面的錯誤:
auth_getpwent.c:48:20: des.h: No such file or directory
make[3]: *** [auth_getpwent.o] Error 1
make[3]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/cyrus-sasl-2.1.21'
make: *** [all] Error 2
修改/tmp/cyrus-sasl-2.1.21/saslauthd/Makefiles內的變量CFLAGS添加-I/opt/openssl/include/openssl
或者直接
mail~#cp /tmp/cyrus-sasl-2.1.21/mac/libdes/public/des.h /tmp/cyrus-sasl-2.1.21/
mail~#make
mail~#make install
mail~#vi /etc/ld.so.conf #添加以下內容
/usr/lib/sals2
/opt/sasl2/lib/sasl2
mail~#ldconfig
4.6、postfix
mail~#wget http://postfix.it-austria.net/releases/official/postfix-2.2.4.tar.gz
mail~#groupadd postfix
mail~#ueradd -g postfix -d /dev/null -s /bin/false postfix
mail~#make makefiles 'CCARGS=-DHAS_MYSQL -I/opt/mysql/include/mysql -DUSE_SASL_AUTH -I/opt/sasl2/include/sasl' 'AUXLIBS=-L/opt/mysql/lib/mysql -lmysqlclient -lm -lz -L/opt/sasl2/lib/sasl2 -lsasl2'
mail~#make install #一路回車默認就可以了
mail~#vi /etc/init.d/postfix
#!/bin/sh
start() {
#Start daemons.
echo -n "Starting postfix: "
/usr/sbin/postfix start
}
stop() {
#Stop daemons.
echo -n "Shutting down postfix: "
/usr/sbin/postfix stop
}
reload(){
echo -n "Reloading postfix: "
/usr/sbin/postfix reload
}
restart(){
stop
start
}
abort(){
/usr/sbin/postfix abort
}
flush(){
/usr/sbin/postfix flush
}
check(){
/usr/sbin/postfix check
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
*)
echo "Usage: postfix {start|stop|restart|reload|abort|flush|check}"
esac
mail~#chmod 755 /etc/init.d/postfix
mail~#ln -s /etc/init.d/postfix /etc/rc3.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc5.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc0.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc1.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc2.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc4.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc6.d/K35postfix
4.7、courier-authlib
mail~#wget http://www.courier-mta.org/beta/courier-authlib/courier-authlib-0.56.20050709.tar.bz2
mail~#su - wxt
wxt@mail:~$ tar xjvf /usr/src/mail/courier-authlib-0.56.20050709.tar.bz2 -C /tmp
wxt@mail:~$cd /tmp/courier-authlib-0.56.20050709/
wxt@mail:~$./configure --with-authmysql=yes --with-mailuser=www --with-mailgroup=www
--with-mysql-libs=/opt/mysql/lib/mysql --with-mysql-includes=/opt/mysql/include
/mysql --prefix=/opt/courier-authlib
wxt@mail:~$make
wxt@mail:~$exit
mail~#make install
4.8、courier-imap
mail~#wget http://www.courier-mta.org/beta/imap/courier-imap-4.0.3.20050702.tar.bz2
mail~#tar zxvf courier-imap-4.0.3.20050702.tar.bz2
mail~#su - wxt
wxt@mail:~$./configure --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030,big5 --prefix=/opt/courier-imap --disable-root-check --with-trashquota --with-dirsync
哪果沒能完成,出錯提示如下
configure: WARNING: === Courier authentication library not found.
configure: WARNING: === You need to download and install
configure: WARNING: === http://www.courier-mta.org/download.php#authlib first.
configure: WARNING: === If courier-authlib is installed in a non-default
configure: WARNING: === directory, set the COURIERAUTHCONFIG environment
configure: WARNING: === variable to the full path to the courierauthconfig
configure: WARNING: === binary and rerun this configure script.
configure: WARNING:
configure: error: courierauthconfig not found
設置變量COURIERAUTHCONFIG
【返回】