系统环境Centos6.3 x64
一、安装mysql-5.0.60
#yum remove mysql
# rm -f /etc/my.cnf
# groupadd mysql
# useradd -g mysql -s /bin/false -M mysql
# tar zxvf mysql-5.0.60.tar.gz
# cd mysql-5.0.60
#./configure --prefix=/usr/local/mysql \
--enable-thread-safe-client \
--enable-local-infile --with-charset=gbk \
--with-extra-charset=all \
--with-low-memory
# make
# make install
# cp support-files/my-medium.cnf /etc/my.cnf
# chown -R mysql /usr/local/mysql/var
# /usr/local/mysql/bin/mysql_install_db --user=mysql
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod u+x /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# service mysqld start
# ln -s /usr/local/mysql/bin/* /usr/local/bin
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig -v
二、安装httpd-2.2.20
yum install openssl openssl-devel
# tar jxvf httpd-2.2.20.tar.bz2
# cd httpd-2.2.20
#./configure --prefix=/usr/local/apache \
--sysconfdir=/etc/httpd \
--enable-so --enable-ssl ---enable-track-vars \
--enable-rewrite \
--with-zlib \
--enable-mods-shared=most \
--enable-suexec --with-suexec-caller=daemon \
--with-suexec-docroot=/var/www
# make
# make install
# echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系统启动时服务自动启动)
三、安装php-5.2.17
yum install curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype* patch libxml2
ln -s /usr/lib64/libjpeg.so /usr/lib/
ln -s /usr/lib64/libpng.so /usr/lib/
# tar -zvxf php-5.2.17.tar.gz
# cd php-5.2.17
#./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-openssl --enable-fastcgi \
--enable-mbstring --enable-force-cgi-redirect --enable-sockets \
--with-curl --with-gd --with-zlib --with-png-dir --with-freetype-dir \
--with-jpeg-dir
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini
注:编辑apache配置文件httpd.conf,以apache支持php
# vi /etc/httpd/httpd.conf
1、添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2、定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
四、编译安装POSTFIX
1, 创建运行postfix的用户,组。安装cyrus-sasl
# yum install cyrus-sasl*
# groupadd -g 1000 postfix
# groupadd -g 1200 postdrop
# useradd -u 1000 -g postfix -G postdrop -M -s /sbin/nologin postfix
2, 解压释放源码包,合并补丁包。
# yum install db*-devel
# tar zxvf postfix-2.8.3.tar.gz
# gunzip postfix-2.8.3-vda-ng.patch.gz
# cd postfix-2.8.3
# patch -p1 < ../postfix-2.8.3-vda-ng.patch
3, 编译并进行安装。
# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/lib64/sasl2 -lsasl2'
make && make install
4.配置postfix服务。
vim /etc/postfix/main.cf
myhostname = mail.upchina.cn
myorigin = $mydomain
mydomain = upchina.cn
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = 192.168.1.83, 127.0.0.1
Home_mailbox = Maildir/
# postfix check
# postfix start
5.添加邮件用户,并测试
# groupadd mailusers
# useradd -s /sbin/nologin -g mailusers test1
# useradd -s /sbin/nologin -g mailusers test2
# passwd test1
# passwd test2
查看/home/test2/Maildir/new是否收到邮件
五、建立虚拟用户数据库。
# tar zxvf extman-1.0.1.tar.gz
# cd extman-0.2.5/docs/
# mysql -u root -p < extmail.sql
# mysql -u root -p < init.sql
修改postfix的配置。
vim /etc/postfix/main.cf 添加
#mydestination = $myhostname, localhost.$mydomain, localhost 注释掉这行
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions= permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_auth_enable = yes
mynetworks = 127.0.0.1
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP, Warning:Version not Available!
virtual_mailbox_base = /mailbox
virtual_mailbox_maps= mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
# postfix reload
# cp mysql_virtual_* /etcc/postfix/
五,设置用户认证。
# tar jxvf courier-authlib-0.60.2.tar.bz2
# cd courier-authlib-0.60.2
# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql
# make && make install
# make install-configure
# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon(这一步需注意,这一步若没有,则会出现authdaemon权限拒绝。)
修改authdaemonrc主配置文件,仅保留authmysql认证方式,去掉其它方式。
# cd /usr/local/courier-authlib/etc/authlib/
# vim authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
DEBUG_LOGIN=2
编辑authmysqlrc配置文件
# vim authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD uidnumber
MYSQL_GID_FIELD gidnumber
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/mailbox/',homedir)
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/mailbox/',maildir)
# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
# chmod 755 /etc/rc.d/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig courier-authlib on
# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
# ldconfig
# service courier-authlib start
六、安装Courier-IMAP
# tar jxvf courier-imap-4.1.0.tar.bz2
# cd courier-imap-4.1.0
#./configure --prefix=/usr/local/courier-imap \
--with-redhat \
--enable-unicode \
--disable-root-check \
--with-trashquota \
--without-ipv6 \
CPPFLAGS='-I/usr/include/openssl -I/usr/local/courier-authlib/include' \
LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib' \
COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'
# make
# make install
# cp /usr/local/courier-imap/etc/imapd.dist /usr/local/courier-imap/etc/imapd
# cp /usr/local/courier-imap/etc/imapd-ssl.dist /usr/local/courier-imap/etc/imapd-ssl
# cp /usr/local/courier-imap/etc/pop3d.dist /usr/local/courier-imap/etc/pop3d
# cp /usr/local/courier-imap/etc/pop3d-ssl.dist /usr/local/courier-imap/etc/pop3d-ssl
配置Courier-IMAP,为用户提供pop3服务:
vi /usr/local/courier-imap/etc/pop3d
POP3DSTART=YES
注:如果你想为用户提供IMAP服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes";其它类同;
# mkdir /mailbox
# chown -R postfix:postfix /mailbox
# cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imapd
# chmod 755 /etc/rc.d/init.d/courier-imapd
# chkconfig --add courier-imapd
# chkconfig --level 35 courier-imapd on
# service courier-imapd start
修改cyrus sasl设置。
# vim /usr/lib64/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
# service saslauthd start
建立虚拟用户的邮箱目录,调整权限。
# mkdir -p /mailbox/extmail.org/postmaster/Maildir/
# cd /mailbox/extmail.org/postmaster/Maildir/
# chown -R postfix:postfix /mailbox
测试验证。
#/usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail
七、使用extmail及管理平台。
安装并配置extmail套件。
# tar zxvf extmail-1.0.5.tar.gz -C /var/www
# cd /var/www/
# mv extmail-1.0.5 extmail
# cd extmail/
# chown -R postfix:postfix cgi
# cp webmail.cf.default webmail.cf
# vim /var/www/extmail/webmail.cf
SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /mailbox
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /tmp/mysql.sock
SYS_CONFIG = /var/www/extmail
SYS_LANGDIR = /var/www/extmail/lang
SYS_TEMPLDIR = /var/www/extmail/html
SYS_MYSQL_TABLE = mailbox
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
# chown postfix:postfix /var/www/extmail/cgi
八、安装Extman
1、安装及基本配置
# tar zxvf extman-1.0.1tar.gz
# mv extman-1.0.1 /var/www/extman
修改配置文件以符合本例的需要:
# vi /var/www/extsuite/extman/webman.cf
SYS_MAILDIR_BASE = /mailbox
SYS_CONFIG = /var/www/extmail
SYS_LANGDIR = /var/www/extmail/lang
SYS_TEMPLDIR = /var/www/extmail/html
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /tmp/mysql.sock
SYS_LANG = zh_CN
# chown postfix:postfix /var/www/extman/cgi
# mkdir /tmp/extman
# chown -R postfix.postfix /tmp/extman/
调整http.conf文件中的配置(添加一个虚拟主机),并重新启动服务程序
# vim /etc/httpd/http.conf
User postfix
Group postfix
Include /etc/httpd/extra/httpd-vhosts.conf
# vim //etc/httpd/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName mail.upchina.cn
DocumentRoot /var/www/extmail/html/
ScriptAlias /extmail/cgi /var/www/extmail/cgi
Alias /extmail /var/www/extmail/html
ScriptAlias /extman/cgi /var/www/extman/cgi
Alias /extman /var/www/extman/html
</VirtualHost>
# apache start
游览器访问 mail.upchina.cn,/extman添加一个域,默认管理员账号root,密码:extmail*123*并且添加用户测试
九、接下来安装图形日志的运行所需要的软件包Time::HiRes、File::Tail和rrdtool,注意:安装图形日志以前,请确保您的系统已经安装了gd gd-devel tcl tcl-devel libart libart-devel软件包
安装Time::HiRes
# tar zxvf Time-HiRes-1.9719.tar.gz
# cd Time-HiRes-1.9719
# perl Makefile.PL
# make
# make test
# make install
# tar zxvf Unix-Syslog-1.1.tar.gz
# tar zxvf DBI-1.607.tar.gz
# tar zxvf DBD-mysql-4.011.tar.gz
# cd Unix-Syslog-1.1
# perl Makefile.PL
# make && make install
# cd ../DBI-1.607
# perl Makefile.PL
# make && make install
# cd ../DBD-mysql-4.011
# perl Makefile.PL
# make && make install
# tar zxvf GD-2.41.tar.gz
# tar zxvf File-Tail-0.99.3.tar.gz
# cd GD-2.41
# perl Makefile.PL
# make && make install
# cd ../File-Tail-0.99.3
# perl Makefile.PL
# make && make install
# yum install rrdtool rrdtool-perl
复制mailgraph_ext到/usr/local,并启动
# cp -r /var/www/extman/addon/mailgraph_ext /usr/local
# /usr/local/mailgraph_ext/mailgraph-init start
添加到自动启动队列
echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
好了,接下来您就可以到extman的后台查看图表日志了。
Extman 系统信息显示 No such file or directory,就是没有启动cmdserver造成的
# /var/www/extman/daemon/cmdserver -d
转载于:https://blog.51cto.com/363070085/1281304