打印

在FreeBSD 上组建ISP级的邮件系统 (转)

三、安装数据库 MySQL

MySQL 版本很多,大家可以据自己需要自行安装。

%cd /usr/ports/databases/mysql51-server/
%make install clean

在/etc/rc.conf 加入

mysql_enable="YES"

复制配置文件(非必需)

cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf
在此说明:

1、如果不在/etc/rc.conf 加入以上内容,手工是无法启动MySQL的。
2、如果你想知道这个软件应该在/etc/rc.conf加入什么内容,打开/usr/local/etc/rc.d 目录,找到此软件的启动脚本。然后打开文件,如果有详细的说明。


%/usr/local/etc/rc.d/mysql-server.sh start
Starting mysql.

如何去检查一个服务是否正常启动:1、通过ps查看进程,2、检查所打开的端口。

%ps aux|grep mysql
mysql 94899  0.2  0.5  1644  1240  p0  S     3:52PM   0:00.07 /bin/sh /usr/local/bin/mysqld_safe --
mysql 94919  0.0 10.8 55564 27428  p0  S     3:52PM   0:01.54 /usr/local/libexec/mysqld --defaults-
%

%netstat -an|grep 3306
tcp4       0      0  *.3306                 *.*                    LISTEN

TOP

MySQL安装时,服务器的密码为空,建议你装好系统后,第一时间去更改密码。

%/usr/local/bin/mysqladmin -u root -p password 你的新密码
Enter password:
如果你服务器只供本站内部使用建议在 my.cnf 里加入下面内容,以增加服务器的安全性。

[mysqld]
bind_address=127.0.0.1

TOP

四、安装Apache
1、安装apache server
作为网络的今天apache web服务器已经是街知港闻了。
%cd /usr/ports/www/apache22/
%make install clean
在/etc/rc.conf 中加入:

apache22_enable="YES"
如果启动时出现httpd: Could not reliably determine the server's fully qualified domain name, using mail.sharesky.cn for ServerName 的错误,在/usr/local/etc/apache22/httpd.conf 约第144行的位置加入下面的内容。

ServerName mail.extmail.org
启动apahce

%/usr/local/etc/rc.d/apache22.sh start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.

TOP

2、安装PHP
%cd /usr/ports/lang/php5/
%make install clean
                  Options for mod_php4 4.4.2_1,1                    x  
               x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x  
               x x         [ ] DEBUG      Enable debug                            x x  
               x x         [X] MULTIBYTE  Enable zend multibyte support           x x  
               x x         [ ] IPV6       Enable ipv6 support                     x x  
               x x         [X] OPENSSL    Build static OpenSSL extension      
在/usr/local/etc/apache22/httpd.conf 里加入

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
加入目录索引 index.php,约在httpd.conf 的212行

DirectoryIndex index.html index.php

restart或reload Apache 使之生效

%/usr/local/etc/rc.d/apache22.sh reload
Performing sanity check on apache22 configuration:
Syntax OK
Performing a graceful restart

TOP

3、安装PHP 扩展
%cd /usr/ports/lang/php5-extensions/
%make install clean
在这里建议大家,如果没有必要尽量不要安装GD库免得浪费时间,大家可据自己需要选择安装模块

               lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
               x                 Options for php4-extensions 1.0                    x  
               x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x  
               x x  [ ] BCMATH       bc style precision math functions            x x  
               x x  [X] BZ2          bzip2 library support                        x x  
               x x  [ ] CALENDAR     calendar conversion support                  x x  
               x x  [ ] CRACK        crack support                                x x  
               x x  [X] CTYPE        ctype functions                              x x  
               x x  [X] CURL         CURL support                                 x x  
               x x  [ ] DBA          dba support                                  x x  
               x x  [ ] DBASE        dBase library support                        x x  
               x x  [ ] DBX          dbx support                                  x x  
               x x  [ ] DIO          Direct I/O support                           x x  
               x x  [ ] DOMXML       DOM support                                  x x  
               x x  [ ] EXIF         EXIF support                                 x x  
               x x  [ ] FILEINFO     fileinfo support                             x x  
               x x  [ ] FILEPRO      filePro support                              x x  
               x x  [ ] FRIBIDI      FriBidi support     
                             x x  [X] FTP          FTP support                                  x x  
               x x  [ ] GD           GD library support                           x x  
               x x  [X] GETTEXT      gettext library support                      x x  
               x x  [ ] GMP          GNU MP support                               x x  
               x x  [X] ICONV        iconv support                                x x  
               x x  [ ] IMAGICK      ImageMagick support                          x x  
               x x  [X] IMAP         IMAP support                                 x x  
               x x  [ ] INTERBASE    Interbase 6 database support (Firebird)      x x  
               x x  [ ] LDAP         OpenLDAP support                             x x  
               x x  [X] MBSTRING     multibyte string support                     x x  
               x x  [ ] MCAL         Modular Calendar Access Library support      x x  
               x x  [X] MCRYPT       Encryption support                           x x  
               x x  [ ] MCVE         MCVE support                                 x x  
               x x  [ ] MHASH        Crypto-hashing support                       x x  
                             x x  [ ] MING         ming shockwave flash support                 x x

TOP

x x  [ ] MNOGOSEARCH  mnoGoSearch support                          x x  
               x x  [ ] MSSQL        MS-SQL database support                      x x  
               x x  [X] MYSQL        MySQL database support                       x x  
               x x  [ ] NCURSES      ncurses support (CLI only)                   x x  
               x x  [ ] ODBC         unixODBC support                             x x  
               x x  [X] OPENSSL      OpenSSL support                              x x  
               x x  [ ] ORACLE       Oracle support                               x x  
               x x  [X] OVERLOAD     user-space object overloading support        x x  
               x x  [ ] PANDA        panda support                                x x  
               x x  [ ] PCNTL        pcntl support (CLI only)                     x x  
               x x  [X] PCRE         Perl Compatible Regular Expression support   x x  
               x x  [ ] PDF          PDFlib support (implies GD)                  x x  
               x x  [ ] PFPRO        PayFlow Pro support                          x x  
                             x x  [ ] PGSQL        PostgreSQL database support                  x x  
               x x  [X] POSIX        POSIX-like functions                         x x  
               x x  [ ] PSPELL       pspell support                               x x  
               x x  [ ] READLINE     readline support (CLI only)                  x x  
               x x  [ ] RECODE       recode support                               x x  
               x x  [X] SESSION      session support                              x x  
               x x  [ ] SHMOP        shmop support                                x x  
               x x  [ ] SNMP         SNMP support                                 x x  
               x x  [ ] SOCKETS      sockets support                              x x  
               x x  [ ] SYBASE_CT    Sybase database support                      x x  
               x x  [ ] SYSVMSG      System V message support                     x x  
               x x  [ ] SYSVSEM      System V semaphore support                   x x  
               x x  [ ] SYSVSHM      System V shared memory support               x x  
               x x  [X] TOKENIZER    tokenizer support                            x x  
                             x x  [ ] WDDX         WDDX support (implies XML)                   x x  
               x x  [X] XML          XML support                                  x x  
               x x  [ ] XMLRPC       XMLRPC-EPI support                           x x  
               x x  [ ] XSLT         XSLT Sablotron support                       x x  
               x x  [ ] YAZ          YAZ support (ANSI/NISO Z39.50)               x x  
               x x  [ ] YP           YP/NIS support                               x x  
               x x  [ ] ZIP          ZIP support                                  x x  
               x x  [X] ZLIB         ZLIB support                                 x x

TOP

4、安装phpmyadmin 管理数据库
phpMyAdmin-2.8.1 版的Port 安装方法.
# whereis phpmyadmin
phpmyadmin: /usr/ports/databases/phpmyadmin
cd /usr/ports/databases/phpmyadmin
make install clean
设置phpmyadmin
%cd /usr/local/www/apache22/data/phpmyadmin/
%ee config.default.php
将$cfg['Servers'][$i]['auth_type'] = 'config'; 改为

$cfg['Servers'][$i]['auth_type']     = 'http';

保存,退出!

我们需要在APACHE里面建立一个Alias:

#vi /usr/local/etc/apache22/httpd.conf
在Alias 组加入下列内容:
***************************************************   
    Alias /phpmyadmin "/usr/local/www/phpMyAdmin/"
    <Directory /usr/local/www/phpMyAdmin/>
    Order allow,deny
    Allow from all
    </Directory>
***************************************************
保存退出.
打开http://ip/phpmyadmin 就可以管理你的mysql 数据库了

TOP

5、安装extman
extman 是extmail用户后台管理系统,官方网站为www.extmail.org 下载解压

%tar zxvf extman-13-20060102.tar.gz
%cd extman-0.13-20060102/docs
%mysql -u root -p <extmail.sql
Enter password:
%mysql -u root -p <init.sql
Enter password:

extmail.sql添加了两个MySQL用户

1、只读用户:extmail 密码:extmail

2、读/写用户:webman 密码:webman

init.sql 里,对extmail数据库添加了下面的记录

a、添加了一个别名记录 support@extmail.org ->test@extmail.org

b、增加了 extmail.org 域

c、增加了test@extmail.org的邮箱密码为test。

d、增加了extman 的管理员root@extmail.org 密码为extmail

TOP

五、安装邮件系统
安装下面三个软件要注意先后顺序

1、安装 Courier-IMAP
%cd /usr/ports/mail/courier-imap/
%make install clean
选择openssl、MySQL

在/etc/rc.conf 加入

courier_authdaemond_enable="YES"
courier_imap_pop3d_enable="YES"
courier_imap_imapd_enable="YES"
修改authdaemond的权限

%/usr/local/etc/rc.d/courier-authdaemond.sh start
%chmod -R  +x /var/run/authdaemond/
authdaemond 启动完成后,检查/var/run/authdaemond 下面是否产生socket 文件,因为认证时是通过这个文件读取密码的。

设置/usr/local/etc/authlib/authdaemonrc

%mv authdaemonrc authdaemonrc.bak
ee authdaemonrc
在authdaemonrc 加入下面的内容

authmodulelist="authmysql"
authmodulelistorig="authmysql"
version="authdaemond.mysql"
daemons=5                             
authdaemover=/var/run/authdaemond     
subsystem=mail                        
DEBUG_LOGIN=2                        
DEFAULTOPTIONS="wbnodsn=1

TOP

上面DEBUG_LOGIN=2 是为了调试方便,等系统完全测试完成,可改为 0,即不显示调试信息。

设置/usr/local/etc/authlib/authmysqlrc

%mv authmysqlrc authmysqlrc.bak
ee authmysqlrc

加入下面的内容

MYSQL_SERVER    localhost
MYSQL_USERNAME  extmail
MYSQL_PASSWORD  extmail
MYSQL_PORT      0
MYSQL_OPT       0
MYSQL_DATABASE  extmail

MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,\
                        CONCAT('/home/data/domains/',homedir),               \
                        CONCAT('/home/data/domains/',maildir),               \
                        quota,                                          \
                        name                                            \
                        FROM mailbox                                    \
                        WHERE username = '$(local_part)@$(domain)'
大家要注意,我的邮件保存的目录是/home/data/domains ,你可以跟据你的需要改为自己的目录。

用户名和密码是extmail 这个具体需要看extman 软件包中的docs 目录中的extmail.sql,很多人无法通上发信认证,很可能以上面两个文件配置有关。

创建pop3/imap 的配置文件

#cd /usr/local/etc/courier-imap/

#cp pop3d.cnf.dist pop3d.cnf
#cp imapd.cnf.dist imapd.cnf

修改/usr/local/etc/courier-imap/pop3d (不修改也行)

POP3AUTH="LOGIN CRAM-MD5 CRAM-SHA1"

修改/usr/local/etc/courier-imap/imapd(不修改也行)

IMAP_CAPABILITY="IMAP4rev1 CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA"

TOP


感谢一直以来您对我们的支持!
当前时区 GMT+8, 现在时间是 2008-8-22 06:49 京ICP证060528 号

Designed By 17DST