(原創)Install Qmail On FreeBSD 6.1

Install Qmail On FreeBSD 6.1

install cvsup
pkg_add -r cvsup-without-gui
rehash

update ports
cvsup -g -L 2 -h cvsup.tw.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

install perl
vi /etc/make.conf
ENABLE_SUIDPERL=true
cd /usr/ports/lang/perl5.8
make deinstall
make -DENABLE_SUIDPERL"TRUE" install clean
chmod 755 ./files/use.perl
./files/use.perl port
rehash

install mysql
cd /usr/ports/databases/mysql41-server
make clean && make && make install

install apache + php + mysql(/usr/ports/www/mod_php4 + /usr/ports/databases/php4-mysql)
cd /usr/ports/www/apache20
make clean && make && make install
cd /usr/ports/lang/php4-extensions
make clean && make && make install
add [X]GD

vi /usr/local/etc/apache2/httpd.conf
AddType application/x-httpd-php .php .php3


install named
cd /usr/ports/dns/bind9
make clean && make && make install
vi /var/named/etc/namedb/named.conf
//      listen-on       { 127.0.0.1; };


update openssh
cd /usr/ports/security/openssh-portable
make clean && make && make install
vi /usr/local/etc/ssh/sshd_config
Port 61093
Protocol 2
AllowUsers jason

vi /etc/rc.conf
#sshd_enable="YES"
#usbd_enable="YES"

syslogd_enable="YES"
syslogd_flags="-ss"
sendmail_enable="NONE"
apache2_enable="YES"
mysql_enable="YES"
named_enable="YES"
openssh_enable="YES"

vi /etc/resolv.conf
change to nameserver 127.0.0.1

reboot


install ucspi-tcp
cd /usr/ports/sysutils/ucspi-tcp
make clean && make && make install

install daemontools
cd /usr/ports/sysutils/daemontools
make clean && make && make install
cd work/admin/daemontools-0.76/
package/install
mv /command /command.bak
cp -rp /usr/ports/sysutils/daemontools/work/admin/daemontools/command /command


install qmail-spamcontrol
cd /usr/ports/mail/qmail-spamcontrol
make clean && make && make install

./work/qmail-1.03/config-fast mail.jason-tang.com

install wget
cd /usr/ports/ftp/wget
make clean && make && make install
rehash

download qmail.tar.gz
cd /home/jason
wget http://www.jason-tang.com/qmail.tar.gz
tar -zxvf qmail.tar.gz

chmod 755 /home/jason/qmail/finalize.script

cd /home/jason/qmail

./finalize.script

mysql

CREATE DATABASE vpopmail;

grant select on vpopmail.* to vpopmailread@localhost identified by 'read-password';

grant all on vpopmail.* to vpopmail@localhost identified by 'vpopmail-password';

quit

install vpopmail
cd /usr/ports/mail/vpopmail
make clean && make WITH_MYSQL=yes WITH_SINGLE_DOMAIN=no && make install

vi /usr/local/vpopmail/etc/vpopmail.mysql
localhost|0|vpopmailread|read-password|vpopmail
localhost|0|vpopmail|vpopmail-password|vpopmail

vi /usr/local/vpopmail/etc/vlimits.default
maxpopaccounts          5
maxforwards             -1
maxautoresponders       -1
maxmailinglists         X

# quota for entire domain, in megabytes
# example shows a domain with a 100MB quota and a limit of 10,000 messages
#quota                  100
quota                   150
#maxmsgcount            10000

# default quota for newly created users (in bytes)
# example shows a user with a 20MB quota and a limit of 1000 messages
default_quota           31457280
#default_maxmsgcount    1000

 

vi /etc/crontab
40      *       *       *       *       root    /usr/local/vpopmail/bin/clearopensmtp 2>&1 > /dev/null
*/10    *       *       *       *       root    /var/qmail/users/vpopmail-users-alias2recipients

/usr/local/vpopmail/bin/vadddomain test.com


install autorespond
cd /usr/ports/mail/autorespond
make clean && make && make install

install ezmlm-idx
cd /usr/ports/mail/ezmlm-idx
make clean && make && make install

install qmailadmin
cd /usr/ports/mail/qmailadmin

vi Makefile

change
CGIBINDIR?=     www/cgi-bin.default
to
CGIBINDIR?=     www/cgi-bin

change
WEBDATADIR?=    www/data.default
to
WEBDATADIR?=    www/data

make clean && make WITHOUT_IPAUTH=yes && make install


install courier-imap
cd /usr/ports/mail/courier-imap
make clean && make && make install
add [X]AUTH_VCHKPW

cp -rp /usr/local/etc/courier-imap/imapd.cnf.dist /usr/local/etc/courier-imap/imapd.cnf

/usr/local/sbin/mkimapdcert

vi /usr/local/etc/courier-imap/imapd.cnf
change Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它 to  Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它

vi /usr/local/etc/courier-imap/imapd
change IMAPDSTART=NO to IMAPDSTART=YES

vi /usr/local/etc/courier-imap/imapd-ssl
change IMAPDSSLSTART=NO to IMAPDSSLSTART=YES

vi /etc/rc.conf
courier_authdaemond_enable="YES"
courier_imap_imapd_enable="YES"
courier_imap_imapd_ssl_enable="YES"

 

install sqwebmail
cd /usr/ports/mail/sqwebmail
make clean && make && make install
add [X]AUTH_VCHKPW

vi /etc/rc.conf
sqwebmaild_enable="YES"


install squirrelmail
cd /usr/ports/mail/squirrelmail
make clean && make && make install

vi /usr/local/etc/php.ini
file_uploads = On
session.auto_start = 1

chown -R www:www /usr/local/www/squirrelmail
/usr/local/www/squirrelmail/config/conf.pl
10->1->zh_TW->S

vi /usr/local/etc/apache2/httpd.conf
change
DirectoryIndex index.html index.html.var
to
DirectoryIndex index.html index.html.var index.htm index.php

Alias /webmail "/usr/local/www/squirrelmail"


install stunnel
cd /usr/ports/security/stunnel
make clean && make && make install

setting pop3dssl
cp -rp /usr/local/etc/courier-imap/pop3d.cnf.dist /usr/local/etc/courier-imap/pop3d.cnf
/usr/local/sbin/mkpop3dcert
cp -rp /usr/local/share/courier-imap/pop3d.pem /var/qmail/supervise/qmail-pop3dssl/pop3dssl.pem

reboot

test:
http://IP/cgi-bin/qmailadmin/qmailadmin
http://IP/cgi-bin/sqwebmail/sqwebmail
http://IP/webmail

 


install antivirus and spamd

install maildrop
cd /usr/ports/mail/maildrop
make clean && make && make install

install clamav
cd /usr/ports/security/clamav
make clean && make && make install
pw groupadd qscand -g 98
pw useradd qscand -g qscand -d /var/spool/qmailscan -s /nonexistent -u 98

vi /usr/local/etc/clamd.conf
change
LocalSocket /var/run/clamav/clamd
to
#LocalSocket /var/run/clamav/clamd

change
#TCPSocket 3310
to
TCPSocket 3310

change
User clamav
to
User qscand

vi /usr/local/etc/freshclam.conf
change
DatabaseOwner clamav
to
DatabaseOwner qscand

chown -R qscand:qscand /var/run/clamav
chown -R qscand:qscand /var/log/clamav
chown -R qscand:qscand /var/db/clamav

vi /etc/rc.conf
clamav_clamd_enable="YES"
clamav_freshclam_enable="YES"


install SpamAssassin
cd /usr/ports/mail/p5-Mail-SpamAssassin
make clean && make && make install
clean [ ]AS_ROOT

vi /usr/local/etc/mail/spamassassin/local.cf

# SpamAssassin config file for version 2.5x
# generated by http://www.yrex.com/spam/spamconfig.php (version 1.01)

# How many hits before a message is considered spam.
required_hits           5.0

# Whether to change the subject of suspected spam
rewrite_subject         1

# Text to prepend to subject if rewrite_subject is used
subject_tag             *****SPAM*****

# Encapsulate spam in an attachment
report_safe             1

# Use terse version of the spam report
use_terse_report        0

# Enable the Bayes system
use_bayes               1

# Enable Bayes auto-learning
auto_learn              1

# Enable or disable network checks
skip_rbl_checks         0
use_razor2              1
use_dcc                 1
use_pyzor               1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
# - chinese english
ok_languages            zh en

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales              en zh


vi /etc/rc.conf
spamd_enable="YES"

spamassassin -t < ./work/Mail-SpamAssassin-3.1*/sample-spam.txt
spamassassin -t < ./work/Mail-SpamAssassin-3.1*/sample-nonspam.txt

reboot

install qmail-scanner
cd /home/jason/qmail
tar zxvf qmail-scanner-1.25.tgz
cd qmail-scanner-1.25
./configure --admin postmaster --domain test.com --scanners clamdscan,fast_spamassassin --notify recips --qmail-queue-binary /var/qmail/bin/qmail-queue --install

vi /var/qmail/bin/qmail-scanner-queue.pl
change
my $spamc_subject='';
to
my $spamc_subject='+++++Trash+++++';

/var/qmail/bin/qmail-scanner-queue.pl -z

vi /service/qmail-smtpd/run

QMAILQUEUE=/var/qmail/bin/qmail-scanner-queue.pl
export QMAILQUEUE

qmailctl restart


./contrib/test_installation.sh -doit