首页 > 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年6月12日13:59 | #1

    cialis 36 hours of freedom
    [url=http://cialisle.com]generic cialis[/url]
    does viagra or cialis make you harder
    buy cialis
    cialis headache treatment

  2. 2018年6月12日16:30 | #2

    Thanks for every other wonderful article. The place else may anybody get that kind of info in such a
    perfect approach of writing? I’ve a presentation subsequent week, and I’m at the search for such
    info.

  3. 2018年6月12日17:39 | #3

    Thank you for this; I’m formally a big fan of your weblog.

  4. 2018年6月12日18:02 | #4

    For the reason that the YouTube videos are posted here same like I also embed YouTube video code at my own web site, since it is easy to obtain embedded code.

  5. 2018年6月12日18:30 | #5

    I like to work on Personal home pages rather than .NET, although .NET presents the ability of drag and drop elements, however I love PHP much.

  6. 2018年6月12日19:30 | #6

    Wow! After all I got a weblog from where I can genuinely obtain valuable facts concerning my study and knowledge.

  7. 2018年6月12日21:16 | #7

    I am еxtremely inspired togeher with your writing skills and alsⲟ
    wіth the format to your weblog. Is this ɑ paіɗ
    theme or did yoս customize it your self? Either way keep up the excellent quality writing, it
    is uncommon to look a greɑt blog lіike this
    one nowadays..

  8. 2018年6月13日00:51 | #8

    Hello! I must say, I’m amazed with your website.
    I had little difficulty navigating through all the information. I found what
    I wanted in no time at all. Pretty great. Would appreciate it in case
    you add forums or something like that, it would be a perfect means for your
    clients and other visitors to have interaction. Good job.

  9. 2018年6月13日01:34 | #9

    Keep up the wonderful piece of work, I read several posts on this site and I think that your web blog is really appealing as well as
    contains lots of outstanding information.

  10. 2018年6月13日03:00 | #10

    Hello mates, its impressive piece of writing about educationand
    fully defined, keep it up all the time.

  11. 2018年6月13日03:09 | #11

    красочные презентации
    Эффективная визуализация ваших идей в презентации. “Под ключ” за 48 часов. Ваш проект обязательно станет успешным.
    У вас впереди курсовая или диплом? У вас грядет сдача бизнес-плана, а презентация не готова? Вы на правильном сайте!
    Для того, чтобы подготовка презентации стала для вас таким же необременительным процессом как оплата товаров банковской картой в магазине и, самое главное, для экономии вашего драгоценного времени. Мы поможем Вам:
    Отразить и дополнить элементы доклада актуальными меди-элементами (диаграммы, инфографика, фото, графики и многое другое).
    Привлечь и удержать внимание слушателей при помощи визуальных деталей и нюансов, подчеркнув уникальность выступления и увеличив шанс на получение высокой оценки работы.
    Мы подготовим для вас интересную, качественную и финансово выгодную презентацию в среде PowerPoint на любую тематику.
    Мы не подведем и оправдаем все Ваши ожидания и надежды. Наши специалисты имеют большой опыт работы с заказчиками из СНГ, США и Европейских стран, что дает гарантию на добросовестность и качество выполняемых работ.
    Все необходимые доработки и исправления выполняются бесплатно и быстро.

  12. 2018年6月13日03:41 | #12

    описание экскурсии в паттайе нонг нуч
    подскажите цены на экскурсии в паттайе

  13. 2018年6月13日06:49 | #13

    Hello there, just became aware of your site via Google, and discovered that it’s truly useful.
    I’ll be grateful if you continue this in future.

  14. 2018年6月13日08:16 | #14
  15. 2018年6月13日09:15 | #15

    Loving the information on this web site, you have done great job on the posts.

  16. 2018年6月13日09:46 | #16

    экскурсии рыбалка в паттайе
    какие цены на экскурсии в паттайе с видео

  17. 2018年6月13日10:15 | #17

    дизайн для сайтов
    Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there.
    Creation of a site on a turn-key basis after discussion and reception of the information on necessary actions.
    While your competitors will only create landing pages or a separate site for the required search query, you will already have an indisputable advantage – an optimized site or internal page with age and external links.
    The design contains adaptive layout and an excellent level of preparation for any user. Interest is always understandable and logical.

  18. 2018年6月13日11:14 | #18

    курсы обменников на сегодня – обменник ru, биткоин рубль обмен

  19. 2018年6月13日11:57 | #19

    This article is very attractive to people like me.
    It’s not just thought-provoking, it draws you in right away.
    This is well-written content. The views here are also encouraging to me.
    Thanks.

  20. 2018年6月13日12:30 | #20

    Hey this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors
    or if you have to manually code with HTML. I’m starting a blog soon but
    have no coding knowledge so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

  21. 2018年6月13日13:07 | #21

    This article was very appealing, particularly since
    I was searching for applying for grants this subject last Thursday.
    Keep posting.

  22. 2018年6月13日14:13 | #22

    Your style is unique in comparison to other folks I’ve read
    stuff from. Thanks for posting when you have the opportunity,
    Guess I will just bookmark this web site.

  23. 2018年6月13日14:36 | #23

    Porn Vids Only 200 links
    Porn Vids Only 200 links
    Porn Tube 200 links
    Porn Vids Only 200 links
    pornvidsonly.com 600 links

  24. 2018年6月13日16:13 | #24
  25. 2018年6月13日16:23 | #25

    экскурсии в паттайе частный остров
    экскурсии в паттайе форум

  26. 2018年6月13日21:42 | #26

    This is really fascinating, You’re an excessively
    professional blogger. I’ve joined your feed and sit up
    for in quest of more of your fantastic post. Additionally, I’ve shared your website
    in my social networks

  27. 2018年6月13日21:50 | #27

    Some visitors are eager to watch comical movies, except I like to watch terrible videos on YouTube.

  28. 2018年6月13日23:27 | #28

    I wanna comment that you have a very nice website,
    I really like the style and design it certainly is different.

  29. 2018年6月14日00:32 | #29

    What’s up, I wish for to subscribe for this website to obtain newest updates, thus where can i do it please help out.

  30. 2018年6月14日00:36 | #30

    Thanks for writing this great excellent articles.
    The information in this material shows my standpoint and you really laid it
    out well. I could never have written a piece of writing this excellent.

  31. 2018年6月14日01:30 | #31

    Eventually, after spending much time on the internet at past We’ve
    uncovered anyone that certainly does know what they’re
    talking about thank you very much fantastic article.

  32. 2018年6月14日02:40 | #32

    Thank you, I’ve just been in search of information about this topic
    for some time and yours is the best I’ve found until
    now.

  33. 2018年6月14日03:55 | #33

    дома из сип панелей

    облицовачный кирпич самара

  34. 2018年6月14日03:57 | #34

    штукатурка короед купить

    http://fkt-samara.ru/katalog/germetiziruyushhie-materialyi-soudal/penyi/ – купить кирпич

  35. 2018年6月14日03:58 | #35

    xn—-8sbaavrnbhpg2bek.xn--p1ai

    http://troy63.ru/katalog/krovlya/prajs-list-na-krovelnye-raboty/ – стоимость кровельных работ

  36. 2018年6月14日04:24 | #36

    Thanks for taking the time to discuss this, It is extremely helpful for
    me.

  37. 2018年6月14日05:09 | #37

    This piece of writing is in fact a nice one it assists new the web viewers, who are wishing in favor of blogging.

  38. 2018年6月14日06:14 | #38

    General Low-down Far this outcome

  39. 2018年6月14日09:40 | #39

    Please let me know if you’re looking for a article
    writer for your weblog. You have some really great
    articles and I believe I would be a good asset. If you ever want to take
    some of the load off, I’d love to write some material for your blog in exchange for a link back to mine.
    Please blast me an e-mail if interested. Thanks!

  40. 2018年6月14日10:51 | #40

    (iii) You are accountable for the work, so maintain a professional attitude when confronted with your customers.
    The goal is usually to find a method to give a complete response,
    all while focusing on as small a region of investigation as possible.
    To ensure that they will will see the message that you are trying to get across, write using their language and write
    while considering their level of comprehension.

  41. 2018年6月14日14:32 | #41

    Say this blog loads a lot quicker then most. http://www.uk-on-line.de/cgi-std/gaestebuch.cgi

  42. 2018年6月14日15:46 | #42

    (iii) You provide for the work, so conserve a professional attitude when confronted with your customers.
    Understand this issue – While writing the essay, the first thing you have to
    do is to define the topic. Run-on sentences occur because of not enough punctuation and happen when you become lost in your essay.

  43. 2018年6月14日22:27 | #43

    Yoᥙ should take part in a contest for one off the highest quality blogs online.
    I will hіghly recommend this site!

  44. 2018年6月15日00:49 | #44

    утеплители для дома

    xps плита купить

  45. 2018年6月15日00:50 | #45

    vermeer d24x40

    http://gnbsklad.ru/ – горизонтальное бурение

  46. 2018年6月15日00:50 | #46

    купить шпунтованный влагостойкий дсп в самаре

    метод гнб

  47. 2018年6月15日09:45 | #47

    Hi, its good article regarding media print, we all know media is a enormous
    source of facts.

  48. 2018年6月15日10:56 | #48

    Excellent post. I was checking continuously this blog and I am
    impressed! Very helpful info specifically the closing part :) I handle
    such information a lot. I used to be looking for this particular info for a long time.

    Thanks and good luck.

  49. 2018年6月15日12:02 | #49

    Hi there! Someone in my Myspace group shared this website with us so I came to take a look.
    I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!

    Outstanding blog and superb design. http://test1.donntu.org/user/Sherman8711/

  50. 2018年6月15日12:39 | #50

    Hello! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing months of hard work due to no back
    up. Do you have any solutions to stop hackers? http://talkaboutendo.com/wp-content/plugins/zingiri-forum/mybb/member.php?action=profile&uid=6346

评论分页
订阅评论
4+9= (必填)