📄 基于linux和postfix的邮件系统的web mail安装手册 linuxsir_org.htm
字号:
<DIV class=codeblock><CODE>[root@mail build]#yum install
mysql-server<BR>[root@mail build]#yum install
mysql-devel</CODE></DIV><BR><BR>
<P></P>
<P><FONT id=5 size=4><B><BR>5、安装apache<BR></B></FONT><BR><BR><BR>
<DIV class=codeblock><CODE>[root@mail build]#yum install
httpd</CODE></DIV><BR><BR><BR><FONT id=6
size=4><B><BR>6.安装php<BR></B></FONT>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build]#yum install php<BR>[root@mail
build]#yum install php-mysql<BR>[root@mail build]#yum install
php-gd<BR>[root@mail build]#yum install php-imap<BR>[root@mail build]#yum
install vsftpd<BR>[root@mail build]#yum install clamav<BR>[root@mail
build]#yum install spamassassin<BR>[root@mail
build]#/usr/bin/freshclam</CODE></DIV>
<P></P>
<P><B>设置apache</B></P>
<P>默认:<BR>User apache<BR>改为<BR>User postfix</P>
<P>默认<BR>Group apache<BR>改为<BR>Group postfix</P>
<P>默认<BR>AddDefaultCharset UTF-8<BR>改为<BR>AddDefaultCharset gb2312</P>
<P>新加入:<BR>
<DIV class=codeblock><CODE>AddType application/x-httpd-php .php<BR>AddType
application/x-httpd-php-source .phps</CODE></DIV>
<P></P>
<P><FONT id=7 size=4><B><BR>7、安装phpMyAdmin<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build]#tar –zxf
../src/phpMyAdmin-2.8.0.1.tar.gz<BR>[root@mail build]#mv
phpMyAdmin-2.8.0.1 /var/www/html/dbadmin/<BR>[root@mail build]#cp
/var/www/html/dbadmin/libraries/config.default.php
/var/www/html/dbadmin/dbadmin/libraries/config.inc.php (line
1.)</CODE></DIV>
<P></P>
<P><FONT id=8 size=4><B><BR>8、设置数据库<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build]#mysql<BR>Mysql> create
datases postfix;<BR>Mysql> use mysql;<BR>Mysql> INSERT INTO user
(host,user,password) VALUES('localhost','postfix','');<BR>Mysql> update
user set password=password('postfix') where User='postfix';<BR>Mysql>
GRANT ALL ON postfix.* TO postfix@localhost IDENTIFIED BY
"postfix";<BR>Mysql> exit<BR>[root@mail build] tar –zxf
../src/webmail.tar.gz<BR>[root@mail build] mysql –u root –p postfix <
Tmail.sql</CODE></DIV>
<P></P>
<P><FONT id=9 size=4><B><BR>9、增加postfix的用户和组<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] groupadd -g 12345
postfix<BR>[root@mail build] useradd -u 12345 -g 12345 -c postfix
-d/dev/null -s/sbin/nologin postfix<BR>[root@mail build] groupadd -g 54321
postdrop</CODE></DIV>
<P></P>
<P><FONT id=10 size=4><B><BR>10、安装postfix<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] tar –zxf
../src/postfix-2.2.8.tar.gz<BR>[root@mail build] cd
postfix-2.2.8<BR>[root@mail build] patch -p1 <
../../src/postfix-2.2.8-vda.patch<BR>[root@mail build] make -f
Makefile.init makefiles \<BR>'CCARGS=-DUSE_SASL_AUTH -DHAS_MYSQL
-I/usr/include/mysql -I/usr/include/sasl' \<BR>'AUXLIBS=-L/usr/lib/mysql
-L/usr/lib/sasl2 -lmysqlclient -lsasl2 -lz -lm'<BR>[root@mail build]
make<BR>[root@mail build] make install</CODE></DIV>
<P></P>
<P>执行make
install这里会出现很多问题,但postfix已经为我们设置好了默认的答案,直接使用这些答案就可以使postfix正常工作了,所以我们只要直接按回车就可以了</P>
<P><FONT id=11 size=4><B><BR>11、安装Courier-authlib<BR></B></FONT><BR>
<DIV class=codeblock><CODE>[root@mail build] tar –jxf
../src/courier-authlib-0.58.tar.gz<BR>[root@mail build] cd
courier-authlib-0.58<BR>[root@mail build] ./configure
--prefix=/usr/lib/authlib --without-authpam \<BR>--without-authcustom
--without-authpgsql --without-authldap \<BR>--without-authuserdb
--without-authpwd --without-authshadow \<BR>--without-authvchkpw
--with-authmysql \<BR>--with-authdaemonvar=/usr/lib/authlib/var
\<BR>--mandir=/usr/lib/man --without-stdheaderdir
\<BR>--sysconfdir=/usr/lib/authlib/etc \<BR>--with-redhat<BR>[root@mail
build] make<BR>[root@mail build] make install<BR>[root@mail build] make
install-migrate<BR>[root@mail build] make install-configure</CODE></DIV>
<P></P>
<P><FONT id=12 size=4><B><BR>12、设置authlib的环境变量<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build]
COURIERAUTHCONFIG=/usr/lib/authlib/bin/courierauthconfig<BR>[root@mail
build] export COURIERAUTHCONFIG</CODE></DIV>
<P></P>
<P><FONT id=13 size=4><B><BR>13、安装Courier-imap<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] tar –jxf
../src/courier-imap-4.0.6.tar.gz<BR>[root@mail build] cd
courier-imap-4.0.6<BR>[root@mail build] ./configure –prefix=/usr/lib/imapd
\<BR>--silent --without-authpgsql --without-ipv6 \<BR>--with-redhat
--with-authmysql \<BR>--mandir=/usr/lib/man
--disable-root-check<BR>[root@mail build] make<BR>[root@mail build] make
install<BR>[root@mail build] make install-configure</CODE></DIV>
<P></P>
<P><FONT id=14 size=4><B><BR>14、配置系统<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] mv /etc/aliases
/etc/aliases.bak<BR>[root@mail build] ln -s /etc/postfix/aliases
/etc/aliases<BR>[root@mail build] echo 'root:
postfix'>>/etc/postfix/aliases<BR>[root@mail build]
/usr/bin/newaliases<BR>[root@mail build] mv /var/mail
/var/mail.bak<BR>[root@mail build] mkdir /var/mail<BR>[root@mail build]
chown -R postfix:postfix /var/mail<BR>[root@mail build] mv
/etc/postfix/main.cf /etc/postfix/main.cf.bak<BR>[root@mail build] vi
/etc/postfix/main.cf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>command_directory =
/usr/sbin<BR>config_directory = /etc/postfix<BR>daemon_directory =
/usr/libexec/postfix<BR>debug_peer_level = 2<BR>html_directory =
no<BR>mail_owner = postfix<BR>mailq_path =
/usr/bin/mailq<BR>manpage_directory = /usr/local/man<BR>newaliases_path =
/usr/bin/newaliases<BR>queue_directory =
/var/spool/postfix<BR>readme_directory = no<BR>sample_directory =
/etc/postfix<BR>sendmail_path = /usr/sbin/sendmail<BR>setgid_group =
postdrop<BR>unknown_local_recipient_reject_code = 550<BR>header_checks =
regexp:/etc/postfix/header_checks<BR>#############NEW
ADD#####################<BR>#=====================BASE=====================<BR>myhostname
= mail.test.com<BR>mydomain = test.com<BR>mydestination =
$myhostname<BR>local_recipient_maps =<BR>local_transport =
virtual<BR>#=====================MySQL=====================<BR>virtual_alias_maps
= mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf<BR>virtual_gid_maps
= static:54321<BR>virtual_mailbox_base = /<BR>virtual_mailbox_domains =
mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf<BR>virtual_mailbox_limit
= 51200000<BR>virtual_mailbox_maps =
mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf<BR>virtual_minimum_uid
= 125<BR>virtual_transport = virtual<BR>virtual_uid_maps =
static:12345<BR>#=====================Quota=====================<BR>virtual_create_maildirsize
= yes<BR>virtual_mailbox_extended = yes<BR>virtual_mailbox_limit_maps =
mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf<BR>virtual_mailbox_limit_override
= yes<BR>virtual_maildir_limit_message = Sorry, the user's maildir has
overdrawn his diskspace quota, please try again
later.<BR>virtual_overquota_bounce =
yes<BR>#====================SASL=====================<BR>smtpd_sasl_auth_enable
= yes<BR>smtpd_sasl_security_options =
noanonymous<BR>broken_sasl_auth_clients =
yes<BR>smtpd_delay_reject=yes<BR>smtpd_recipient_restrictions =
permit_mynetworks,permit_sasl_authenticated,permit_auth_destination,reject<BR>smtpd_client_restrictions
= permit_sasl_authenticated</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
mysql_virtual_alias_maps.cf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>user = postfix<BR>password = postfix<BR>hosts =
localhost<BR>dbname = postfix<BR>query = SELECT alias FROM userinfo WHERE
address='%s' AND active = 1</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
mysql_virtual_domains_maps.cf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>user = postfix<BR>password = postfix<BR>hosts =
localhost<BR>dbname = postfix<BR>query = SELECT domain FROM domaininfo
WHERE domain='%s'</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
mysql_virtual_mailbox_limit_maps.cf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>user = postfix<BR>password = postfix<BR>hosts =
localhost<BR>dbname = postfix<BR>query = SELECT quota FROM userinfo WHERE
address='%s'</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
mysql_virtual_mailbox_maps.cf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>user = postfix<BR>password = postfix<BR>hosts =
localhost<BR>dbname = postfix<BR>query = SELECT maildir FROM userinfo
WHERE address='%s' AND active = 1</CODE></DIV>
<P></P>
<P><FONT id=15 size=4><B><BR>15、配置sasl认证<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
/usr/lib/sasl2/smtpd.conf</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>pwcheck_method: authdaemond<BR>log_level:
3<BR>mech_list: plain
login<BR>authdaemond_path:/usr/lib/authlib/var/socket</CODE></DIV>
<P></P>
<P><FONT id=16 size=4><B><BR>16、配置courier-imap<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] mv
/usr/lib/authlib/etc/authlib/authmysqlrc
/usr/lib/authlib/etc/authlib/authmysqlrc.bak<BR>[root@mail build] vi
/usr/lib/authlib/etc/authlib/authmysqlrc</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>MYSQL_SERVER localhost<BR>MYSQL_USERNAME
postfix<BR>MYSQL_PASSWORD postfix<BR>MYSQL_PORT 0<BR>MYSQL_OPT
0<BR>MYSQL_DATABASE postfix<BR>MYSQL_USER_TABLE
userinfo<BR>MYSQL_CRYPT_PWFIELD passwd<BR>MYSQL_UID_FIELD
'12345'<BR>MYSQL_GID_FIELD '54321'<BR>MYSQL_LOGIN_FIELD
address<BR>MYSQL_HOME_FIELD homedir<BR>MYSQL_NAME_FIELD
realname<BR>MYSQL_MAILDIR_FIELD maildir<BR>MYSQL_QUOTA_FIELD
quota</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] mv
/usr/lib/authlib/etc/authlib/authdaemonrc
/usr/lib/authlib/etc/authlib/authdaemonrc.bak<BR>[root@mail build] vi
/usr/lib/authlib/etc/authlib/authdaemonrc</CODE></DIV>
<P></P>
<P>
<DIV
class=codeblock><CODE>authmodulelist="authmysql"<BR>authmodulelistorig="authmysql"<BR>version="authdaemond.mysql"<BR>daemons=5<BR>subsystem=mail<BR>DEBUG_LOGIN=0<BR>DEFAULTOPTIONS="wbnodsn=1"</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
/usr/lib/imapd/etc/pop3d</CODE></DIV>
<P></P>
<P>默认<BR>POP3DSTART=NO<BR>改为<BR>POP3DSTART=YES<BR>[root@mail build] vi
/usr/lib/imapd/etc/imapd<BR>默认<BR>IMAPDSTART=NO<BR>改为<BR>IMAPDSTART=YES<BR>[root@mail
build] chmod +x /usr/lib/authlib/var/</P>
<P><FONT id=17 size=4><B><BR>17、安装WebMail<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] mv Tmail
/var/www/html/webmail<BR>[root@mail build] vi
/var/www/html/webmail/config/config_inc.php</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>$CFG_BASEPATH = "/var/www/html/webmail/temp";
//临时目录<BR>// Mysql<BR>define(MYSQL_HOST, 'localhost');
//数据库主机名<BR>define(MYSQL_USER, 'postfix'); //数据库用户名<BR>define(MYSQL_PASS,
'postfix'); //数据库密码<BR>define(MYSQL_DATA, 'postfix');
//数据库名称<BR>$CFG_NETDISK_PATH = "/var/mail/netdisk";
//文件管理存储目录</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] vi
/var/www/html/webmail/webadmin/include/config.inc.php</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>// Mysql<BR>define(MYSQL_HOST, 'localhost');
//数据库主机名<BR>define(MYSQL_USER, 'postfix'); //数据库用户名<BR>define(MYSQL_PASS,
'postfix'); //数据库密码<BR>define(MYSQL_DATA, 'postfix'); //数据库名称</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] mkdir
/var/mail/netdisk<BR>[root@mail build] chown –R postfix:postfix
/var/mail/netdisk<BR>[root@mail build] mkdir
/var/www/html/webmail/temp<BR>[root@mail build] chown –R postfix:postfix
/var/www/html/webmail/temp</CODE></DIV>
<P></P>
<P>
<DIV class=codeblock><CODE>[root@mail build] cp
courier-authlib-0.58/courier-authlib.sysvinit
/etc/rc.d/init.d/courier-authlib<BR>[root@mail build] chmod 755
/etc/rc.d/init.d/courier-authlib<BR>[root@mail build] chkconfig –-add
courier-authlib<BR>[root@mail build] cp
courier-imap-4.0.6/courier-imap.sysvinit
/etc/rc.d/init.d/courier-imap<BR>[root@mail build] chmod 755
/etc/rc.d/init.d/courier-imap<BR>[root@mail build] chkconfig –-add
courier-imap</CODE></DIV>
<P></P>
<P><FONT id=18 size=4><B><BR>18、启动服务测试<BR></B></FONT></P>
<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -