Try this newer howto. The one below is too old.
-c
Note
Gentoo has made Courier-imap version 4 stable, and has moved authentication back to /etc/courier. This is just after I've gone through and hacked all the Make and config files in the vhcs source to point to /etc/courier-imap so as to create the gentoo vhcs tarball. So if you want to try this, please follow the source part of this howto and skip my tarball atm - else you won't have any authentication working and all hell will break loose! Alternatively you could use my tarball and tell portage you want to use Courier-imap v 3.
This is a work in progress - I was trying to get it working on my system and thought I'd document it as I went in case I got it working
Init script for Gentoo
I created a little init.d script, which you can use. Please see this thread here.
64bit daemon fix
If you are using 64bit like me (Opteron) the vhcs2_daemon will segfault. You need to re-compile it 64bit, see my howto here.
Guide
This guide is derived from Petzch's work in the VHCS Forums. Thank you!
If you see anything in square brackets through out this guide (ie [ipaddress]), then it is something you should be modifying for your network.
This guide assumes you extract the tarball to /root. If you have extracted it elsewhere, just replace /root/vhcs-2.4 with your location
This guide should give you the follow setup:
Apache2 for web
Postfix for MTA
Courier IMAP / POP3
MySQL for database
Bind for DNS
ProFTPd for FTP server
Sync your portage tree
First you may like to get a copy of the latest portage tree. If so, then
Code: Select all
emerge --syncNow we need to ensure we have the correct USE flags. These are related to VHCS2 and based on my dual Opteron server, but feel free to change them based on your profile and other requirements.
Code: Select all
USE="-* -X adns apache2 authdaemond berkdb bzlib crypt curl gd imap innodb maildir -mbox memlimit mime mmx mmx2 mysql php python sasl session sockets softquota sse sse2 ssl threads vhosts xml xml2 zlib"I also have the following custom USE flags under /etc/portage/package.use
Code: Select all
dev-libs/cyrus-sasl pam
sys-devel/libperl ithreads
dev-lang/perl ithreads
dev-php/php jpeg png tiff truetype
dev-php/mod_php jpeg png tiff truetype
net-dns/bind bind-mysql
net-firewall/iptables extensions
mail-mta/postfix -postgres ssl sasl
media-libs/gd jpeg png truetype
net-ftp/proftpd shaperCode: Select all
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/../../../../i686-pc-linux-gnu/bin/ld: unrecognized option '-Wl'
!!! ERROR: net-libs/courier-authlib-0.55.20050320 failed.Packages
Now let's get started with the packages.
Remove SSMTP (unless you have mailwrapper and need it)
Code: Select all
emerge -C ssmtpCode: Select all
emerge -av postfix apache Authen-DigestMD5 BerkeleyDB bind Class-DBI-mysql expect courier-imap Crypt-Blowfish crypt-cbc cyrus-sasl Date-Calc DateManip DBD-mysql dev-perl/libnet gawk gzip IO-stringy iptables libmcrypt libperl MailTools MD5 MIME-Base64 MIME-tools mod_php mysql Net-DNS Net-Netmask perl php procmail proftpd SNMP_Session tar TermReadKey TimeDate fcronCode: Select all
for x in apache2 courier-imapd courier-pop3d courier-authlib mysql named postfix proftpd saslauthd fcron ; do rc-update add $x default ; doneCarefully check and update config files
Code: Select all
etc-updateInstall MySQL database
Code: Select all
/usr/bin/mysql_install_db ; /etc/init.d/mysql startCode: Select all
mysqladmin password [password]Code: Select all
cp /etc/proftpd/proftpd.conf.distrib /etc/proftpd/proftpd.confCode: Select all
nano -w /etc/conf.d/apache2Code: Select all
APACHE2_OPTS="-D SSL -D PHP4"Code: Select all
nano -w /etc/apache2/conf/apache2.confCode: Select all
ServerName [set your fqdn]Configure VHCS
Now we need to start configuring VHCS2.
The configuration files that come with the tarball need to be changed to reflect our Gentoo base.
So I have already changed them all for you, and re-packaged it into a convenient tarball
Download it here.
Code: Select all
sudo su - ; wget http://gensys.net.au/files/vhcs2/vhcs-2.4-gentoo-2005041801.tar.bz2Code: Select all
tar -xvjpf vhcs-2.4-gentoo-2005041801.tar.bz2Edit the main config
If you are using my tarball, I have already gone through each and every file and replaced apache with apache2, courier with courier-imap etc, and pointed everything to the proper locations. I have also Gentoofied the vhcs2.conf file, however you will still need to edit it to suit your network.
Change anything that has a square bracket, ie [hostname].
Code: Select all
cd /root/vhcs-gentoo-2.4/configs ; nano -w vhcs2.confCode: Select all
cd /root/vhcs-2.4/configs ; rm vhcs2.conf ; wget http://gensys.net.au/files/vhcs2/vhcs2.conf ; nano -w vhcs2.confFor those doing it manually, most of the config is correct. Just make the following changes:
Code: Select all
DEFAULT_ADMIN_ADDRES = [enter your email address here]
SERVER_HOSTNAME = [enter your server name here]
FTPD_CONF_FILE = /etc/proftpd/proftpd.conf
DATABASE_NAME = vhcs2
DATABASE_PASSWORD = [enter your password here]
ROOT_DIR = /var/www/localhost/htdocs/vhcs2
BIND_DB_DIR = /var/bind/pri
SECONDARY_DNS = [if you have one, add it here]
APACHE_WWW_DIR = /var/www/localhost/htdocs/virtual
APACHE_CONF_FILE = /etc/apache2/vhcs2.conf
GUI_ROOT_DIR = /var/www/localhost/htdocs/vhcs2/gui
PEAR_DIR = /usr/lib/php
APACHE_USER = apache
APACHE_GROUP =apache
MTA_LOCAL_MAIL_DIR = /var/spool/mail
MTA_VIRTUAL_MAIL_DIR = /var/spool/mail/virtual
MTA_LOCAL_ALIAS_HASH = /etc/mail/aliases
MTA_MAILBOX_MIN_UID = 1001
MTA_MAILBOX_UID = 1001
MTA_MAILBOX_GID = 12
MTA_SASLDB_LOCAL_DOMAIN = [enter your domain here]
MTA_SASLDB_FILE = /etc/sasl2/sasldb2
COURIER_CONF_DIR = /etc/courier-imap
BACKUP_ROOT_DIR = /var/www/localhost/htdocs/vhcs2/engine/backup
CMD_NAMED = /etc/init.d/named
CMD_HTTPD = /usr/sbin/apache2
CMD_AUTHD = /etc/init.d/courier-authlib
CMD_IMAP = /etc/init.d/courier-imapd
CMD_POP = /etc/init.d/courier-pop3d
QUOTA_ROOT_DIR = /var/www/localhost/htdocs/vhcs2/engine/quota
TRAFF_ROOT_DIR = /var/www/localhost/htdocs/vhcs2/engine/traffic
TOOLS_ROOT_DIR = /var/www/localhost/htdocs/vhcs2/engine/tools
FTP_USERNAME_SEPARATOR = -
FTP_HOMEDIR = /var/www/localhost/htdocs/virtual
Edit Postfix main.cf
I found the default postfix config a little restrictive (like not letting you email other domains outside your network), so I changed it. Either way you will need to edit the main.cf file so that it is compatible with your network.
If you used my tarball, main.cf will soon be changed to grab variables from the vhcs2.conf so you won't have to edit anything, but for now change anything in square brackets, else you can edit it manually.
Code: Select all
nano -w /root/vhcs-gentoo-2.4/configs/postfix/main.cfRebuild the daemon
You need to re-build the daemon so that it is Gentoo init compatible. See howto here.
If you are running 64bit OS, then use this howto here.
Let's continue.
Perl Modules
Now that you have the configs done there are a few more perl modules you need.
Code: Select all
USE="-X" emerge -av lynx ftp gnupg ncftp unzip zipCode: Select all
g-cpan.pl MIME::Entity MIME::Parser MIME::Base64 Crypt::CBC Crypt::Blowfish Term::ReadPasswordEdit Courier DB location
The next thing you need to do is edit makeuserdb
Code: Select all
nano -w /usr/sbin/makeuserdbCode: Select all
$dbfile="/etc/courier-imap/authlib/userdb";
$datfile="/etc/courier-imap/authlib/userdb.dat";
$lockfile="/etc/courier-imap/authlib/userdb.lock";
$shadowfile="/etc/courier-imap/authlib/userdbshadow.dat";
$tmpdir="/etc/courier-imap/authlib";Now we should now be ready to finalise the setup!
Backup
Let's back it all up
Code: Select all
mkdir ~/vhcs2.backup ; cp -R /root/vhcs-gentoo-2.4/* ~/vhcs2.backup/Now we run the installer which creates the files under /tmp/vhcs2
Code: Select all
cd /root/vhcs-gentoo-2.4 ; make install ; cd /tmp/vhcs2Code: Select all
cp -R /tmp/vhcs2/* /If you are using the source tarball (not my gentoo one) then you'll need to create some symlinks.
If you are using the gentoo tarball you can skip this step.
Web
Code: Select all
mv /var/www/vhcs2 /var/www/localhost/htdocs/ ; ln -sf /var/www/localhost/htdocs/vhcs2 /var/www/vhcs2 ; mv /var/www/virtual /var/www/localhost/htdocs/ ; ln -sf /var/www/localhost/htdocs/virtual /var/www/virtual
Code: Select all
mv /var/mail /var/spool/mail ; ln -sf /var/spool/mail /var/mail ; ln -sf /etc/mail/aliases /etc/aliases ; ln -sf /etc/init.d/courier-imapd /etc/init.d/courier-imap ; ln -sf /etc/init.d/courier-pop3d /etc/init.d/courier-pop ; ln -sf /etc/init.d/courier-pop3d /etc/init.d/courier-popd ; mv /etc/courier/* /etc/courier-imap ; rmdir /etc/courier ; cp /etc/vhcs2/courier/authmodulelist /etc/courier-imap/ ; ln -sf /etc/courier-imap /etc/courier ; mv /usr/lib/courier/courier-authlib /usr/lib/courier-imap ; rmdir /usr/lib/courier ; ln -sf /usr/lib/courier-imap /usr/lib/courier ; ln -sf /etc/courier-imap /etc/courier-imap/authlib ; mkdir /var/run/courierNow we need to run the setup program
Code: Select all
cd /var/www/localhost/htdocs/vhcs2/engine/setup/ ; ./vhcs2-setupFix Bind
We need to tell Bind to listen on its external address, not local 127.0.0.1.
Code: Select all
nano -w /etc/bind/named.confCode: Select all
listen-on { 127.0.0.1; };Code: Select all
CPU="2"Finally we need to tell <=Apache 2.0.52 about our vhcs2.conf, so let's add it
Code: Select all
echo "Include /etc/apache2/vhcs2.conf" >> /etc/apache2/conf/commonapache.confCode: Select all
echo "Include /etc/apache2/vhcs2.conf" >> /etc/apache2/httpd.confCode: Select all
echo "=dev-php/mod_php-4.3.10-r1" >> /etc/portage/package.keywords ; emerge -av mod_phpIf you did not use the gentoo tarball, then you'll need to grab the init script I created, start it and add to default runlevel
Code: Select all
cd /etc/init.d/ ; wget http://gensys.net.au/files/vhcs2/vhcs2 ; chmod 765 vhcs2 ; /etc/init.d/vhcs2 start ; rc-update add vhcs2 defaultCode: Select all
for x in apache2 courier-imapd courier-pop3d courier-authlib mysql named postfix proftpd saslauthd fcron vhcs2 ; do /etc/init.d/$x start ; done ; rc-update add vhcs2 defaultAssuming there were no errors, try and browse to your new setup at
http://ipaddress/vhcs2/gui/index.php
Good Luck!





