基于FreeBSD5.4全能服务器安装(dns,ftp,apache,qmail)

###################################################基本设置#####################################################
setenv PACKAGEROOT "ftp://ftp.jp.freebsd.org"
pkg_add -r cvsup-without-gui
ee /etc/rc.conf
add
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

mkdir /usr/home/chb/pkg_info
reboot
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_cvsup-without-gui.txt



##################################################同步系统代码###################################################
cvsup -g -L 2 -h cvsup.jp.FreeBSD.org /usr/share/examples/cvsup/standard-supfile

reboot



##################################################编译系统内核###################################################
cd /usr/src
make -j4 buildworld
cd /usr/src/sys/i386/conf
cp GENERIC /root/GENERIC.OLD
ee NS1
cd /usr/src
make buildkernel
make installkernel
shutdown -r now

mergemaster -p
cd /usr/src
make installworld
mergemaster
shutdown -r now

delete

/usr/obj
cd /usr/obj
chflags -R noschg *
rm -rf *

###############################################同步ports软件包###############################################
cvsup -g -L 2 -h cvsup.jp.FreeBSD.org /usr/share/examples/cvsup/ports-supfile
reboot



################################################设置bind######################################################

%%%%%%%%%%%%%%%%%建立正反向解析目录%%%%%%%%%%%%%%%

mkdir /etc/namedb/rev
mkdir /etc/namedb/hosts

%%%%%%%%%%%%%%%改变正反向解析目录属性%%%%%%%%%%%%%

chown bind:bind /etc/namedb/rev
chown bind:bind /etc/namedb/hosts
chmod 750 /etc/namedb/rev
chmod 750 /etc/namedb/hosts
%%%%%%%%%%%%%生成正反向解析文件的例子文件%%%%%%%%%
cd /etc/namedb
sh make-localhost
%%%%%%%%%%%%%%%%生成这正反向解析文件%%%%%%%%%%%%%%
cp /etc/namedb/master/localhost.rev /etc/namedb/rev/192.168.0.rev
cp /etc/namedb/master/localhost.rev /etc/namedb/hosts/tjhaina.net.hosts



%%%%%%%%%%%%%%%%设置DNS服务器的主域%%%%%%%%%%%%%%%
ee /etc/namedb/named.conf

zone "0.168.192.IN-ADDR.ARPA" {
type master;
file "/etc/namedb/rev/192.168.0.rev";
};
zone "tjhaina.net" {
type master;
file "/etc/namedb/hosts/tjhaina.net.hosts";
};


%%%%%%%%%%%%%设置DNS服务器反向解析文件%%%%%%%%%%%%%

ee /etc/namedb/rev/192.168.0.rev

$TTL 3600

@ IN SOA ns1.tjhaina.net. root.ns1.tjhaina.net. (
20050430 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns1.tjhaina.net.
205 IN PTR ns1.tjhaina.net.
205 IN PTR www.tjhaina.net.



%%%%%%%%%%%%%设置DNS服务器的正向击文件%%%%%%%%%%%%%%

ee /etc/namedb/hosts/tjhaina.net.hosts


$TTL 3600

@ IN SOA ns1.tjhaina.net. root.ns1.tjhaina.net. (
20050621 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns1.tjhaina.net.
ns1 IN A 192.168.0.205
www IN A 192.168.0.205
tjhaina.net. IN MX 10 ns1.tjhaina.net.



%%%%%%%%%%%%%生成DNS服务器的key文件%%%%%%%%%%%%%%%%%
/usr/sbin/rndc-confgen > /etc/namedb/rndc.conf


%%%%%%%%%%%%将key文件导入named.conf文件%%%%%%%%%%%%%
cd /etc/namedb
tail -n10 rndc.conf | head -n9 | sed -e s/#\ //g >> named.conf

%%%%%%%%%%%%%%%%%%%启动DNS服务器%%%%%%%%%%%%%%%%%%%%
/usr/sbin/named -gc /etc/namedb/named.conf &
/usr/sbin/rndc status


%%%%%%%%%%%%%%%%%%设置本机DNS服务器地址%%%%%%%%%%%%%
ee /etc/resolv.conf

add

nameserver 127.0.0.1
nameserver 211.98.2.4
nameserver 202.99.104.68
nameserver 202.99.96.68
nameserver 202.102.128.68
nameserver 202.103.0.117
nameserver 202.103.44.5


%%%%%%%%%%%%删除或注释掉DNS服务器的监听地址%%%%%%%%
ee /etc/namedb/named.conf
delete
20 listen-on { 127.0.0.1; };
rndc reload

%%%%%%%%%%%%使DNS服务器和系统一起启动%%%%%%%%%%%%%%
ee /etc/rc.conf
add
named_enable="YES"


###############################################安装perl5.8.X########################################################
cd /usr/ports/lang/perl5.8

make WITH_DEBUGGING=yes \
WITH_GDBM=yes \
WITHOUT_PERL_MALLOC=yes \
WITHOUT_PERL_64BITINT=yes \
WITH_THREADS=yes \
ENABLE_SUIDPERL=yes

make test
make install
make clean
make rmconfig
shutdown -r now
perl -v
ps auwx|grep perl
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_perl5.8.txt



#############################更改ports软件包的默认下载路径(因为只有安装了perl后才会有/etc/make.conf)##############
ee /etc/make.conf

add

MASTER_SITE_OVERRIDE=ftp://ftp3.jp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}




###############################################安装openssl##########################################################
cd /usr/ports/security/openssl
make
make install
make clean
make rmconfig
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_openssl.txt



##############################################安装web管理系统webmin################################################
cd /usr/ports/sysutils/webmin
make
make install
make clean
make rmconfig
/usr/local/lib/webmin/setup.sh
ee /etc/rc.conf
add
webmin_enable="YES"

pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_webmin.txt



##############################################安装数据库mysql4.0#####################################################
cd /usr/ports/databases/mysql40-server
make WITH_CHARSET=gbk \
WITH_XCHARSET=all \
SKIP_DNS_CHECK=yes \
BUILD_OPTIMIZED=yes \
BUILD_STATIC=yes
make install
make clean
make rmconfig

pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_mysql40-server.txt

%%%%%%%%%%%%%%%%%%安装mysql40组件%%%%%%%%%%%%%%%%%%
cd /usr/ports/databases/p5-DBD-mysql40
make
make install
make clean
make rmconfig

%%%%%%%%%%%%%%%使mysql40和系统一起启动%%%%%%%%%%%%%
ee /etc/rc.conf
mysql_enable="YES"

%%%%%%%%%%%%%%%%%启动mysql40%%%%%%%%%%%%%%%%%%%%%%%
start mysql
#/usr/local/share/mysql/mysql.server start
/usr/local/etc/rc.d/mysql-server.sh start

%%%%%%%%%%%%%%%%%%设置mysql40的密码%%%%%%%%%%%%%%%%
/usr/local/bin/mysqladmin -u root password 'password'
reboot
mysql -u root -ppassword
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_mysql40.txt



###############################################安装expat2#############################################################
cd /usr/ports/textproc/expat2
make
make install
make clean
make rmconfig
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_expat2.txt



###############################################安装web服务器apache1.33################################################
cd /usr/ports/www/apache13
make
make install
make clean
make rmconfig

%%%%%%%%%%%%%%%%%%使apache和系统一起启动%%%%%%%%%%%
ee /etc/rc.conf
add
apache_enable="YES"

%%%%%%%%%%%%%%%%更改apache的相应设置%%%%%%%%%%%%%%%
ee /usr/local/etc/apache/httpd.conf
change 330
ServerAdmin you@your.address ==>ServerAdmin b.s.d@163.com
change 348
#ServerName www.example.com==>ServerName www.tjhaina.net
add 794
AddLanguage zh-cn .zh-cn
add 822
Addcharset GB2312 .gb2312
add 977
NameVirtualHost 192.168.0.205 (your hosts ip)

%%%%%%%%%%%%%%%%%%%%启动apache%%%%%%%%%%%%%%%%%%%%
start apache
/usr/local/sbin/apachectl start
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_apache.txt



##############################################安装php###############################################################
cd /usr/ports/lang/php4
make
make install
make clean
make rmconfig
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_php4.txt



##############################################安装php扩展###########################################################
cd /usr/ports/lang/php4-extensions
make (+ bz2)
make install
make clean
make rmconfig
cd /usr/local/etc
cp php.ini-recommended php.ini
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_php4-extensions.txt



##############################################安装phpSysInfo基于php的系统监测###########################################
cd /usr/ports/www/phpSysInfo/
make
make install
make clean
make rmconfig
cd /usr/local/www/data/phpSysInfo/
cp config.php.new config.php
chown www:www config.php
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_phpSysInfo.txt



#############################################安装phpmyadmin基于php的数据库web管理系统###################################
cd /usr/ports/databases/phpmyadmin/
make
make install
make clean
make rmconfig

%%%%%%%%%%%%%%%%%%更改phpMyAdmin的配置%%%%%%%%%
cd /usr/local/www/phpMyAdmin
chmod 755 config.inc.php
ee /usr/local/www/phpMyAdmin/config.inc.php
将84行
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
改成
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
将39行
$cfg['PmaAbsoluteUri'] = ' ';
改成
$cfg['PmaAbsoluteUri'] = 'http://192.168.0.205/phpMyAdmin/';
pkg_info
pkg_info | col -b > /usr/home/chb/pkg_info/pkg_info_phpmyadmin.txt







#################################安装ftp服务器pure-ftpd############################
cd /usr/ports/ftp/pure-ftpd
ee /usr/ports/ftp/pure-ftpd/Makefile
add

--with-everything \
--with-paranoidmsg \
--with-virtualchroot \
--with-tls \
--with-largefile \
--with-welcomemsg \
--with-uploadscript \
--with-cookie \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-quotas \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling \
--sysconfdir=${PREFIX}/etc

make WITH_MYSQL=1 WITH_LANG=simplified-chinese
make install
make clean
make rmconfig



cd /usr/local/etc
cp pureftpd-mysql.conf.sample pureftpd-mysql.conf
cp pure-ftpd.conf.sample pure-ftpd.conf
ee /usr/local/etc/pure-ftpd.conf

changes
NoAnonymous no
77 NoAnonymous yes
# MySQLConfigFile /etc/pureftpd-mysql.conf
116 MySQLConfigFile /usr/ocal/etc/pureftpd-mysql.conf
#UserRatio 1 10
201 UserRatio 1 10
MinUID 100
240 MinUID 2000
AllowUserFXP no
246 AllowUserFXP yes
#AltLog w3c:/var/log/pureftpd.log
318 AltLog w3c:/var/log/pureftpd.log
#NoChmod yes
324 NoChmod yes
# KeepAllFiles yes
330 KeepAllFiles no
#CreateHomeDir yes
336 CreateHomeDir yes


ee /usr/local/etc/pureftpd-mysql.conf

# MYSQLServer 127.0.0.1
12 MYSQLServer 127.0.0.1
# MYSQLPort 3306
17 MYSQLPort 3306
MYSQLUser root
27 MYSQLUser ftp
MYSQLPassword rootpw
32 MYSQLPassword password
MYSQLDatabase pureftpd
37 MYSQLDatabase ftpusers
MYSQLCrypt cleartext
45 MYSQLCrypt md5
MYSQLDefaultUID 1000
73 MYSQLDefaultUID 2000
#MYSQLDefaultGID 1000
83 MYSQLDefaultGID 2000
# MySQLGetQTAFS ELECT QuotaFiles FROM users WHERE User="\L"
94 MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User="\L"
#MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"
101 MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User="\L"
# MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L"
# MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L"
106 MySQLGetRatioUL SELECT ULRatio FROM users WHERE User="\L"
107 MySQLGetRatioDL SELECT DLRatio FROM users WHERE User="\L"
# MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L"
114 MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L"
# MySQLForceTildeExpansion 1
115 MySQLForceTildeExpansion 1
# MySQLTransactions On
129 MySQLTransactions On


###################################建立ftp用户组###################################

pw groupadd ftpusers -g 2000
pw useradd ftp -u 2000 -g ftpusers -s /sbin/nologin
#########################################添加ftp用户数据库#########################
upload
script.mysql
mysql -u root -ppassword < script.mysql

######################################script.mysql##################################
INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv,
Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv,
Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv,
Index_priv, Alter_priv) VALUES
('localhost','ftp',PASSWORD('password'),'Y','Y','Y','Y','N','N','N','N',
'N','N','N','N','N','N');

FLUSH PRIVILEGES;

CREATE DATABASE ftpusers;

USE ftpusers;

CREATE TABLE admin (
Username varchar(35) NOT NULL default '',
Password char(32) binary NOT NULL default '',
PRIMARY KEY (Username)
) TYPE=MyISAM;

INSERT INTO admin VALUES ('Administrator',MD5('password'));

CREATE TABLE users (
User char(16) NOT NULL default '',
Password char(32) binary NOT NULL default '',
Uid int(11) NOT NULL default '2000',
Gid int(11) NOT NULL default '2000',
Dir char(128) NOT NULL default '',
QuotaFiles int(10) NOT NULL default '500',
QuotaSize int(10) NOT NULL default '30',
ULBandwidth int(10) NOT NULL default '80',
DLBandwidth int(10) NOT NULL default '80',
status enum('0','1') NOT NULL default '1',
ipaccess varchar(15) NOT NULL default '*',
comment tinytext NOT NULL,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;

INSERT INTO `users` VALUES ('test1',MD5('123456'),2001,2000,'/home/test1',500,30,80,5,1,'*','*');
#################################################################################################




####################################启动pure-ftpd###################################
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf

提示一下信息证明pure-ftpd已经工作
Running: /usr/local/sbin/pure-ftpd -A -c50 -B -C8 -D -E -fftp -H -I15
-lmysql:/usr/local/etc/pureftpd-mysql.conf -L2000:8 -m4 -Q1:10 -s -U133:022
-u100 -Ow3c:/var/log/pureftpd.log -j -k99 -Z


####################################设置ftp管理界面################################

upload
chinaPHP_Manager
ee config.php


require 'language.php';

$LANG = $ZH_CN; // Language (Options are $DUTCH, $ENGLISH, $PT_BR, $RUSSIAN
// $SPANISH, $COREAN, $FRENCH, $HUNGARIAN, $GERMAN
// $TURKISH, $DANISH , $NORWEGIAN or $ZH_CN)

$LocationImages = "images"; // Location of images

$DBHost = "localhost"; // Ip-adres of MySQL server
// (Dont change this if you are using the default database)

$DBLogin = "ftp"; // Username of MySQL user

$DBPassword = "password"; // Password of MySQL user

$DBDatabase = "ftpusers"; // Name of database

$FTPAddress = "192.168.0.205:21"; // Domain name or ip-address of your ftp server

$DEFUserID = "2000"; // nobody // Default user id of virtual ftp user.

$DEFGroupID = "2000"; // guest // Default group is of virtual ftp user.

###############################设置ftp管理的虚拟主机##############################
ee /usr/local/etc/apache/httpd.conf

add

<VirtualHost 192.168.0.205>
DocumentRoot "/home/chb/ftp"
ServerName www.tjhaina.net
<Directory "/home/chb/ftp">
allow from all
Options +Indexes
</Directory>
</VirtualHost>






#################################增加ftp启动项#####################################
ee /etc/rc.conf
add
pureftpd_enable="YES"














#############################################下载软件包##############################################################
Part 1 - Download the Software(http://www.qmailrocks.org/downloads/qmailrocks.tar.gz)


mkdir /downloads
cd /downloads
tar zxvf qmailrocks.tar.gz




#############################################安装qmail主程序###########################################################
Part 2 - Installing Qmail Itself


/downloads/qmailrocks/scripts/install/qmr_install_freebsd-s1.script
/downloads/qmailrocks/scripts/util/qmail_patches.script
cd /usr/src/qmail/qmail-1.03

make man
make setup check
./config-fast mail.tjhaina.net

/usr/ports/mail/qmail
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cd /usr/src/qmail/ucspi-tcp-0.88/
make
make setup check

/usr/ports/sysutils/ucspi-tcp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cd /package/admin/daemontools-0.76
package/install
reboot

/usr/ports/sysutils/daemontools
#############################################Part 3 - EZmlm############################################################
Part 3 - EZmlm
cd /downloads/qmailrocks/
tar zxvf ezmlm-0.53-idx-0.41.tar.gz
cd ezmlm-0.53-idx-0.41
make
make setup


/usr/ports/mail/ezmlm
#########################################Part 4 - Qmail-Autoresponder ##################################################
Part 4 - Qmail-Autoresponder
#pkg_add -r qmail-autoresponder
cd /downloads/qmailrocks
pkg_add qmail-autoresponder-0.96.1.tbz


/usr/ports/mail/qmail-autoresponder
##############################################art 5 - Vpopmail##########################################################
Part 5 - Vpopmail(I would like to install vpopmail with MySQL integration)
mkdir -p ~vpopmail/etc
mysql -u root -p
CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY 'password';
quit
mysql -u vpopmailuser -p
quit
upload
iGENUS.mysql
mysql -u root -p < /home/chb/iGENUS.mysql
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%iGENUS.mysql%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DROP DATABASE vpopmail;
CREATE DATABASE vpopmail;
USE vpopmail;

CREATE TABLE `address` (
`id` int(11) unsigned NOT NULL auto_increment,
`pw_id` int(5) NOT NULL default '0',
`name` varchar(64) NOT NULL default '',
`email` varchar(128) NOT NULL default '',
UNIQUE KEY `id` (`id`),
KEY `pw_id` (`pw_id`)
) TYPE=MyISAM PACK_KEYS=1 ;

CREATE TABLE `admin` (
`id` int(10) unsigned NOT NULL auto_increment,
`site_id` int(10) unsigned NOT NULL default '0',
`domain` varchar(128) NOT NULL default '',
`quota` smallint(5) unsigned NOT NULL default '0',
`total` smallint(5) unsigned NOT NULL default '0',
`createtime` timestamp(14) NOT NULL,
`login` char(1) NOT NULL default '',
`cur_total` smallint(5) NOT NULL default '0',
`cur_quota` smallint(5) NOT NULL default '0',
`gid` varchar(11) NOT NULL default '',
`expiration_time` timestamp(14) NOT NULL,
`flag` int(10) unsigned NOT NULL default '0',
`maxmsg` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `domain` (`domain`)
) TYPE=MyISAM PACK_KEYS=1 ;

CREATE TABLE `card` (
`id` int(5) unsigned NOT NULL auto_increment,
`pw_id` int(5) unsigned NOT NULL default '0',
`LinkMan` varchar(64) NOT NULL default '',
`CompanyName` varchar(100) NOT NULL default '',
`Address` varchar(255) NOT NULL default '',
`Position` varchar(32) NOT NULL default '',
`PhoneNumber` varchar(16) NOT NULL default '',
`Mobile` varchar(12) NOT NULL default '',
`Email` varchar(128) NOT NULL default '',
`Partaker` varchar(32) NOT NULL default '',
`Memo` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;

CREATE TABLE `lastauth` (
`user` char(32) NOT NULL default '',
`domain` char(64) NOT NULL default '',
`remote_ip` char(18) NOT NULL default '',
`timestamp` bigint(20) NOT NULL default '0',
PRIMARY KEY (`user`,`domain`)
) TYPE=MyISAM;

CREATE TABLE `logs` (
`pw_id` int(5) default '0',
`ip` varchar(15) NOT NULL default '',
`action` varchar(15) NOT NULL default '',
`time` datetime default NULL,
`content` varchar(64) NOT NULL default '',
`email` varchar(128) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE `message` (
`id` int(5) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`body` text NOT NULL,
`createtime` datetime NOT NULL default '0000-00-00 00:00:00',
`updatetime` datetime NOT NULL default '0000-00-00 00:00:00',
`pw_domain` varchar(64) NOT NULL default '',
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM ;

CREATE TABLE `personal` (
`id` int(11) unsigned NOT NULL auto_increment,
`pw_id` int(5) NOT NULL default '0',
`truename` varchar(10) NOT NULL default '',
`fax` varchar(20) NOT NULL default '',
`telephone` varchar(15) NOT NULL default '',
`sex` int(1) NOT NULL default '0',
`year` int(4) NOT NULL default '0',
`MONTH` int(2) NOT NULL default '0',
`DAY` int(2) NOT NULL default '0',
`education` varchar(4) NOT NULL default '',
`marital` int(1) NOT NULL default '0',
`occupation` varchar(15) NOT NULL default '',
`companyname` varchar(30) NOT NULL default '',
`province` varchar(6) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM PACK_KEYS=1 ;

CREATE TABLE `scheduler` (
`id` int(11) unsigned NOT NULL auto_increment,
`begin_time` int(11) unsigned default NULL,
`end_time` int(11) unsigned default NULL,
`title` varchar(255) NOT NULL default '',
`body` varchar(255) NOT NULL default '',
`pw_id` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;

CREATE TABLE `stow` (
`id` int(5) unsigned NOT NULL auto_increment,
`pw_id` int(5) unsigned NOT NULL default '0',
`Name` varchar(128) NOT NULL default '',
`http` varchar(255) NOT NULL default 'http://',
`memo` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;

create table vpopmail (
pw_id int(5) unsigned NOT NULL auto_increment,
pw_name varchar(32) NOT NULL default '',
pw_domain varchar(64) NOT NULL default '',
pw_passwd varchar(40) NOT NULL default '',
pw_uid int(11) default NULL,
pw_gid int(11) default NULL,
pw_gecos varchar(64) default NULL,
pw_dir varchar(160) default NULL,
pw_shell varchar(20) default NULL,
pw_clear_passwd varchar(16) default NULL,
createtime timestamp(14) NOT NULL,
PRIMARY KEY (pw_id),
KEY pw_name (pw_name,pw_domain) )
TYPE=MyISAM PACK_KEYS=1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




cd /downloads/qmailrocks
tar zxvf vpopmail-5.4.9.tar.gz
cd vpopmail-5.4.9
./configure \
--disable-roaming-users \
--enable-logging=p \
--disable-ip-alias-domains \
--disable-passwd \
--enable-clear-passwd \
--disable-domain-quotas \
--enable-auth-module=mysql \
--enable-many-domains \
--enable-auth-logging \
--enable-sql-logging \
--enable-valias \
--disable-mysql-limits
make
make install-strip


chown vpopmail:vchkpw ~vpopmail/etc

echo "localhost|0|vpopmailuser|password|vpopmail" > ~vpopmail/etc/vpopmail.mysql

chown vpopmail:vchkpw ~vpopmail/etc/vpopmail.mysql

chmod 640 ~vpopmail/etc/vpopmail.mysql

/home/vpopmail/bin/vadddomain 你的域名
之后回提示输入域管理员的密码
/home/vpopmail/bin/vadduser 邮件用户@你的域名
之后回提示输入邮件用户的密码




/usr/ports/mail/vpopmail
################################################Part 6 - Vqadmin#############################################################
Part 6 - Vqadmin
cd /downloads/qmailrocks
tar zxvf vqadmin-2.3.6.tar.gz
cd vqadmin-2.3.6
./configure \
--enable-cgibindir=/usr/local/www/cgi-bin \
--enable-htmldir=/usr/local/www/html

make
make install-strip


Now you will need to add the following to your server's Apache configuration file (usually called httpd.conf)


ee /usr/local/etc/apache/httpd.conf
ADD end

<Directory "/usr/local/www/cgi-bin/vqadmin">
deny from all
Options ExecCGI
AllowOverride AuthConfig
Order deny,allow
</Directory>

cd /usr/local/www/cgi-bin/vqadmin
ee .htaccess
AuthType Basic
AuthUserFile /usr/local/etc/apache/conf/vqadmin.passwd
AuthName vQadmin
require valid-user
satisfy any


mkdir /usr/local/etc/apache/conf

chown www .htaccess
chmod 644 .htaccess
htpasswd -bc /usr/local/etc/apache/conf/vqadmin.passwd admin password
chmod 644 /usr/local/etc/apache/conf/vqadmin.passwd
apachectl stop
apachectl start
http://192.168.0.205/cgi-bin/vqadmin/vqadmin.cgi


/usr/ports/mail/vqadmin
###################################################Part 7 - Maildrop########################################################
Part 7 - Maildrop
cd /downloads/qmailrocks
tar zxvf maildrop-1.6.3.tar.gz
cd maildrop-1.6.3
./configure \
--prefix=/usr/local \
--exec-prefix=/usr/local \
--enable-maildrop-uid=root \
--enable-maildrop-gid=vchkpw \
--enable-maildirquota
make
make install-strip
make install-man

/usr/ports/mail/maildrop
#######################################################Part 8 - Qmailadmin###################################################
Part 8 - Qmailadmin
cd /downloads/qmailrocks
tar zxvf qmailadmin-1.2.3.tar.gz
cd qmailadmin-1.2.3
./configure \
--enable-cgibindir=/usr/local/www/cgi-bin \
--enable-htmldir=/usr/local/www/html/directory \
--enable-autoresponder-path=/usr/local/bin/qmail-autoresponder

make
make install-strip

/usr/ports/mail/qmailadmin
##################################################Part 9 - Finalizing Qmail##################################################
Part 9 - Finalizing Qmail
/downloads/qmailrocks/scripts/finalize/freebsd/finalize_freebsd.script

ee /var/qmail/supervise/qmail-pop3d/run
Find "mail.example.com" and change it to your server's hostname. For example: mail.mydomain.com.

ee /var/qmail/supervise/qmail-smtpd/run
Find "mail.example.com" and change it to your server's hostname. For example: mail.mydomain.com

qmailctl stop
echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp

qmailctl cdb

echo b.s.d@163.com > /var/qmail/alias/.qmail-root
where "some_address" is the system user or email address you want these addresses aliased to.

echo b.s.d@163.com > /var/qmail/alias/.qmail-postmaster
where "some_address" is the system user or email address you want these addresses aliased to.

echo b.s.d@163.com > /var/qmail/alias/.qmail-mailer-daemon
where "some_address" is the system user or email address you want these addresses aliased to.

ln -s /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-anonymous
chmod 644 /var/qmail/alias/.qmail*


##############################################Part 10 - Uninstalling Sendmail################################################
Part 10 - Uninstalling Sendmail
killall sendmail
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
mv /usr/lib/sendmail /usr/lib/sendmail.old(this may not apply if there is no sendmail link or binary in this location)
chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old

Now we will need to instruct FreeBSD not to attempt to start Sendmail upon startup. This is done by make the following

modification to the /etc/rc.conf file:

Change sendmail_enable="YES" to sendmail_enable="NONE"
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
#ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail



##################################################Part 11 - Starting up qmail################################################


Part 11 - Starting up qmail
/downloads/qmailrocks/scripts/util/qmr_inst_check
qmailctl stop
qmailctl start
telnet localhost 110

you should see something like this:

Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
+OK <16658.1054485137@yourserver.com>
user postmaster@mydomain.com (enter your username here. remember to use the full e-mail address)
+OK
pass your_password
+OK
quit
+OK
Connection closed by foreign host.

This is the sign of a successfull POP connection to the server!

Now try sending mail to that same user from another location. Telnet to 110 again and run the "list" command and you should

see the message that your send...
telnet localhost 110

Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
+OK <16658.1054485137@yourserver.comt>
user postmaster@mydomain.com (again, remember to log in with the full email address of the user)
+OK
pass your_password
+OK
list
+OK
1 323 (there's your message!)
.
quit
+OK
Connection closed by foreign host.

#############################################Part 12 - Installing Courier IMAP & IMAP SSL####################################
Part 12 - Installing Courier IMAP & IMAP SSL
cd /downloads/qmailrocks/
/usr/bin/bunzip2 courier-imap-3.0.8.tar.bz2 (Note: some systems may use bunzip2 instead of bunzip)
#bunzip courier-imap-3.0.8.tar.bz2
tar xvf courier-imap-3.0.8.tar
cd courier-imap-3.0.8
./configure \
--prefix=/usr/local \
--exec-prefix=/usr/local \
--without-authdaemon \
--with-authvchkpw \
--without-authldap \
--disable-root-check \
--with-ssl
make
make install-strip
cd /usr/local/etc
cp imapd.dist imapd
cp imapd-ssl.dist imapd-ssl
/usr/local/sbin/mkimapdcert
ee imapd-ssl
#make sure IMAPDSSLSTART=YES

cp /usr/local/libexec/imapd.rc /usr/local/etc/rc.d/imap.sh
cp /usr/local/libexec/imapd-ssl.rc /usr/local/etc/rc.d/imaps.sh
/usr/local/etc/rc.d/imap.sh start
/usr/local/etc/rc.d/imaps.sh start


telnet localhost 143

Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE STARTTLS]

Courier-IMAP ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for distribution information.
a login postmaster@mydomain.com my_password
a OK LOGIN Ok. (successful login!)
a logout (logs you out)
* BYE Courier-IMAP server shutting down
a OK LOGOUT completed
Connection closed by foreign host.

<!--cd /downloads/qmailrocks
tar zxvf courierpassd-1.1.0-RC1.tar.gz
cd courierpassd-1.1.0-RC1
./configure --with-couriersrc=/downloads/qmailrocks/courier-imap-3.0.8
make
make install-->



#########################################Part 14 - Clam Antivirus & Spamassassin#############################################
Part 14 - Clam Antivirus & Spamassassin

安装Clamav

cd /usr/ports/security/clamav
make
make install
make clean
注:选中CURL
reboot
测试
/usr/local/bin/clamscan -r -i /usr/local/www/data
----------- SCAN SUMMARY -----------
Known viruses: 32358
Scanned directories: 47
Scanned files: 866
Infected files: 0
Data scanned: 10.32 MB
I/O buffer size: 131072 bytes
Time: 41.750 sec (0 m 41 s)

升级病毒库
/usr/local/bin/freshclam -l /var/log/clamav/clam-update.log

ClamAV update process started at Fri May 6 00:12:24 2005
WARNING: Your ClamAV installation is OUTDATED - please update immediately!
WARNING: Local version: 0.83 Recommended version: 0.84
Downloading main.cvd [*]
main.cvd updated (version: 31, sigs: 33079, f-level: 4, builder: tkojm)
Downloading daily.cvd [*]
daily.cvd updated (version: 871, sigs: 1178, f-level: 4, builder: ccordes)
Database updated (34257 signatures) from database.clamav.net (IP: 61.8.0.16)
Clamd successfully notified about the update.
原文地址:https://www.cnblogs.com/wenus/p/198859.html