首页 > linux, mysql, postfix > linux下编译安装postfix+mysql+dovecot+postfixadmin

linux下编译安装postfix+mysql+dovecot+postfixadmin

2010年3月16日 eric 发表评论 阅读评论

         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

  1. 2018年8月13日03:58 | #1

    An intriguing discussion is definitely worth comment. There’s no doubt that that you ought to write more on this issue, it may not be a
    taboo subject but typically people don’t speak about such issues.
    To the next! Many thanks!!

  2. 2018年8月13日06:14 | #2

    Hi! Someone in my Myspace group shared this website with us so I came to give it a look.
    I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers!
    Superb blog and excellent style and design.

  3. 2018年8月13日17:32 | #3

    I don’t even know how I ended up here, but I thought this post was good.
    I do not know who you are but certainly
    you’re going to a famous blogger if you are not already ;) Cheers!

  4. 2018年8月13日18:45 | #4

    Look forward to checking out your web page
    again.

  5. 2018年8月13日23:11 | #5

    This text is worth everyone’s attention. When can I find out more?

  6. 2018年8月14日03:47 | #6

    Ссылка Гидра https://hydra.biz.ski/hydra-link.html – это идеальный супермаркет даркнета, где возможно безопасно и абсолютно конфиденциально приобрести все что душе угодно.

  7. 2018年8月14日07:21 | #7

    The problem however is the fact that sending paper birthday cards through send to friends and household that are
    far could possibly be very costly and usually delayed.
    You can always improve upon them with your own ideas and
    imagination which will make your birthday card very special indeed.
    Let’s take a review of just a couple approaches to give birthday
    well wishes without the need for balloons or cake.

  8. 2018年8月14日09:30 | #8

    Thank you for such a good blog. Where else could
    anybody get that kind of info written in such a perfect way?
    I have a presentation that I am presently writing on, and I have been on the look
    out for such great information. Pleased to discover your blog.

  9. 2018年8月14日12:34 | #9

    Yes! Finally someone writes about Pocono Mountain House Rentals.

  10. 2018年8月14日18:31 | #10

    wh0cd389921 [url=http://amoxilcheap.us.com/]amoxil[/url]

  11. 2018年8月14日21:50 | #11

    I visit day-to-day some sites and websites to read posts,
    but this website offers quality based content.

  12. Melvinpange
    2018年8月14日23:23 | #12

    Hi there! can you buy propecia in dubai excellent site.

  13. 2018年8月15日00:47 | #13

    Несколько дней назад разглядывал контент инет, и к своему восторгу увидел восхитительный ресурс. Вот он: молодые проститутки СПб . Для нас этот ресурс оказал незабываемое впечатление. Хорошего дня!

  14. 2018年8月15日02:47 | #14

    Adoring the information on this web site, you have done a fantastic job on the blog
    posts.

  15. 2018年8月15日04:19 | #15

    It is Frank Rudy who first put ahead the precept-to make use of inflatable
    air cushion to boost the shock of athletic footwear, and one yr later, Nike air came out
    and brought about a revolution in sports activities shoes.

  16. 2018年8月15日06:55 | #16

    Great information. Lucky me I came across your
    blog by accident (stumbleupon). I’ve bookmarked it for later!

  17. 2018年8月15日08:29 | #17

    Tremendous issues here. I am very satisfied to peer your article.

    Thank you a lot and I am having a look ahead to touch you.
    Will you kindly drop me a mail?

  18. 2018年8月15日09:50 | #18

    брокер
    Привет! Мы профессиональные трейдеры. На рынке более 10 лет. Работаем с надежным брокером Forex4you и Affiliate.olymptrade! Нашими прогнозами пользуются тысячи трейдеров! Рекомендуем и Вам присоединиться к нашей команде! Мы вместе будем хорошо зарабатывать на Форексе! Мы лучшие!

  19. Melvinpange
    2018年8月15日11:19 | #19

    Hello! how to buy propecia in india good website.

  20. 2018年8月15日12:08 | #20

    Утром просматривал содержание инета, и вдруг к своему удивлению увидел хороший вебсайт. Вот смотрите: бизнес-презентация . Для нас данный веб-сайт оказался довольно важным. Всего наилучшего!

  21. 2018年8月15日14:26 | #21

    What’s up colleagues, nice post and nice arguments commented
    at this place, I am really enjoying by these.

  22. 2018年8月15日18:49 | #22

    Hi there, You’ve done a fantastic job. I will definitely digg it and personally suggest to my friends.
    I’m confident they will be benefited from this site.

  23. 2018年8月15日22:44 | #23

    Fifa 13 gameplay ps3 move manual
    Hp laserjet 4025 manual
    Sports car manual transmission
    Manualul antrenorului de fotbalisti
    First alert carbon monoxide alarm instruction manual co614
    Duraflame electric logs manual muscle
    Empreendimento marinha guincho manual manivela

  24. 2018年8月16日05:05 | #24

    Undeniably imagine that which you stated. Your favourite reason seemed to be at the internet the simplest thing to be mindful of.
    I say to you, I certainly get annoyed at the same time as other people think
    about concerns that they just don’t realize about. You managed
    to hit the nail upon the top and also defined out the whole thing without having side-effects , people can take
    a signal. Will likely be back to get more. Thanks

  25. 2018年8月16日09:01 | #25

    Superb site you have here but I was curious about
    if you knew of any forums that cover the same topics discussed in this article?
    I’d really like to be a part of group where I can get feedback from other experienced people that share
    the same interest. If you have any suggestions,
    please let me know. Thank you!

  26. 2018年8月16日09:07 | #26

    Yoou are soo cool! I don’t think I’ve truly read through a single thing like
    this before. So great to discover another person with genuine thouyghts on this topic.
    Seriously.. many thanks for starting this up. This site is something
    that is required on the internet, someone with a bit of originality!

  27. 2018年8月16日14:02 | #27

    I enjoy reading a post that makes people think. In addition, thank you
    for enabling me to provide feedback!

  28. 2018年8月16日20:50 | #28

    wh0cd389921 WELLBUTRIN

  29. 2018年8月17日02:34 | #29

    I have to thank you for thhe effirts you have put in penning this blog.

    I am hoping to see the same high-grade blog posts
    by you in the future as well. In fact, your creative writing abilitijes has
    inspired me to get my own siye noow ;)

评论分页
1 ... 41 42 43 69
订阅评论
1+5= (必填)