rhel6.0+postfix+mysql+dovecot+extmail+sasl+tls

rhel6.0+postfix+mysql+dovecot+extmail Command History

0. disable SELinux -> setenforce 0

# yum -y install mysql mysql-server httpd telnet perl-CGI gcc perl-GD rrdtool-perl dovecot perl-Encode-Detect dovecot-mysql perl-ExtUtils-MakeMaker perl-Time-HiRes
# tar xf Unix-Syslog-1.1.tar.gz
# cd Unix-Syslog-1.1
# perl Makefile.PL
# make test
# make install

# tar xf File-Tail-0.99.3.tar.gz
# cd File-Tail-0.99.3
# perl Makefile.PL
# make test
# make install

# chkconfig mysqld dovecot httpd on
# chkconfig mysqld httpd on
# chkconfig mysqld dovecot  on

# /etc/init.d/mysqld start
# /usr/bin/mysql_secure_installation

# mkdir /var/www/extsuite
# tar xf extmail-1.2.tar.gz -C /var/www/extsuite
# tar xf extman-1.1.tar.gz -C /var/www/extsuite
# cd /var/www/extsuite
# mv extmail-1.2/ extmail
# mv extman-1.1/ extman
# cd extman/docs
# cp extmail.sql linuxcbt.sql
# vi linuxcbt.sql
USE mysql;
INSERT INTO user (Host, User, Password) VALUES ('localhost','mailadmin',password('westos'));
INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'maildb', 'mailadmin', 'Y', 'Y', 'Y', 'Y');
FLUSH PRIVILEGES;
GRANT USAGE ON maildb.* TO maildb@localhost;
GRANT SELECT, UPDATE ON maildb.* TO maildb@localhost;
GRANT USAGE ON maildb.* TO mailadmin@localhost;
GRANT SELECT, INSERT, DELETE, UPDATE ON maildb.* TO mailadmin@localhost;
CREATE DATABASE maildb;
USE maildb;
...

# mysql -p < linuxcbt.sql
# cp init.sql init.linuxcbt.sql
# vi init.linuxcbt.sql
use maildb;
/*!40000 ALTER TABLE `alias` DISABLE KEYS */;
LOCK TABLES `alias` WRITE;
INSERT INTO `alias` VALUES ('support@linuxcbt.com','postmaster@linuxcbt.com','linuxcbt.com','2007-02-14 15:10:04',1);
UNLOCK TABLES;
/*!40000 ALTER TABLE `alias` ENABLE KEYS */;
/*!40000 ALTER TABLE `domain` DISABLE KEYS */;
LOCK TABLES `domain` WRITE;
INSERT INTO `domain` VALUES ('linuxcbt.com','virtualDomain for linuxcbt.com','A0/B0',50,50,1073741824,1073741824,NULL,'1','5242880','5242880','1y','0','0','0','0','1','0','2007-02-14 15:10:04','2010-11-08',1);
UNLOCK TABLES;
/*!40000 ALTER TABLE `domain` ENABLE KEYS */;
/*!40000 ALTER TABLE `mailbox` DISABLE KEYS */;
/* postmaster@linuxcbt.com password is westos */
LOCK TABLES `mailbox` WRITE;
INSERT INTO `mailbox` VALUES ('postmaster@linuxcbt.com','postmaster','westos','','PostMaster','','linuxcbt.com/postmaster/Maildir/','linuxcbt.com/postmaster','104857600S','52428800S','linuxcbt.com',1000,1000,'2007-02-14 15:10:04','2010-11-08',1,0,0,0,0,0,0,0,'my question','my answer');
UNLOCK TABLES;
/*!40000 ALTER TABLE `mailbox` ENABLE KEYS */;

/*!40000 ALTER TABLE `manager` DISABLE KEYS */;
/* [email protected] password is westos */
LOCK TABLES `manager` WRITE;
INSERT INTO `manager` VALUES ('root@linuxcbt.com','westos','admin','root','Super User','my question','my answer','0','2007-02-14 15:10:04','2010-11-08',1);
UNLOCK TABLES;
/*!40000 ALTER TABLE `manager` ENABLE KEYS */;

# mysql -p < init.linuxcbt.sql
# cp mysql_virtual_* /etc/postfix/
# cd /etc/postfix/
# rm -rf mysql_virtual_limit_maps.cf
# rm -rf mysql_virtual_sender_maps.cf
# vi mysql_virtual_alias_maps.cf
user = mailadmin
password = westos

hosts = localhost
dbname = maildb
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'

# vi mysql_virtual_domains_maps.cf
user = mailadmin
password = westos

hosts = localhost
dbname = maildb
table = domain
select_field = domain
where_field = domain
additional_conditions = AND active = '1'

# vi mysql_virtual_mailbox_maps.cf
user = mailadmin
password = westos

hosts = localhost
dbname = maildb
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'

# postmap -q "[email protected]" mysql:/etc/postfix/mysql_virtual_alias_maps.cf
[email protected]

# postmap -q "[email protected]" mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
linuxcbt.com/postmaster/Maildir/

# postmap -q "linuxcbt.com" mysql:/etc/postfix/mysql_virtual_domains_maps.cf
linuxcbt.com

# useradd -u 600 -s /sbin/nologin email
# postconf -d | grep virtual
# postconf -e virtual_mailbox_base=/home/email
# postconf -e virtual_uid_maps=static:600
# postconf -e virtual_gid_maps=static:600
# postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql_virtual_alias_maps.cf
# postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domains_maps.cf
# postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
# postconf -e inet_interface=all
# /etc/init.d/postfix restart

# cd /etc/dovecot/conf.d/
# vi 10-mail.conf
mail_location = maildir:/home/email/%d/%n/Maildir

# cp
/etc/dovecot/conf.d/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf
# cd /etc/dovecot/
# cp /usr/share/doc/dovecot-2.0/example-config/dovecot-sql.conf.ext .
# vi dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=maildb user=mailadmin password=westos
default_pass_scheme = PLAIN
password_query = \
  SELECT username, domain, password \
  FROM mailbox WHERE username = '%u'
user_query = \
  SELECT maildir, 600 AS uid, 600 AS gid \
  FROM mailbox WHERE username = '%u'

# /etc/init.d/dovecot restart
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready. <[email protected]>
user [email protected]
+OK
pass westos
+OK Logged in.
list
+OK 1 messages:
1 573


# vim /etc/httpd/conf/httpd.conf
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName server17.example.com
</VirtualHost>
<VirtualHost *:80>
    ServerName mail.linuxcbt.com
    DocumentRoot /var/www/extsuite/extmail/html/
    ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
    Alias /extmail /var/www/extsuite/extmail/html
    ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
    Alias /extman /var/www/extsuite/extman/html
    SuexecUserGroup email email
</VirtualHost>

# cd /var/www/extsuite/extmail/
# chown -R email.email cgi/
# cp webmail.cf.default webmail.cf
# vi webmail.cf
SYS_MAILDIR_BASE = /home/email
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = mailadmin
SYS_MYSQL_PASS = westos
SYS_MYSQL_DB = maildb

# cd /var/www/extsuite/extman/
# cp webman.cf.default webman.cf
# chown -R email.email cgi/
# vi webmail.cf
SYS_MAILDIR_BASE = /home/email
SYS_SESS_DIR = /tmp/
SYS_GROUPMAIL_SENDER = [email protected]
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = mailadmin
SYS_MYSQL_PASS = westos
SYS_MYSQL_DB = maildb

# cd /var/www/extsuite/extman/addon
# cp -r mailgraph_ext/ /usr/local/
# /usr/local/mailgraph_ext/mailgraph-init start

# vi /etc/hosts
192.168.0.248    mail.linuxcbt.com

# postconf -e smtpd_sasl_auth_enable=yes
# postconf -e smtpd_sasl_authenticated_header=yes
# postconf -e smtpd_sasl_type=dovecot
# postconf -e smtpd_sasl_path=private/auth
# postconf -e broken_sasl_auth_clients=yes
# postconf -e "smtpd_recipient_restrictions = permit_sasl_authenticated, permit_tls_clientcerts, permit_mynetworks, reject_unauth_destination"

# postconf -e smtpd_tls_cert_file=/etc/postfix/postfix.pem
# cd /etc/pki/tls/certs/ && make postfix.pem && cp postfix.pem /etc/postfix/

# postconf -e smtpd_tls_received_header=yes
# postconf -e smtp_tls_security_level=may
# vi /etc/dovecot/conf.d/10-master.conf

service auth {

  unix_listener /var/spool/postfix/private/auth {
    mode = 0600
    user =
    group =
  }
}

你可能感兴趣的:(linux,mysql,数据库,postfix,ExtMail)