/etc/postfix/sasl/smtpd.conf
引用:
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login cram-md5 digest-md5
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: provider_admin
sql_passwd: xxxxxx
sql_database: provider
sql_select: select password from users where email='%u@%r'


chown root:postfix /etc/postfix/sasl/smtpd.conf
chmod u=rw,g=r,o= /etc/postfix/sasl/smtpd.conf

openssl req -new -outform PEM -out /etc/postfix/smtpd.cert -newkey rsa:2048 \
-nodes -keyout /etc/postfix/smtpd.key -keyform PEM -days 3650 -x509
chmod u=rw,g=r,o= /etc/postfix/smtpd.key
chown root:postfix /etc/postfix/smtpd.key

/etc/courier/authdaemonrc
引用:
authmodulelist="authmysql"


/etc/courier/authmysqlrc
引用:
MYSQL_SERVER localhost
MYSQL_USERNAME provider_admin
MYSQL_PASSWORD xxxxxx
MYSQL_PORT 0
MYSQL_DATABASE provider
MYSQL_USER_TABLE users
#MYSQL_CRYPT_PWFIELD (comment this out)
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
#MYSQL_NAME_FIELD (comment this out)


/etc/init.d/courier-authdaemon restart
重启Postfix:/etc/init.d/postfix restart

☆Apache 2.0.54/PHP 4.3.10
apt-get install apache2 apache2-doc
apt-get install libapache2-mod-php4 libapache2-mod-perl2 php4 php4-cli php4-common php4-curl php4-dev php4-domxml php4-gd
php4-imap php4-ldap php4-mcal php4-mhash php4-mysql php4-odbc php4-pear php4-xslt curl libwww-perl imagemagick

编辑/etc/php4/apache2/php.ini,修改:
引用:
display_errors = off
disable_functions = phpinfo, get_cfg_var

编辑/etc/apache2/apache2.conf,修改:
引用:
AddDefaultCharset off
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.pl index.xhtml

激活SSL, rewrite, deflate模块
echo 'Listen 443' >> /etc/apache2/ports.conf
a2enmod ssl (rewrite / deflate)
apache2-ssl-certificate
重启Apache:/etc/init.d/apache2 restart

PHPMyAdmin 2.6.2/SquirrelMail 1 .4.4
apt-get install phpmyadmin squirrelmail
/usr/sbin/squirrelmail-configure
ln –s /usr/share/squirrelmail /var/www/webmail

编辑/etc/apache2/httpd.conf:
引用:
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
ErrorLog "|/usr/sbin/rotatelogs /var/log/apache2/www.example.com_error.log 604800"
CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/www.example.com_access.log 604800" combined
</VirtualHost>
<VirtualHost *:443>
ServerName mail.example.com
DocumentRoot /var/www/webmail
ErrorLog /var/log/apache2/mail.example.com_error.log
CustomLog /var/log/apache2/mail.example.com_access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
</VirtualHost>


☆ProFTPd 1.2.10 + MySQL认证
apt-get install proftpd-mysql
groupadd -g 5500 ftpgroup
useradd -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser
CREATE DATABASE `proftpd`;
GRANT select, insert, update, delete on proftpd_admin@localhost IDENTIFIED BY 'xxxxxx';
USE proftpd;

CREATE TABLE `ftpgroup` (
`groupname` varchar(16) NOT NULL default '',
`gid` smallint(6) NOT NULL default '5500',
`members` varchar(16) NOT NULL default '',
KEY `groupname` (`groupname`)
) TYPE=MyISAM;
INSERT INTO 'ftpgroup' VALUES ('ftpgroup',5500, 'ftpuser');

CREATE TABLE `ftpuser` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` varchar(32) NOT NULL default '',
`passwd` varchar(32) NOT NULL default '',
`uid` smallint(6) NOT NULL default '5500',
`gid` smallint(6) NOT NULL default '5500',
`homedir` varchar(255) NOT NULL default '',
`shell` varchar(16) NOT NULL default '/bin/false',
`count` int(11) NOT NULL default '0',
`accessed` datetime NOT NULL default '0000-00-00 00:00:00',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
`LoginAllowed` enum('true','false') NOT NULL default 'true',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
INSERT INTO ftpuser (userid,passwd,uid,gid,homedir,shell) VALUES ('username','xxxxxx',5500,5500,'/home/username', '/sbin/nologin');

CREATE TABLE `ftpquotalimits` (
`name` varchar(30) default NULL,
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`par_session` enum('false','true') NOT NULL default 'false',
`limit_type` enum('soft','hard') NOT NULL default 'soft',
`bytes_up_limit` float NOT NULL default '0',
`bytes_down_limit` float NOT NULL default '0',
`bytes_transfer_limit` float NOT NULL default '0',
`files_up_limit` int(10) unsigned NOT NULL default '0',
`files_down_limit` int(10) unsigned NOT NULL default '0',
`files_transfer_limit` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;
INSERT INTO ftpquotalimits VALUES ('testuser','user','false','soft','104857600','0','0','0','0','0');

CREATE TABLE `ftpquotatotal` (
`name` varchar(30) NOT NULL default '',
`quota_type` enum('user','group','class','all') NOT NULL default 'user',
`bytes_up_total` float NOT NULL default '0',
`bytes_down_total` float NOT NULL default '0',
`bytes_transfer_total` float NOT NULL default '0',
`files_up_total` int(10) unsigned NOT NULL default '0',
`files_down_total` int(10) unsigned NOT NULL default '0',
`files_transfer_total` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;

编辑/etc/proftpd.conf:
引用:
SQLAuthTypes Plaintext
SQLAuthenticate users groups
SQLConnectInfo proftpd@localhost proftpd_admin xxxxxx
SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLUserWhereClause "LoginAllowed = 'true'"
SQLGroupInfo ftpgroup groupname gid members
SQLHomedirOnDemand on
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on
SQLNamedQuery get-quota-limit SELECT "name, quota_type, par_session, limit_type, bytes_up_limit, bytes_down_limit, bytes_transfer_
limit, files_up_limit, files_down_limit, files_transfer_limit FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_up_total, bytes_down_total, bytes_transfer_total, files_up_total, files
_down_total, files_transfer_total FROM ftpquotatotal WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery update-quota-tally UPDATE "bytes_up_total = bytes_up_total + %{0}, bytes_down_total = bytes_down_total + %{1}, bytes_transfer_total = bytes_transfer_total + %{2}, files_up_total = files_up_total + %{3}, files_down_total = files_down_total + %{4}, files_transfer_total = files_transfer_total + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatotal
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatotal
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
DefaultRoot ~
RootLogin off
RequireValidShell off
SQLLogFile /var/log/proftpd.mysql.log
LogFormat auth "%v [%P] %h %t \"%r\" %s"
ExtendedLog /var/log/proftpd.auth.log AUTH auth
LogFormat write "%h %l %u %t \"%r\" %s %b"
ExtendedLog /var/log/proftpd.access.log WRITE,READ write