freebsd+postfix+mysql+authdaemon+sasl2+bind9

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:
   最小化安装freebsd选上ports
1.安装 apache2
 
shell $> cd /usr/ports/www/apache22
shell $> make install  clean
shell $> ee /etc/rc.conf
accf_data_load="YES"
accf_http_load="YES"
apache22_enable="YES"
apache22_http_accept_enable="YES"
 
2.安装 php5
 
shell $> cd /usr/ports/lang/php5
shell $> make install clean
出现配置选项 选上 MULTIBYTE 、OPENSSL 两项
然后修改 /usr/loca/etc/apache22/httpd.conf
shell $> ee /usr/local/etc/apache22/httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html  
</IfModule>
修改为
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
然后在
   AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
下添加
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
shell $> cd /usr/loca/etc
shell $> cp php.ini-dist php.ini
 
3.安装PHP扩展
shell $> /usr/ports/lang/php5-extensions
shell $> make install clean
出现配置选项,该选什么大家都应该知道。
我选了mysql  gettext.......就不一一列出。
 
4.安装 mysql -server
shell $> cd /usr/ports/databases/mysql50-server
shell $> make install clean
shell $> ee /etc/rc.conf
添加
mysql_enable="YES"
shell $> cp /usr/local/share/mysql/my-medium.cnf  /usr/local/etc/my.cnf
shell $> /usr/local/etc/rc.d/mysql-server start
shell $> mysql_install_db --user=mysql       ###初始化数据库
 
5. 安装phpmyadmin
shell $> cd /usr/ports/databases/phpmyadmin
shell $> make install clean
shell $> cp -R  /usr/local/www/phpMyAdmin  /usr/local/www/apache22/data/
shell $> cd /usr/local/www/apache22/data/phpMyAdmin
shell $> cp libraries/config.default.php ./config.inc.php
shell $> ee config.inc.php
查找 $cfg['Servers'][$i]['auth_type'] = 'config';
改为 $cfg['Servers'][$i]['auth_type'] = 'http';
shell $> chown -R www:www /usr/local/www/apache22/data/phpMyAdmin
 
6.安装 courier-imap
shell $> cd /usr/ports/mail/courier-imap
shell $> make install clean             ###配置单中选种 mysql  openssl
shell $> ee /etc/rc.conf
添加如下:
courier_authdaemond_enable="YES"
courier_imap_pop3d_enable="YES"
courier_imap_imapd_enable="YES"
shell $> chmod -R +x /var/run/authdaemond
shell $> /usr/local/etc/rc.d/courier-authdaemond start
shell $> ls /var/run/authdaemond
pid             pid.lock        socket
####看到有 socket 就是正常,认证时需要用到
shell $> ee /usr/local/etc/authlib/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
###修改认证方式为 mysql
shell $> ee /usr/local/etc/authlib/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          root
MYSQL_PASSWORD          123456
MYSQL_OPT               0
MYSQL_DATABASE          postfix
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD   password
MYSQL_UID_FIELD '80'
MYSQL_GID_FIELD         '80'                           ###给apache 操作权限
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        '/var/mailbox/'     ###mail 虚拟目录
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     maildir
shell $> ee /usr/local/etc/courier-imap/pop3d
查找  POP3DSTART=NO
改为 POP3DSTART=YES
 
7.安装 Cyrus-sasl2
shell $> cd /usr/ports/security/cyrus-sasl2
shell $> make install clean       #### 配置菜单要选 AUTHDAEMON
shell $> ee /usr/local/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
mech_list:PLAIN LOGIN
authdaemond_path:/var/run/authdaemond/socket

8. 安装 postfix
shell $> cd /usr/ports/mail/postfix
shell $> make install clean    ##配置选项,选择 SASL2 ,TLS,MYSQL,VDA
shell $>  echo postfix:  root  >> /etc/aliases
shell $> newaliases
shell $> chown postfix:postfix /etc/opiekeys
shell $> ee /etc/rc.conf
##添加如下:
postfix_enable="YES"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
shell $> cd /usr/local/etc/postfix
shell $> ee main.cf
###################  BASE  ##################`
command_directory = /usr/local/sbin
config_directory = /usr/local/etc/postfix
daemon_directory = /usr/local/libexec/postfix
debug_peer_level = 2
html_directory = no
mail_owner = postfix
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
mynetworks_style = host
newaliases_path = /usr/local/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
unknown_local_recipient_reject_code = 550
myhostname = mail.ludy.com
mydomain = ludy.com
home_mailbox = Maildir/
mydestination = $myhostname
local_recipient_maps =
message_size_limit = 14680064
#################MySQL################
virtual_alias_maps =mysql:/usr/local/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:80
virtual_gid_maps = static:80
virtual_mailbox_base = /var/mailbox/
virtual_mailbox_domains = mysql:/usr/local/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 80
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
################Quota################
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/usr/local/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry,the user's Maildir has overdrawn his diskspace quota ,please tray again later.
virtual_overquota_bounce = yes
##############SASL####################
smtpd_sasl_auth_enable = yes
smtpd_sasl2_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
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,
                                reject_rbl_client cblless.antispam.org.cn
smtpd_client_restrictions = permit_mynetworks,
                            permit_sasl_authenticated
 
shell $> mkdir /var/mailbox
shell $> chown -R www:www /var/mailbox
shell $> chmod -R 700 /var/mailbox
 
9.建立MYSQL 查询配置文件
shell $> cd /usr/local/etc/postfix
shell $> mkdir mysql
shell $>  cd mysql
shell $> ee mysql_virtual_alias_maps.cf
user = root
password = 123456
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address
shell $> ee  mysql_virtual_domains_maps.cf
user = root
password = 123456
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain
shell $> ee mysql_virtual_mailbox_limit_maps.cf
user = root
password = 123456
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
shell $> ee  mysql_virtual_mailbox_maps.cf
user = root
password = 123456
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username

10. 安装 POSTFIXADMIN
shell $> cd /usr/ports/mail/postfixadmin
shell $> make install clean
shell $> cp -R /usr/local/www/postfixadmin  /usr/local/www/apache22/data/
shell $> shown -R www:www /usr/local/www/apache22/data
shell $> cd /usr/local/www/postfixadmin
shell $> mysql -u root -p < DATABASE_MYSQL.TXT
shell $> ee config.inc.php
$CONF['default_language'] = 'cn';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'root';
$CONF['database_password'] = '123456';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['quota'] = 'YES';
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to Host';
$CONF['footer_link'] = 'http://192.168.6.44/postfixadmin';
 
11.安装 bind9
shell $>cd /usr/ports/dns/bind9
shell $> make install clean
shell $> cd /etc/namedb
shell $> rndc-confgen > rndc.conf    ##生成rndc.conf
复制rndc.conf
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
#       algorithm hmac-md5;
#       secret "dOESmFjoj6ptokHGi4aJAg==";
# };
#
# controls {
#       inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndc-key"; };
# };
去掉注释到 named.conf 文件
shell $> ee named.conf
options {
        // Relative to the chroot directory, if any
        directory       "/etc/namedb";
        pid-file        "/var/run/named/pid";
        dump-file       "/var/dump/named_dump.db";
        statistics-file "/var/stats/named.stats";
        listen-on       { 192.168.6.44; };
             forwarders {
                202.106.0.20;
        };
};
zone "ludy.com" {
        type master;
        file "dynamic/ludy.com";
};
key "rndc-key" {
      algorithm hmac-md5;
      secret "dOESmFjoj6ptokHGi4aJAg==";
};
controls {
      inet 127.0.0.1 port 953
              allow { 127.0.0.1; } keys { "rndc-key"; };
};
 
##添加 ludy.com 域名解析文件
shell $> cd /etc/namedb/dynamic/
shell $> ee ludy.com
$TTL    86400
$ORIGIN ludy.com.
@       IN      SOA     ludy.com. root.ludy.com. (
                        2009072901      ;
                        68400           ;
                        86400           ;
                        3600000;        ;
                        36000   )       ;
        IN      NS      ns.ludy.com.
        IN      MX      10 mail.ludy.com.
www     IN      A       192.168.6.44
mail    IN      A       192.168.6.44
ns      IN      A       192.168.6.44
shell $> ee /etc/rc.conf
添加如下:
named_enable="YES"
named_program="/usr/sbin/named"
named_flags="-c /etc/namedb/named.conf"
 
12.重新启动服务器,测试
 
a. 在你的XP 机器上把 DNS 地址 改为 postfix 地址
 
 
b.打开浏览器输入
 
c.点击 new domain 输入 你的域名  然后点 Add Domain.
d.点击 Add mailbox 添加帐户,添写完后点 Add mailbox 
 
e.在 以 d 的方式添加另一个帐号
 
f. 在 outlook 上添加两个帐号,发邮件测试
##关于 outlook  的使用方法详见   http://deidara.blog.51cto.com/400447/172849
 
g. 点击败接受与发送看邮件收到没。
 
成功了,有什么问题大家多多沟通~~~
 

本文转自Deidara 51CTO博客,原文链接:http://blog.51cto.com/deidara/185510,如需转载请自行联系原作者
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
关系型数据库 MySQL 应用服务中间件
|
监控 关系型数据库 MySQL
|
Unix 关系型数据库 MySQL
|
Web App开发 关系型数据库 应用服务中间件
FreeBSD 安装配置Nginx+PHP+APC+MySQL
在 FreeBSD 下安装软件的传统方法是用 ports 源码安装,不过使用 ports 源码编译安装太耗时(尤其是各种库依赖多、大的时候),个人还是喜欢 pkg 这种软件包管理工具直接安装编译好的二进制软件包,不用自己编译,省时省力。
1552 0
x3d
|
关系型数据库 Unix MySQL
Freebsd中mysql安装及使用笔记
1.安装 一开始连mysql的软件包在freebsd中叫什么都不知道; 依稀属于databases类,先到ports下看看叫什么名字,不看不知道,一看吓一跳,好多版本;4 5 6都有,选用得多的51,即mysql51-server,由于连了网,然后pkg_add -r mysql51-server...
x3d
966 0
|
7月前
|
Unix Linux
Linux/FreeBSD 安装
在Linux/FreeBSD上安装Julia 1.7.2的步骤:从[官方](https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.2-linux-x86_64.tar.gz)或[Tsinghua镜像](https://mirrors.tuna.tsinghua.edu.cn/julia-releases/bin/linux/x86/1.7/julia-1.7.2-linux-i686.tar.gz)下载二进制包,然后使用`tar`解压。

推荐镜像

更多
下一篇
DataWorks