linux下编译安装postfix+mysql+dovecot+postfixadmin
Postfix 是一种电子邮件服务器,它是由任职于IBM华生研究中心(T.J. Watson Research Center)的荷兰籍研究员Wietse Venema为了改良sendmail邮件服务器而产生的。最早在1990年代晚期出现,是一个开放源代码的软件。
我是安装在了ubuntu server 上安装的,因为需要web界面操作,所以需要安装 apache+php
我的环境是:
ubuntu + apache2 + php5 + dovecot + postfix + postfixadmin
安装步骤:
1.首先在域名服务商的 DNS解析上添加
MX 映射: IN MX 10 mail.ludy.com.
mail IN A “IP地址”
2.安装mysql 由于我比较懒,我就用了懒人模式,安装时候要记得root 密码
Shell $> apt-get install mysql-server
创建postfix数据库,以及操作数据库user
Shell $> mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 58 Server version: 5.0.67-0ubuntu6 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database postfix; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on postfix.* to 'postfix'@'localhost' identified by '123456' with grant option; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
3.编译安装 postfix 支持 mysql 和 dovecot
shell $>wget http://www.postfix.cn/source/official/postfix-2.6.5.tar.gz shell $> apt-get install libmysqlclient15-dev shell $> tar zxvf postfix-2.6.5.tar.gz shell $> cd postfix shell $> make tidy shell $>make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -BDEF_SERVER_SASL_TYPE=\"dovecot\"' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm' shell $> make shell $>make install
##默认main.cf 配制文件
shell $>postconf -n command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 html_directory = no mail_owner = postfix mailq_path = /usr/bin/mailq manpage_directory = /usr/local/man newaliases_path = /usr/bin/newaliases queue_directory = /var/spool/postfix readme_directory = no sample_directory = /etc/postfix sendmail_path = /usr/sbin/sendmail setgid_group = postdrop unknown_local_recipient_reject_code = 550
####配份main.cf 配置文件
Shell $> mv main.cf main.cf.bak
####创建新的 main.cfg
shell $> vim main.cf command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 html_directory = no mail_owner = postfix mailq_path = /usr/bin/mailq manpage_directory = /usr/local/man newaliases_path = /usr/bin/newaliases queue_directory = /var/spool/postfix readme_directory = no sample_directory = /etc/postfix sendmail_path = /usr/sbin/sendmail setgid_group = postdrop unknown_local_recipient_reject_code = 550 ############################################################################ myhostname = mail.ludy.com mydomain = ludy.com myorigin = $mydomain mydestination = mynetworks = 127.0.0.0/8 inet_interfaces = all home_mailbox = Maildir/ ############################################################################ virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf virtual_gid_maps = static:33 virtual_mailbox_base = /var/vmail ###虚拟用户目录 virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf virtual_minimum_uid = 33 ### 给 apache 权限。 virtual_transport = virtual virtual_uid_maps = static:33 ############################################################################ message_size_limit = 52428800 mailbox_size_limit = 209715200 virtual_mailbox_limit = 209715200 virtual_create_maildirsize = yes virtual_mailbox_extended = yes virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf virtual_mailbox_limit_override = yes virtual_overquota_bounce = yes ############################################################################ smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot ###定义安装方式 dovecot smtpd_sasl_path = private/auth-client ##### 路径要与 dovecot 一样,一会要讲到 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
###创建 mysql 通信文件
shell$> cd /etc/postfix shell $> mkdir mysql shell $> cd mysql shell $> vim mysql_virtual_alias_maps.cf user = portfix password = 123456 hosts = localhost dbname = postfix table = alias select_field = goto where_field = address shell $> vim mysql_virtual_domains_maps.cf user = portfix password = 123456 hosts = localhost dbname = postfix table = domain select_field = domain where_field = domain shell $> vim mysql_virtual_mailbox_maps.cf user = portfix password = 123456 hosts = localhost dbname = postfix table = mailbox select_field = maildir where_field = username shell $> vim mysql_virtual_mailbox_limit_maps.cf user = portfix password = 123456 hosts = localhost dbname = postfix table = mailbox select_field = quota where_field = username
4.安装配置 dovecot-pop3d
shell $> apt-get install dovecot-pop3d shell $> cd /etc/dovecot shell $> mv dovecot.conf dovecot.conf.bak ##备份原有dovecot配置文件 shell $> vim dovecot.conf ## 创建新的 dovecot 配置文件 base_dir = /var/run/dovecot/ protocols = pop3 pop3s listen = * disable_plaintext_auth = no log_path = /var/log/dovecot.log info_log_path = /var/log/dovecot.info log_timestamp = "%Y-%m-%d %H:%M:%S " ssl_disable = yes mail_location = maildir:/var/vmail/%u mail_privileged_group = mail first_valid_uid = 33 protocol imap { } protocol pop3 { pop3_uidl_format = %08Xu%08Xv } auth default { mechanisms = plain login passdb pam { } passdb sql { args = /etc/dovecot/dovecot-sql.conf } userdb passwd { } userdb sql { args = /etc/dovecot/dovecot-sql.conf } user = root socket listen { client { path = /var/spool/postfix/private/auth-client ###这里对应postfix smtpd_sasl_path mode = 0660 user = postfix group = postfix } } }
######备份 dovecot 连接数据库配置文件
shell $> mv dovecot-sql.conf dovecot-sql.conf.bak shell $> vim dovecot-sql.conf driver = mysql connect = host=localhost dbname=postfix user=postfix password=123456 default_pass_scheme = MD5-CRYPT ### 这里修改为 MD5-CRYPT 是为了与 postfixadmin 想符合,不然验证不过去总提示密码错误! password_query = SELECT password FROM mailbox WHERE username = '%u' user_query = SELECT maildir, 33 AS uid, 33 AS gid FROM mailbox WHERE username = '%u'
####重新启动 dovecot 服务`
shell $> /etc/init.d/dovecot restart
5. 建立 postfix 虚拟用户目录
shell $> mkdir -p /var/vmail
## 赋给 apache 权限~~~
shell $> chown www-data:www-data /var/vmail -R
6.安装配置 postfixadmin
shell $> wget 'http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin_2.3.tar.gz?use_mirror=cdnetworks-kr-2' shell $> tar zxvf postfixadmin_2.3.tar.gz shell $> mv postfixadmin-2.3 /var/www/postfixadmin shell $> cd /var/www/postfixadmin shell $> vim config.inc.php #### 查找 $CONF['configured'] = false; ### 改为 $CONF['configured'] = true; ###查找 $CONF['default_language'] = 'en'; ## 改为: $CONF['default_language'] = 'cn'; ####查找 $CONF['database_type'] = 'mysql'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'postfixadmin'; $CONF['database_name'] = 'postfix'; $CONF['database_prefix'] = ''; 改为: $CONF['database_type'] = 'mysql'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = '123456'; $CONF['database_name'] = 'postfix'; $CONF['database_prefix'] = '';
转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/69.html
近期评论