ISP in a Box Redhat 2005
<pre><p>
# DNS
This is the file that tells all computers on the internet where your domain’s website/email/ftpsite/etc is. Below is my zone file. Do not enter the #’s.
vi /var/named/ciruspc.com.zone
#############################################################################
$TTL 84600
ciruspc.com. IN SOA ciruspc.com. root.ciruspc.com. (
2002090501 ; year, todays date and serial number
8H ; refresh, seconds
2H ; retry, seconds
1W ; expire, seconds
1D ) ; minimum, seconds
IN NS ns1.ciruspc.com.
IN NS ns2.ciruspc.com.
IN MX 10 mail.ciruspc.com.
ciruspc.com. A 208.39.218.226
ns1 A 208.39.218.226
ns2 A 208.39.218.227
www A 208.39.218.226
ftp A 208.39.218.226
mail A 208.39.218.226
ciruspc A 208.39.218.226
#############################################################################
You can just copy and paste that exact config above into your zone file.
Just substitue out all the red entrys with your domain and IPs.
The reverse file is mapping IPs to hostnames.
This is important to the email program we are going to install.
vi /var/named/208.39.218
Notice how the name of the file is the first part
of my IP address. You will need to do the same.
#####################################################
@ IN SOA ciruspc.com. root.ciruspc.com. (
2002090501 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
NS ns1.ciruspc.com.
NS ns2.ciruspc.com.
226 PTR ciruspc.com.
227 PTR ciruspc.com.
#####################################################
The 226 and 227 are the last digits of my IP address. See how nicely that works?
We need to add your new zone/reverse files to the DNS process.
vi /etc/named.conf
####################################
zone “ciruspc.com” IN {
type master;
file “ciruspc.com.zone”;
};
zone “218.39.208.in-addr.arpa” IN {
type master;
file “208.39.218”;
};
####################################
Switch out your filenames with mine, and same with your IP.
Notice in the reverse zone config, you enter the first part of your IP address…backwards.
If you want to add support for additional websites add the following to the named.conf file
in the following format, just add below the zone “218.x.x.x entry just under the };
.
####################################
zone “domain.com” IN {
type slave;
file “domain.com.zone”;
masters {
208.39.218.226;
};
};
####################################
The hosts file identifies the server itself.
vi /etc/hosts
####################################
127.0.0.1 ciruspc.ciruspc.com ciruspc localhost.localdomain localhost
208.39.218.226 ciruspc.com
208.39.218.227 ciruspc.com
####################################
Switch out your names/domains with mine.
Some of this may already be in there, and that is ok.
resolve.conf tells the server where to go to do DNS lookups.
vi /etc/resolv.conf
####################################
domain ciruspc.com
search ciruspc.com
nameserver 208.39.218.226
####################################
That is all that needs to be in there, you can take everything else out.
——————————————————————————–
-Start DNS.
service named start
——————————————————————————–
# Configure DNS to startup with the server.
chkconfig –level 2345 named on
# END DNS
# MYSQL
groupadd mysql
useradd -g mysql mysql
cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-standard-4.1.10-pc-linux-gnu-i686.tar.gz/from/http://mirror.services.wisc.edu/mysql/
cd /usr/local
tar xzf /usr/local/src/mysql-standard-4.1.10-pc-linux-gnu-i686.tar.gz
ln -s mysql-standard-4.1.10-pc-linux-gnu-i686 mysql
cd mysql
scripts/mysql_install_db
cd ..
mkdir mysql/var
chown -R root.mysql mysql-standard-4.1.10-pc-linux-gnu-i686
chmod -R 640 mysql
chmod -R u+X,g+X mysql
chmod -R ug+x mysql/bin
chmod -R g+w mysql/data
chmod -R g+w mysql/var
cp /usr/local/mysql/support-files/my-medium.cnf /usr/local/mysql/data/my.cnf
chgrp mysql /usr/local/mysql/data/my.cnf
cd /usr/local/mysql
bin/safe_mysqld –user=mysql &
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
chmod 744 /etc/rc.d/init.d/mysql
chkconfig –add mysql
ntsysv
/usr/local/mysql/bin/mysqladmin -u root password ‘*PASSWORD*’
# END MYSQL
# APACHE
cd /usr/local/src
wget http://linux.cs.lewisu.edu/apache/httpd/apache_1.3.33.tar.gz
chown -R root.root apache_1.3.33.tar.gz
tar xzf apache_1.3.33.tar.gz
groupadd www
useradd -g www www
cd /usr/local/src
cd apache_1.3.33
./configure –prefix=/usr/local/apache –enable-module=so –server-uid=www –server-gid=www
make
make install
# END APACHE
# PHP with zlib, freetype, libjpeg-6b and libpng
cd /usr/local/src
wget http://us3.php.net/distributions/php-4.3.10.tar.gz
tar xzf php-4.3.10.tar.gz
chown -R root.root php-4.3.10.tar.gz
# Install Zlib
wget http://www.zlib.net/zlib-1.2.2.tar.gz
tar -xzf zlib-1.2.2.tar.gz
cd zlib-1.2.2
make
make test
make install
path /usr/local/lib
# Install libpng
wget http://download.sourceforge.net/libpng/libpng-1.2.5.tar.gz
tar -xzf libpng-1.2.5.tar.gz
cd libpng-1.2.5
cp scripts/makefile.linux Makefile
make
make test
make install
path /usr/local/lib /usr/local/include/lib
# Install Freetype
wget http://easynews.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.7.tar.gz
tar -xzf freetype-2.1.7.tar.gz
cd freetype-2.1.7
make
make clean
make install
path /usr/local/lib
# Install libjpeg
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -xzf jpegsrc.v6b.tar.gz
mkdir /usr/local/man/man1
cd jpeg-6b
./configure
make
make test
make install
edit the /etc/ld.so.conf. Add the following line at the bottom:
/usr/local/lib
Save the file , and reload the libs:
/sbin/ldconfig
path /usr/local/bin
# Install GD
wget http://www.boutell.com/gd/http/gd-2.0.23.tar.gz
tar -xzf gd-2.0.23.tar.gz
cd gd-2.0.23
./configure
make
make install
# Now compile and install php
cd /usr/local/src/php-4.3.6…. and run
./configure –with-mysql-dir=/usr/local/mysql –with-apxs=/usr/local/apache/bin/apxs –with-gd –enable-gd-native-ttf –with-zlib –with-freetype-dir=/usr/include/ –with-jpeg-dir=/usr/local/lib –with-png-dir=/usr/local/lib –with-pear –with-curl
–with-xml –enable-ftp –enable-magic-quotes
make
make install
cp php.ini-dist /usr/local/lib/php.ini
vi /usr/local/lib/php.ini
max_execution_time=60
memory_limit=10M
post_max_size=8M
upload_max_filesize=8M
file_uploads=On
log_errors=On
error_log=/usr/local/apache/logs/php_error_log
Registered Globals=ON
chown -R root.www /usr/local/lib/php
chmod -R g-w,o-rwx /usr/local/lib/php
# END PHP
# APACHE CONFIG
vi /usr/local/apache/conf/httpd.conf
User www
Group www
ServerAdmin postmaster@ciruspc.com
ServerName ciruspc.ciruspc.com
AddType application/x-httpd-php .php
DirectoryIndex portal.php index.php index.htm index.html
rm -Rf /usr/local/apache/htdocs/*
rm -f /usr/local/apache/index.html.*
rm -Rf /usr/local/apache/cgi-bin/*
# Setup permissions on the apache dirs
cd /usr/local
chown -R root.root apache
chmod 755 apache
chmod -R 600 apache/*
chmod -R u+X apache
cd apache
chmod -R u+x bin
chgrp -R www cgi-bin
chmod -R u+x,g+x cgi-bin
chgrp -R www icons
chmod -R g+rX icons
chgrp -R www logs
chmod g+wX logs
chgrp -R www htdocs
chmod -R g+rX htdocs
mkdir /etc/skel/internet
# will need to grant execute permissions to any scripts such as php
# for example
# chmod -R g+x htdocs/dircontainingscripts
#test
/usr/local/apache/bin/apachectl configtest
#start
/usr/local/apache/bin/apachectl start
vi /etc/rc.d/rc.local
/usr/local/apache/bin/apachectl start
#END APACHE CONFIG
# SAMBA
# Install Samba
cd /usr/local/src
wget http://us1.samba.org/samba/ftp/samba-2.2.8.tar.gz
tar xz samba-2.2.8.tar.gz
cd samba-2.2.8
./configure –help
make
make install
make installbin
make installman
vi /etc/smb.conf
# Samba config file
# Date: 2000/11/13 12:31:50
# Global parameters
[global]
workgroup = WORKGROUP-NAME
server string = samba file services at WORKGROUP-NAME
security = USER
#must be set to ‘no’ to use PAM
encrypt passwords = No
update e ncrypted = No
allow trusted domains = Yes
min password length = 6
null passwords = No
revalidate = No
[homes]
valid users = sample
writeable = Yes
[www]
path = /www
valid users = sample
force group = http
writeable = Yes
[public]
path = /samba/public
valid users = sample
writeable = Yes
guest ok = No
vi startsmb
#!/bin/sh
/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D
chmod +x startsmb
vi /etc/rc.local
startsmb start
# For security purposes do the following
edit /etc/samba/smb.conf and add the following under global settings
hosts allow = 127.0.0.1 208.39.218.224/29
hosts deny = 0.0.0.0/0
You can also add
interfaces = eth* lo
bind interfaces only = yes
that tells Samba to only listen for connections on interfaces
with a name starting with ‘eth’ such as eth0, eth1, plus on
the loopback interface called ‘lo’. The name you will need to
use depends on what OS you are using. In the above I used the
common name for ethernet adapters on Linux.
If you use the above and someone tries to make a SMB
connection to your host over a PPP interface called ‘ppp0’,
they will get a TCP connection refused reply. In that
case no Samba code is run at all as the operating system has
been told not to pass connections from that interface to any
process.
Documentation found here
http://www.sourcekeg.co.uk/samba/whatsnew/samba-2.2.8.html
# END SAMBA
# PROFTPD
cd /usr/local/src
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.10.tar.gz
tar xvfz proftpd-1.2.10.tar.gz
cd proftpd-1.2.10
./configure –sysconfdir=/etc/proftpd
make
make install
mv /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.bak
vi /etc/proftpd/proftpd.conf
#############################################
ServerName “FTP Server”
ServerType standalone
DefaultServer on
RequireValidShell off
DefaultRoot ~/internet
Port 21
Umask 022
MaxInstances 30
User nobody
Group nobody
<Directory /*>
AllowOverwrite on
</Directory>
#############################################
That is all that needs to be in there.
# End proftpd.conf
#Start up the ftp server
/usr/local/sbin/proftpd -c /etc/proftpd/proftpd.conf
# Add to startup
echo ‘/usr/local/sbin/proftpd -c /etc/proftpd/proftpd.conf’ >> /etc/rc.d/rc.local
# End Proftpd
# VSFTP if you don’t like PROFTPD
cd /usr/local/src
wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.0.1.tar.gz
tar -xzf vsftpd-2.0.1.tar.gz
cd vsftpd-2.0.1
make
make install
chkconfig vsftpd on
Edit the config file so that chroot_list is enabled and edit the file /etc/vsftpd.chroot_list
and just add the usernames to the blank text file, it’s empty by default.
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
#
———————————————-
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s
# capabilities.
#
# Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd’s)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages – messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using “root” for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command “SIZE /big/file” in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the “-R” option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as “ncftp” and “mirror” assume
# the presence of the “-R” option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
# QMAIL
su
umask 022
cd /usr/local/src
wget ftp://cr.yp.to/software/qmail-1.03.tar.gz
mkdir -p /package
wget ftp://cr.yp.to/daemontools/daemontools-0.76.tar.gz
mv daemontools-0.76.tar.gz /package
chmod 1755 /package
gunzip qmail-1.03.tar.gz
tar xpf qmail-1.03.tar
wget ftp://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
gunzip ucspi-tcp-0.88.tar.gz
tar xpf ucspi-tcp-0.88.tar
cd /package
gunzip daemontools-0.76.tar.gz
tar xpf daemontools-0.76.tar
cd /usr/local/src
mkdir /var/qmail
cd /usr/local/src/qmail-1.03
groupadd nofiles
useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
groupadd qmail
useradd qmailq -g qmail -d /var/qmail -s /nonexistent
useradd qmailr -g qmail -d /var/qmail -s /nonexistent
useradd qmails -g qmail -d /var/qmail -s /nonexistent
vi qmail-smtpd.c
change the code on the straynewline function on line 50 from 451 to 553
make setup check
./config
# END QMAIL INSTALL
# ucspi-tcp Setup
cd /usr/local/src/ucspi-tcp-0.88
make
make setup check
# END ucspi-tcp
# daemontools
cd /package/admin/daemontools-0.76
package/install
# END daemontools
# scripts
vi /var/qmail/rc
#!/bin/sh
# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default
exec env – PATH=”/var/qmail/bin:$PATH” \
qmail-start “`cat /var/qmail/control/defaultdelivery`”
chmod 755 /var/qmail/rc
mkdir /var/log/qmail
echo ./Mailbox >/var/qmail/control/defaultdelivery
#QMAILCTL SCRIPT
vi /var/qmail/bin/qmailctl
#!/bin/sh
# For Red Hat chkconfig
# chkconfig: – 80 30
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
case “$1” in
start)
echo “Starting qmail”
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo “qmail-send supervise not running”
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo “qmail-smtpd supervise not running”
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo “Stopping qmail…”
echo ” qmail-smtpd”
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo ” qmail-send”
svc -d /service/qmail-send /service/qmail-send/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
;;
doqueue|alrm|flush)
echo “Flushing timeout table and sending ALRM signal to qmail-send.”
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo “Sending HUP signal to qmail-send.”
svc -h /service/qmail-send
;;
pause)
echo “Pausing qmail-send”
svc -p /service/qmail-send
echo “Pausing qmail-smtpd”
svc -p /service/qmail-smtpd
;;
cont)
echo “Continuing qmail-send”
svc -c /service/qmail-send
echo “Continuing qmail-smtpd”
svc -c /service/qmail-smtpd
;;
restart)
echo “Restarting qmail:”
echo “* Stopping qmail-smtpd.”
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo “* Sending qmail-send SIGTERM and restarting.”
svc -t /service/qmail-send /service/qmail-send/log
echo “* Restarting qmail-smtpd.”
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo “Reloaded /etc/tcp.smtp.”
;;
help)
cat <<HELP
stop — stops mail service (smtp connections refused, nothing goes out)
start — starts mail service (smtp connection accepted, mail can go out)
pause — temporarily stops mail service (connections accepted, nothing leaves)
cont — continues paused mail service
stat — displays status of mail service
cdb — rebuild the tcpserver cdb file for smtp
restart — stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue — schedules queued messages for immediate delivery
reload — sends qmail-send HUP, rereading locals and virtualdomains
queue — shows status of queue
alrm — same as doqueue
flush — same as doqueue
hup — same as reload
HELP
;;
*)
echo “Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}”
exit 1
;;
esac
exit 0
# END qmailctl script
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
#supervise script
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
vi /var/qmail/supervise/qmail-send/run
#!/bin/sh
exec /var/qmail/rc
vi /var/qmail/supervise/qmail-send/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
vi /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z “$QMAILDUID” -o -z “$NOFILESGID” -o -z “$MAXSMTPD” -o -z “$LOCAL” ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo “No /var/qmail/control/rcpthosts!”
echo “Refusing to start SMTP listener because it’ll create an open relay”
exit 1
fi
exec /usr/local/bin/softlimit -m 4000000 \
/usr/local/bin/tcpserver -v -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD” \
-u “$QMAILDUID” -g “$NOFILESGID” 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
# end script
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
vi /var/qmail/supervise/qmail-smtpd/log/run
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd
Make the run files executable:
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
Then set up the log directories:
mkdir -p /var/log/qmail/smtpd
chown qmaill /var/log/qmail /var/log/qmail/smtpd
Finally, link the supervise directories into /service:
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
The /service directory is created when daemontools is installed.
Allow the local host to inject mail via SMTP:
echo ‘127.:allow,RELAYCLIENT=””‘ >>/etc/tcp.smtp
qmailctl cdb
If your existing MTA is Sendmail, you should be able to stop it by running the init.d script
with the “stop” argument. E.g., one of these should work:
/etc/init.d/sendmail stop
/sbin/init.d/sendmail stop
/etc/rc.d/init.d/sendmail stop
If you can’t find an init.d/sendmail script, you can locate sendmail’s PID using “ps -ef|grep
sendmail” or “ps waux|grep sendmail” and stop it using:
kill PID-of-sendmail
If your MTA isn’t Sendmail, check its documentation for the correct shutdown procedure.
You should also consider removing the old MTA completely from the system. At least disable the
init.d script so it doesn’t try to start up again when the system is rebooted.
For Red Hat Linux, removing Sendmail can be accomplished by:
rpm -e –nodeps sendmail
rpm -e –nodeps postfix
mv /usr/lib/sendmail /usr/lib/sendmail.old # ignore errors
mv /usr/sbin/sendmail /usr/sbin/sendmail.old # ignore errors
chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old # ignore errors
ln -s /var/qmail/bin/sendmail /usr/lib
ln -s /var/qmail/bin/sendmail /usr/sbin
# use postmaster@hostname.ciruspc.com as sender in bounce messages
echo ‘postmaster’ > /var/qmail/control/bouncefrom
# Tell qmail to send double-bounces to doublebounce@ciruspc.com
echo ‘doublebounce’ > /var/qmail/control/doublebounceto
echo ‘ciruspc.com’ > /var/qmail/control/doublebouncehost
#
# Now, if you want to keep these doublebounces, then once you have finished setting
# up your server, you will be able to use qmailadmin to setup a mailbox or alias
# to receive them.
# Alternatively if you would prefer to silently discard any doublebounces,
# then you should now run the following command to configure the discarding
echo ‘#’ > ~alias/.qmail-doublebounce
# set maximum message size to be 10Mb
echo ‘20000000’ > /var/qmail/control/databytes
# queue mail for up to 4 days
echo ‘345600’ > /var/qmail/control/queuelifetime
# setup the default domain for use where an address does not have a domain specified
echo ‘ciruspc.com’ > /var/qmail/control/defaultdomain
# now setup aliases here for any mails sent to someone@thishost.ciruspc.com
echo ‘postmaster@ciruspc.com’ > ~alias/.qmail-root
echo ‘postmaster@ciruspc.com’ > ~alias/.qmail-postmaster
echo ‘postmaster@ciruspc.com’ > ~alias/.qmail-mailer-daemon
chmod 644 ~alias/.qmail-*
# POP3D Setup
SEE http://www.dredsdomain.com/linux/pop3.html
#END Complete Qmail Installation
# VPOPMAIL
userdel postfix
groupadd -g 89 vchkpw
useradd -g vchkpw -u 89 vpopmail
cd /usr/local/src
wget http://www.inter7.com/devel/vpopmail-5.3.14.tar.gz
tar xzf vpopmail-5.3.14.tar.gz
chown -R root.root vpopmail-5.3.14.tar.gz
cd vpopmail-5.3.14
chown root.root vmysql.h
chmod 600 vmysql.h
vi vmysql.h
#define MYSQL_UPDATE_USER=”vpopmailuser”
#define MYSQL_UPDATE_PASSWD=”vpoppasswd”
#define MYSQL_READ_USER=”vpopmailuser”
#define MYSQL_READ_PASSWD=”vpoppasswd”
/usr/local/mysql/bin/mysql –password=”*PASSWORD*”
CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.*
TO vpopmailuser@localhost IDENTIFIED BY ‘vpoppasswd’;
quit
./configure \
–enable-roaming-users=y \
–enable-default-domain=ciruspc.com \
–enable-admin-email=postmaster@ciruspc.com \
–enable-logging=p \
–enable-defaultquota=20000000S \
–enable-ip-alias-domains=n \
–enable-passwd=n \
–enable-clear-passwd=y \
–enable-mysql=y \
–enable-incdir=/usr/local/mysql/include \
–enable-libdir=/usr/local/mysql/lib \
–enable-many-domains=y \
–enable-auth-logging=y \
–enable-mysql-logging=y \
–enable-valias=y
make
make install-strip
vi quotawarn.msg
From: Postmaster
Reply-To: postmaster@ciruspc.com
To: User:;
Subject: Mail quota warning
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Your mailbox on the server is now more than 90% full.
So that you can continue to receive mail,
you need to remove some messages from your mailbox.
cp quotawarn.msg /home/vpopmail/domains/.quotawarn.msg
echo “Message rejected. Not enough storage space in user’s mailbox to
accept message.” > /home/vpopmail/domains/.over-quota.msg
# END VPOPMAIL
# Autoresponse
cd /usr/local/src
wget http://www.inter7.com/devel/autorespond-2.0.3.tar.gz
tar xzf autorespond-2.0.3.tar.gz
chown -R root.root autorespond-2.0.3.tar.gz
cd autorespond-2.0.3
make
make install
# END AUTORESPONSE
# EZMLM/EZMLM-IDX
cd /usr/local/src
wget http://cr.yp.to/software/ezmlm-0.53.tar.gz
tar xzf ezmlm-0.53.tar.gz
chown -R root.root ezmlm-0.53.tar.gz
wget ftp://ftp.pipeline.com.au/PipeInt/Sources/Linux/WebMail/ezmlm-idx-0.40.tar.gz
tar xzf ezmlm-idx-0.40.tar.gz
chown -R root.root ezmlm-idx-0.40.tar.gz
cp -R ezmlm-idx-0.40/* ezmlm-0.53/
# (you need to press y quite a few times to allow the patch files to overwrite the original files)
cd ezmlm-0.53
patch < idx.patch
make
make man
make setup
# END EZML
# Qmailadmin
cd /usr/local/src
wget http://www.inter7.com/devel/qmailadmin-1.0.10.tar.gz
tar xzf qmailadmin-1.0.10.tar.gz
chown -R root.root qmailadmin-1.0.10
cd qmailadmin-1.0.10
wget ftp://ftp.pipeline.com.au/pipeint/sources/linux/WebMail/qmailadmin-1.0.10-configure-maxaliasesperpage.patch.txt
patch < qmailadmin-1.0.10-configure-maxaliasesperpage.patch.txt
vi html/en
Change record 112 to Username
./configure \
–enable-htmldir=/usr/local/apache/htdocs \
–enable-cgibindir=/usr/local/apache/cgi-bin \
–enable-maxusersperpage=12 \
–enable-maxaliasesperpage=12 \
–enable-no-cache=y \
–enable-modify-quota=n \
–enable-help=n
make
make install-strip
#create virtual links to cgi bin in all webfolders
see if it works http://www.ciruspc.com/cgi-bin/qmailadmin
# END Qmailadmin
# VQregister
cd /usr/local/src
wget http://www.inter7.com/vqregister/vqregister-2.5.tar.gz
tar -zxvpf vqregister-2.5.tar.gz
chown -R root.root vqregister-2.5.tar.gz
cd vqregister-2.5
vi vqregister.conf
AdminEmail postmaster@ciruspc.com
AllowDomain dredsdomain.com
AllowDomain ciruspc.com
AllowDomain durhamfamilyhistory.com
Redirect http://www.ciruspc.com/webmail
BadHosts badhosts
vi Makefile
VDIR = /home/vpopmail
CC = gcc
BIN = vqregister
# Change to path of your MySQL include directory: (My RedHat 8.0 is
located at: /usr/local/mysql/lib)
DEFS = -I$(VDIR)/include -I/usr/local/mysql/include
LINKDEFS
# Change to path of your MySQL lib directory: (My RedHat 8 is located
at: /usr/local/mysql/lib/mysql)
LIBS = -L$(VDIR)/lib -lvpopmail -lcrypt -L/usr/local/mysql/lib -lmysqlclient -lz
OBJS = main.o cgi.o template.o global.o misc.o config.o register.o
password.o \vpopmail.o db.o field.o badhosts.o
INSTALL_DIR = /usr/local/apache/cgi-bin/vqregister
INSTALL_BIN = vqregister.cgi
INSTALL_UID = vpopmail
INSTALL_GID = vchkpw
# End of changes to Makefile
Edit the webpages in the /html directory to suite your site.
9) Compile the entire thing by typing:
make
make install
10) Go check out your work!
http://www.yourdomain.com/cgi-bin/vqregister/vqregister.cgi
# END VQregister
# VQAdmin
cd /usr/local/src
wget http://www.inter7.com/vqadmin/vqadmin-2.3.2.tar.gz
tar xzf vqadmin-2.3.2.tar.gz
cd vqadmin-2.3.2
vi vqadmin.acl
edit your vqadmin.acl file, which is your access list
definitions.
./configure
make
make install-strip
vi /usr/local/apache/conf/httpd.conf
<Directory “/usr/local/apache/cgi-bin/vqadmin”>
deny from all
Options ExecCGI
AllowOverride AuthConfig
Order deny,allow
</Directory>
vi /usr/local/apache/cgi-bin/vqadmin/.htaccess
AuthType Basic
AuthUserFile /usr/local/apache/conf/vqadmin.passwd
AuthName vqadmin
require valid-user
satisfy any
chown nobody /usr/local/apache/cgi-bin/vqadmin/.htaccess
/usr/local/apache/bin/htpasswd -bc /usr/local/apache/conf/vqadmin.passwd
vqadmin *PASSWORD*
#stop the apache service
/usr/local/apache/bin/apachectl stop
#start the apache service
/usr/local/apache/bin/apachectl start
# END VQADMIN
# Courier-IMAP
cd /usr/local/src
wget http://flow.dl.sourceforge.net/sourceforge/courier/courier-imap-1.7.0.tar.bz2
bunzip2 courier-imap-1.7.0.tar.bz2
tar xf courier-imap-1.7.0.tar
chown -R root.root courier-imap-1.7.0
cd courier-imap-1.7.0
vi maildir/maildirpurgetmp.c
Change st_ctime to st_mtime
./configure \
–prefix=/usr/local/courier-imap \
–disable-root-check \
–without-authpam \
–without-authldap \
–without-authpwd \
–without-authmysql \
–without-authpgsql \
–without-authshadow \
–without-authuserdb \
–without-authcustom \
–without-authcram \
–without-authdaemon \
–with-authvchkpw
make
make install
make install-configure
vi /usr/local/courier-imap/etc/imapd
MAXDAEMONS=40
MAXPERIP=100
TCPDOPTS=”-nodnslookup -noidentlookup -user=vpopmail -group=vchkpw”
AUTHMODULES=”authvchkpw”
IMAP_EMPTYTRASH=Trash:7,Sent:30
IMAPDSTART=YES
cp /usr/local/src/courier-imap-1.7.0/courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
chmod 744 /etc/rc.d/init.d/courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc0.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc1.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc2.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc3.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc4.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc5.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc.d/rc6.d/K30courier-imap
# END IMAP
# Squirrelmail
cd /usr/local/src
wget http://twtelecom.dl.sourceforge.net/sourceforge/squirrelmail/squirrelmail-1.2.11.tar.gz
cd /usr/local/apache/htdocs
tar xzf /usr/local/src/squirrelmail-1.2.11.tar.gz
chown -R root.www squirrelmail-1.2.11
chmod -R 750 squirrelmail-1.2.11
ln -s squirrelmail-1.2.11 webmail
#put webmail link in all web site folders
mkdir /var/squirrelmail
mkdir /var/squirrelmail/data
mkdir /var/squirrelmail/attach
cd webmail
cp data/default_pref /var/squirrelmail/data
chown -R root.www /var/squirrelmail
chmod -R 0770 /var/squirrelmail/data
chmod -R 0730 /var/squirrelmail/attach
cd config
perl conf.pl
ORGANIZATION PREFERENCES
1. Organization name : YourCompany WebMail
2. Organization Logo : ../../images/yourcompanylogo-100.gif
3. Org. Logo Height/Width : 100/100
4. Organization title : YourCompany WebMail (v$version)
SERVER SETTINGS
1. Domain : ciruspc.com
6. SMTP server : 127.0.0.1
10 Server : courier
FOLDER OPTIONS
9. List Special Folders First : false
15. Default Unseen Type : 2
GENERAL OPTIONS
2. Data directory : /var/squirrelmail/data
3. Attachment directory : /var/squirrelmail/attach
6. Usernames in lower case : true
8. Hide squirrelmail attributions : true
12. Allow server-side sorting : true
ADDRESS BOOKS
2. Use Javascript Address Book Search : True
DATABASE
1. DSN for address book : mysql://root:*PASSWORD*@localhost/squirrelmail
3. DSN for preferences : mysql://root:*PASSWORD*@localhost/squirrelmail
DONT PRESS D TO CHOOSE PRE-DEFINED SETTINGS FOR COURIER
Save and quit the config program
cd /usr/local/mysql/bin
./mysql –password=”*PASSWORD*”
CREATE DATABASE squirrelmail;
GRANT select,insert,update,delete ON squirrelmail.*
TO root@localhost IDENTIFIED BY ‘*PASSWORD*’;
USE squirrelmail;
CREATE TABLE address (
owner varchar(128) DEFAULT ” NOT NULL,
nickname varchar(16) DEFAULT ” NOT NULL,
firstname varchar(128) DEFAULT ” NOT NULL,
lastname varchar(128) DEFAULT ” NOT NULL,
email varchar(128) DEFAULT ” NOT NULL,
label varchar(255),
PRIMARY KEY (owner,nickname),
KEY firstname (firstname,lastname)
);
CREATE TABLE userprefs (
user varchar(128) DEFAULT ” NOT NULL,
prefkey varchar(64) DEFAULT ” NOT NULL,
prefval blob DEFAULT ” NOT NULL,
PRIMARY KEY (user,prefkey)
);
quit
cd /usr/local/apache/htdocs/webmail
vi functions/db_prefs.php
var $default = Array(‘chosen_theme’ => ‘../themes/default_theme.php’,
‘show_html_default’ => ‘1’,
‘language’ => ‘en_US’,
‘use_javascript_addr_book’ => ‘1’,
‘left_size’ => ‘140’,
‘left_refresh’ => ‘3600’,
‘show_username’ => ‘1’,
‘show_username_pos’ => ‘top’,
‘order1’ => ‘1’,
‘order2’ => ‘2’,
‘order3’ => ‘3’,
‘order4’ => ‘5’,
‘order5’ => ‘4’,
‘order6’ => ‘6’);
crontab -e
# delete any files that are more than 2 days old from the squirrelmail
attachment dir
0 0 * * * find /var/squirrelmail/attach/* -atime +2 -exec /bin/rm \;
We also added some code to squirrelmail/src/login.php to add a notes page to the login screen.
We inserted this chunk just before the line that says “do_hook(‘login_bottom’);
echo “<BR><CENTER>”.
“<TABLE BORDER=1 WIDTH=75%><TR><TD ALIGN=CENTER><FONT FACE=Arial SIZE=2>”.
“<P><B><FONT SIZE=3>IMPORTANT NOTES REGARDING THE WEBMAIL SYSTEM</FONT></B></P>”.
“<P><B>AUTOMATIC MAIL DELETION</B></P>”.
“<P>The mail server will automatically delete mail from the<BR> “.
“following folders after the specified number of days :<br>”.
“Trash Folder – 7 days, Sent Folder – 30 days,<BR> All other folders 90 days.</P>”.
“<P><B>POP3 MAIL CLIENTS</B></P>”.
“<P>If you check your mail using a POP3 mail client (such as Outlook Express),<BR> “.
“it will download and delete the mail from your WebMail inbox.</P>”.
“<P>If you want to be able to download the mail using POP3 and also<BR> “.
“leave it on the server so you can see it with WebMail, you will need<BR> “.
“to adjust the settings in your POP3 client to tell it not to delete<BR> “.
“mail after downloading.</P>”.
“<P>For example, to configure this in Outlook Express you would go to<br> “.
“<i>Tools -> Accounts -> Mail -> Properties -> Advanced</i><BR> “.
“and then tick the box<BR><i>’Leave a copy of message on server'</i><P>”.
“</FONT>”.
“</TD><TR></TABLE></CENTER>”;
Now, another cosmetic change… : modify the squirrelmail/src/login.php and change the
wording of “Name:” to “Email address:”.
Next, we setup a default document in the web servers root, to redirect our customers
through to the SquirrelMail login page. That way when people want to access the
WebMail tool they can point their browser to “http://webmail.yourdomain.com” and
they will get automatically redirected through to the SquirrelMail directory
vi /usr/local/apache/htdocs/index.html
<HTML>
<HEAD>
<TITLE>Redirect to WebMail login screen…</TITLE>
<META HTTP-EQUIV=”refresh” CONTENT=”1; url=http://webmail.yourdomain.com/squirrelmail/”>
</HEAD>
<BODY>
Redirecting to the WebMail login screen…<br>
<a href=squirrelmail/>Click here if you are not automatically redirected</a>
</BODY>
</HTML>
# END SQMAIL
# Maintenance
To add a domain :
/home/vpopmail/bin/vadddomain ciruspc.com yourpassword
# this creates the domain and makes a mailbox postmaster@ciruspc.com
To add a mailbox:
/home/vpopmail/bin/vadduser someone@ciruspc.com apassword
To remove a mailbox
/home/vpopmail/bin/vdeldomain someone@ciruspc.com
To remove a domain :
/home/vpopmail/bin/vdeldomain ciruspc.com
To change a users password
/home/vpopmail/bin/vpasswd someone@ciruspc.com newpassword
To lookup info about a user
/home/vpopmail/bin/vuserinfo someone@ciruspc.com
This gives you info such as name, crypted password, cleartext password,
dir, quota, usage%, last auth.
It has a number of flags to let you see the individual fields, or you can
see them all if you dont use any flags.
It also creates the maildirsize file in the users dir
To add a web domain
useradd _______ -g www -d /home/______ -p xxxx
chmod 755 ~_____ -R
# END Maintenance
# Additional Tools
# PhpMyAdmin
cd /usr/local/src
wget http://aleron.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.6.0-pl1.tar.gz
tar -xzf phpMyAdmin-2.6.0-pl1.tar.gz
./configure
make
make install
# PhpSysInfo
wget http://easynews.dl.sourceforge.net/sourceforge/phpsysinfo/phpsysinfo-2.3.tar.gz
tar -xzf phpsysinfo-2.3.tar.gz
move to desired web directory
# webmin
cd /usr/local/src
wget http://prdownloads.sourceforge.net/webadmin/webmin-1.160.tar.gz
tar -xzf webmin-1.160.tar.gz
cd webmin-1.160
./setup.sh
# Disable X-Windows
edit the file /etc/inittab.
Look for the line
id:5:initdefault:
and change the 5 to a 3. The comments in the file tell you what the various
levels do, but basically you only need to know about 1, 3 and 5. 0 and 6 are
special and should never be called directly anyway.
# END Additional Tools
</p></pre>
./configure –enable-htmldir=/usr/local/apache/htdocs –enable-cgibindir=/usr/local/apache/cgi-bin –enable-maxuserperpage=12 –enable-maxaliasesperpage=12 –enable-no-cache=y –enable-modify-quota –enable-help –enable-autoresponder-bin=usr/local/bin -enable-vpopuser=vpopmail –enable-ezmlmdir=/usr/local/bin/ezmlm/ –enable-ezmlmidx=y –disable-ipauth –enable-modify-spam –enable-domain-autofill