Whatever it may be, you should go with what works for you and your organization. In the grand scheme of things, you have to be convinced about the value you are getting for the money you are paying...

Home » Archives » 17. September 2009

Installation and Configuration of AWStats on Tomcat Web Server

September 17, 2009

Here are the steps in installing and configuring AWstats in Tomcat Web Server

STEPS:

1.    Download awstats.war from the internet
2.    Since Tomcat disabled by default the CGI executions, we need to enable it by renaming the file servlets-cgi.renametojar to servlets-cgi.jar
Example:
[Tomcat_installation_path] = /usr/local/apache-tomcat-5.5.20

#cd /usr/local/apache-tomcat-5.5.20/server/lib
#mv servlets-cgi.renametojar servlets-cgi.jar

3.    Install AWStats
Since it is already a .war file, no need to install it by hand, you just need to copy this file to [Tomcat_installation_path]/webapps folder

#cp awstats.war [Tomcat_installation_path]/webapps

It would create an [Tomcat_installation_path]/webapps/awstats folder after copied.

4.    Configure AWStats
Let say our domain is www.mydomain.com

#cd /etc
#mkdir awstats
#cd [Tomcat_installation_path]/webapps/awstats/WEB-INF/cgi-bin
#cp awstats.model.conf /etc/awstats/awstats.www.mydomain.com.conf

5.    Edit awstats.conf
#vi /etc/awstats/awstats.www.mydomain.com.conf

Look for the line in the configuration and change the values as shown below:
Example:

LogFile=”LogFile=”/var/log/httpd/www.mydomain.com-combined_log”
LogType=W
LogFormat=1
LogSeparator=” ”
SiteDomain=”www.mydomain.com”
DNSLookup=1
DirData=”.”
DirCgi=”/cgi-bin”

6.    Update Site Statistics
Here you have two choices:
1.    Set AllowToUpdateStatsFromBrowser=1 in awstats.www.mydomain.com.conf file, see above. This will allow updating from the web browser with: http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com&update=1.
2.    Using SSH, go to [Tomca_install]/webapps/awstats/WEB-INF/cgi-bin folder and run perl awstats.pl -config=www.mydomain.com -update.
Example:
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.mydomain.com -update
Create/Update database for config “/etc/awstats/awstats.www.mydomain.com.conf” by AWStats version 6.6 (build 1.887)From data in log file “/var/log/httpd/www.freelinuxtutorials-combined_log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 10471)
Jumped lines in file: 10471
Found 10471 already parsed records.
Parsed lines in file: 160
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 160 new qualified records.

7.View Site Statistics

Access it using your favorite browser. Type
http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com

8.Create crontab script in order to update the  log file analysis
#crontab –e

add this line
example:

0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.mydomain.com -update > /root/awstatsjob/awstats.log

9. You can follow “Installation of GeoIP Information for AWStats” documentation to have a country information on your web/mail/ftp statistics.

 Original reference can be found on this links: http://www.freelinuxtutorials.com/tutorials/installation-and-configuration-of-awstats-on-apache-web-server/

Posted by linux at 6:21 am | permalink | Add comment

Setting up FTP server via VSFTPD

* Setting up ftp via vsftpd in linux

The VSFTPD (Very Secure FTP Server Deamon) is one of the most commonly used FTP servers under Linux and comes with most Linux distributions.

This article will help you install and configure vsftpd in Linux. (sample OS used is a Red-hat based distribution)

GOALS:

* to create a secure ftp server
* to create an ftp user chrooted or jailed in a certain directory (sample use is an apache directory wherein you can limit users or your developers to just upload to a restricted folder)

procedures and actual simulation as follows:

A. INSTALLATION

#yum install vsftpd

Loaded plugins: refresh-packagekit
updates                                                  | 3.4 kB     00:00
updates/primary_db                                       | 4.0 MB     00:10
fedora                                                   | 2.8 kB     00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
–> Running transaction check
—> Package vsftpd.i386 0:2.0.7-2.fc10 set to be updated
updates/filelists_db                                                                                   | 7.3 MB     00:18
fedora/filelists_db                                                                                    |  11 MB     00:24
–> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================
Package                     Arch                      Version                             Repository                    Size
======================================================================================================
Installing:
vsftpd                      i386                      2.0.7-2.fc10                        updates                      145 k

Transaction Summary
======================================================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 145 k
Is this ok [y/N]:y

Downloading Packages:
vsftpd-2.0.7-2.fc10.i386.rpm                                                                              | 145 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : vsftpd                                                                                                    1/1
Installed:
vsftpd.i386 0:2.0.7-2.fc10
Complete!

B. Edit configuration file (self-explanatory)

# vi /etc/vsftpd/vsftpd.conf

Here’s the important line that you need to modify:

# Turn off anonymous users
anonymous_enable=NO

# Turn on local users
local_enable=YES

# Users should be able to write
write_enable=YES

# chroot everyone
chroot_local_user=YES

#create userlist
userlist_file=/etc/vsftpd/vsftpd.userlist

C.  Create ftp acct (example create ftp user darwin)

# useradd -d /home/Sites/ -s /sbin/nologin darwin
# passwd darwin

D.    Add it on the vsftpd service userlist

# vi /etc/vsftpd/vsftpd.userlist

Add the ftp name pmorris, This will be the output once included:

# cat /etc/vsftpd/vsftpd.userlist
darwin

E. Add an FTP group e.g. ftpusers

#groupadd ftpusers

Example directory where we will jail the ftp users: /home/Sites

F. Change the ownership of the directory. e.g. root: ftpusers

/home/Sites folder ownership is currently set to root:ftpusers with permission 775 (meaning all FTP users should be in the GROUP “ftpusers”, and it has a GROUP read-write-execute) permission
drwxrwxr-x 13 root      ftpusers   4096 Jan 28 15:23 Sites

G. Add the ftpuser in the ftpusers group

#vi /etc/group

This will be the output once included:
ftpusers:x:502:darwin

Alternatively: you can use the command

#usermod -G ftpusers darwin

Testing:
Using your favorite FTP client such as FileZilla FTP or via CLI , you can test the functionality by uploading, deleting or creating folders on it.

————————————————————————————————————————
[root@darwin ~]# ftp ip.of.the.server
Connected to ip.of.the.server (ip.of.the.server).
220 (vsFTPd 2.0.5)
Name (ip.of.the.server:root): darwin
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bin
200 Switching to Binary mode.
ftp> bye
221 Goodbye.

* this was tested in RPM-based distro such as CentOS,Fedora Core & RHEL

Posted by linux at 5:55 am | permalink | Add comment

qemu virtualization

There are lots of operating system virtualization, you have the option to use an open source or a proprietary software depending on your needs,familiarization and most significantly, budget. People have several reasons why they use virtualization, and the most common is for testing purposes wherein they can test different configurations from different OS. Another reason is to security and consolidation, where they can save money and electricity.

Some of the popular open source linux virtualization softwares are OpenVZ, Xen, KVM and VirtualBox. You can also try proprietary softwares such as VMWare and Citrix XenServer, a commercial implementation of Xen.

For this tutorial, I’ll be covering Qemu, another virtualization program and here are the steps:

Prerequisites and componets:

a. windows installation in ISO format  ex. WinXP ( you can create ISO format using 3rd party programs like magic ISO, power ISO etc.)

b.process emulator (QEMU)

c. any Linux distribution (I’ll be using CentOS 5 for this demonstration)

d. Linux/Unix administration skills

A. Installing qemu

# yum install qemu

# qemu-img create winxp.img 4G

C. install the windows

#qemu -hda winxp.img -cdrom win.iso -m 256 -boot d

B. Create windows image by creating a virtual drive ( sample demo is creation of 4 GB virtual drive named winxp.img)

this will tell qemu to use the virtual disk as the hard disk, which drive to use as the cdrom  and to allocate 256 memory for the virtual pc
Qemu will boot up and you will be in windows install (line the normal windows installation)

Tips: CTRL+ALT= when you need your mouse
ALT+CTRL+F = toggle fullscreen

After finished the windows installation, you can just close the Qemu Window

D. Testing the newly installed windows under Linux

#qemu -hda winxp.img -m 256 -boot c

NOTE: This procedure is being done in your Linux X environment e.g. GNOME , KDE etc.

CHALLENGE: How to emulate Windows in Linux OS when you only have ssh access to the remote server, no X or GUI?

SOLUTION: Create a windows image in your local test machine then upload the image file.
Tip: Since an image file will be 4GB in size, you can split the file into several pieces via your favorite archiver. I used Winrar for this one, then upload those files in queue ( Bandwidth matters)

* Since image is already uploaded on the server, the only thing to do is to emulate and redir port 3389 for RDP purposes.

sample:

# qemu -hda /home/test/winxp.img -m 2000 -boot c -redir tcp:3389::3389 -nographic

You can now access your windows via RDP… Start> Run..> mstsc

then input the server IP address

 Reference: http://www.freelinuxtutorials.com/tutorials/qemu-virtualization/

Posted by linux at 5:53 am | permalink | Add comment

Qmail Howto

QMAIL HOW TO

I.    Qmail Installation

A.    INSTALLATION

A.1. Software Pre-requisites
1. Linux Operating System
2.Apache Web Server
3.Perl –any version  of 5
4.GCC – the gcc compiler
5. wget – use for downloading installers
6. patch & patchutils -

Access to a domain name server (DNS) is highly recommended.

A.2  Download the source

Download the necessary installers for setting up the qmail, download the source code for qmail and any other add-ons.
•     qmail, http://www.qmail.org/netqmail-1.05.tar.gz
•    ucspi-tcp, ftp://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
•    daemontools, ftp://cr.yp.to/daemontools/daemontools-0.76.tar.gz
for e.g.
# wget  http://www.qmail.org/netqmail-1.05.tar.gz
You can put all of installers on a certain directory for e.g. /home/darwin
A.3. Build the source
A.3.1 Switch user as root and do these:
su
umask 022
mkdir -p /usr/local/src  (if not yet existing)
mv netqmail-1.05.tar.gz ucspi-tcp-0.88.tar.gz /usr/local/src
mkdir -p /package
mv daemontools-0.76.tar.gz /package
chmod 1755 /package

A.3.2 Unpack the packages

cd /usr/local/src
tar zxvf  netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh  # watch for errors here
cd ..
tar zxvf ucspi-tcp-0.88.tar.gz
cd /package
tar zxvf daemontools-0.76.tar.gz

A.3.3 Create directories

mkdir /var/qmail

A.3.4 Create users and groups

cd /usr/local/src/netqmail-1.05/netqmail-1.05

You can check the INSTALL.ids to setup qmail groups and users, to make it easy you just copy these commands

groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails

A.3.5 Do the build
cd /usr/local/src/netqmail-1.05/netqmail-1.05

make setup check

./config-fast the.full.hostname(for ex. ./config-fast phi.freelinuxtutorials.com)

A.4 Install ucspi-tcp

cd /usr/local/src/ucspi-tcp-0.88

patch < /usr/local/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch

make
make setup check

A.5 Install daemontools

cd /package/admin/daemontools-0.76

cd src
patch < /usr/local/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
cd ..
package/install

A.6 Start qmail

A.6.1 Use an editor to create /var/qmail/rc script

vi /var/qmail/rc and then use this script:

#!/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`”

A.6.2 Execute these commands:
chmod 755 /var/qmail/rc
mkdir /var/log/qmail

A.6.3 Create a default delivery mode for messages that aren’t delivered by a .qmail file. Type:

echo ./Maildir/ >/var/qmail/control/defaultdelivery

A.7 Create a startup/shutdown script like the following in /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 svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo “qmail-pop3d 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
echo “  qmail-pop3d”
svc -d /service/qmail-pop3d /service/qmail-pop3d/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
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/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
echo “Pausing qmail-pop3d”
svc -p /service/qmail-pop3d
;;
cont)
echo “Continuing qmail-send”
svc -c /service/qmail-send
echo “Continuing qmail-smtpd”
svc -c /service/qmail-smtpd
echo “Continuing qmail-pop3d”
svc -c /service/qmail-pop3d
;;
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
echo “* Restarting qmail-pop3d.”
svc -t /service/qmail-pop3d /service/qmail-pop3d/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.”
tcprules /etc/tcp.pop3.cdb /etc/tcp.pop3.tmp < /etc/tcp.pop3
chmod 644 /etc/tcp.pop3.cdb
echo “Reloaded /etc/tcp.pop3.”
;;
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

This script is available via http://www.lifewithqmail.org/qmailctl-script-dt70

A.7.1 Make the qmailctl script executable and link it to a directory in your path:

chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin

A.8 The supervise scripts

A.8.1 Now create the supervise directories for the qmail services:
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
A.8.2. Create the /var/qmail/supervise/qmail-send/run file:
#!/bin/sh
exec /var/qmail/rc
A.8.3 Create the /var/qmail/supervise/qmail-send/log/run file:
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
A.8.4 Create the /var/qmail/supervise/qmail-smtpd/run file:
#!/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 2000000 \
/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

A.8.5 Create the concurrencyincoming control file:
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
A.8.6 Create the /var/qmail/supervise/qmail-smtpd/log/run file:
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd
A.8.7 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.

A.8.8 SMTP Access Control
Allow the local host to inject mail via SMTP:
echo ‘127.:allow,RELAYCLIENT=””‘ >>/etc/tcp.smtp
qmailctl cdb

You can add here IP address that will allow to relay to outside domain. These entries ensure that your mail server is not an open relay.

A.9 Stop and disable the installed MTA

If you’re using an RPM-based Linux distribution like Red Hat, removing the MTA package might cause problems down the road. Utilities that update the system might try to reinstall Sendmail, or MUA packages might not install because they can’t tell an MTA is installed. You can use Mate Wierdl’s stub package called “fake_mta” that can be installed to prevent these problems. Simply install the RPM available from http://www.csi.hu/mw/fake_mta-1-1memphis.noarch.rpm.

A.9.1 Download the said rpm and install the package

rpm –ivh fake_mta-1-1memphis.noarch.rpm

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
kill PID¬of¬sendmail
rpm ¬e ¬¬nodeps sendmail

Lastly, replace any existing /usr/lib/sendmail with the qmail version:
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

A.10 Create System Aliases
There are three system aliases that should be created on all qmail installations:
Alias     Purpose
postmaster     RFC 2821 required, points to the mail adminstrator (you)
mailer-daemon     de facto standard recipient for some bounces
root     redirects mail from privileged account to the system administrator
To create these aliases, decide where you want each of them to go (a local user or a remote address) and create and populate the appropriate .qmail files. For example, say local user dave is both the system and mail administrator:
echo darwin > /var/qmail/alias/.qmail-root
echo darwin > /var/qmail/alias/.qmail-postmaster
ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon
chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster

A.11 Start qmail
If you stopped qmail above after creating the links in /service, you should restart it now:
qmailctl start
A.12 Test the Installation
qmail should now be running. First run qmailctl stat to verify that the services are up and running:
# qmailctl stat
/service/qmail-send: up (pid 30303) 187 seconds
/service/qmail-send/log: up (pid 30304) 187 seconds
/service/qmail-smtpd: up (pid 30305) 187 seconds
/service/qmail-smtpd/log: up (pid 30308) 187 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0

All four services should be “up” for more than a second. If they’re not, you’ve probably got a typo in the associated run script or you skipped one or more steps in creating the necessary files, directories, or links. Go back through the installation step-by-step and double check your work. You can also download and run the inst_check script, available from http://lifewithqmail.org/inst_check. For example:
# sh inst_check
! /var/log/qmail has wrong owner, should be qmaill
…try: chown qmaill /var/log/qmail
#
If inst_check finds problems, fix them and re-run it. When everything looks right, inst_check will report:
Congratulations, your LWQ installation looks good!

B. Configuration
You’ve got qmail installed, from the recommended source tarball method, one of the self-compiling packages, or a var-qmail package. This section contains information you will need to configure qmail to make it work the way you want it to.
B.1. Configuration Files
All of qmail’s system configuration files, with the exception of the .qmail files in ~alias, reside in /var/qmail/control. The qmail-control man page contains a table like the following:
Control     Default     Used by     Purpose
badmailfrom     none     qmail-smtpd     blacklisted From addresses
bouncefrom     MAILER-DAEMON     qmail-send     username of bounce sender
bouncehost     me     qmail-send     hostname of bounce sender
concurrencyincoming     none     /service/qmail-smtpd/run     max simultaneous incoming SMTP connections
concurrencylocal     10     qmail-send     max simultaneous local deliveries
concurrencyremote     20     qmail-send     max simultaneous remote deliveries
defaultdelivery     none     /var/qmail/rc     default .qmail file
defaultdomain     me     qmail-inject     default domain name
defaulthost     me     qmail-inject     default host name
databytes     0     qmail-smtpd     max number of bytes in message (0=no limit)
doublebouncehost     me     qmail-send     host name of double bounce sender
doublebounceto     postmaster     qmail-send     user to receive double bounces
envnoathost     me     qmail-send     default domain for addresses without “@”
helohost     me     qmail-remote     host name used in SMTP HELO command
idhost     me     qmail-inject     host name for Message-ID’s
localiphost     me     qmail-smtpd     name substituted for local IP address
locals     me     qmail-send     domains that we deliver locally
me     FQDN of system     various     default for many control files
morercpthosts     none     qmail-smtpd     secondary rcpthosts database
percenthack     none     qmail-send     domains that can use “%”-style relaying
plusdomain     me     qmail-inject     domain substituted for trailing “+”
qmqpservers     none     qmail-qmqpc     IP addresses of QMQP servers
queuelifetime     604800     qmail-send     seconds a message can remain in queue
rcpthosts     none     qmail-smtpd     domains that we accept mail for
smtpgreeting     me     qmail-smtpd     SMTP greeting message
smtproutes     none     qmail-remote     artificial SMTP routes
timeoutconnect     60     qmail-remote     how long, in seconds, to wait for SMTP connection
timeoutremote     1200     qmail-remote     how long, in seconds, to wait for remote server
timeoutsmtpd     1200     qmail-smtpd     how long, in seconds, to wait for SMTP client
virtualdomains     none     qmail-send     virtual domains and users

Sample PHI MAIL SERVER CONFIGURATION

badmailfrom:
FROM_USER@netmail.nl
@*.service.ohio-state.edu
@4cpp.net
@8hy.cn
@aidscare.com.hk
@bbqgirl.com

concurrencyincoming
20

defaultdelivery
./Maildir

defaultdomain
phmx1.freelinuxtutorials.com

helohost
phi.freelinuxtutorials.com

locals
phmx1.freelinuxtutorials.com

me
phmx1.freelinuxtutorials.com

plusdomain
freelinuxtutorials.com

queuelifetime
172800

rcpthosts
phmx1.freelinuxtutorials.com
freelinuxtutorials.com
hkpub.com
mail.freelinuxtutorials.com
mail.hkpub.com
phi.freelinuxtutorials.com

virtualdomains
phi.freelinuxtutorials.com:phi.freelinuxtutorials.com

II. INSTALLING VPOPMAIL

Vpopmail is one of the major components of this installation. Vpopmail allows us to do virtual domain mail hosting. It’s got a lot of built in tools and features that make it a dream to work with
B. 1 Download the installer of vpopmail on http://www.inter7.com/
C. Unpack/uncompress the tarball file
tar zxvf vpopmail-5.4.0.tar.gz
cd vpopmail-5.4.0
# ./configure
# make
# make install-strip

1.Now you are ready to add a virtual domain and users

#cd /home/vpopmail/bin
#./vadddomain phi.freelinuxtutorials.com password yourpostmasterpassword

2.To add a new pop users

You can install qmailadmin and administer your new pop mail
system via a web interface. Or you can use the command line
interface.

# cd /home-dir-of-vpopmail/bin
# ./vadduser newuser@test.com
or
# ./vadduser newuser@test.com <password-for-newuser>

3.Delete a pop user

# cd /home-dir-of-vpopmail/bin
# ./vdeluser newuser@test.com (for the test.com virtualdomain example)

4.Delete a virtual domain

# cd /home-dir-of-vpopmail/bin
# ./vdeldomain test.com

5.Changing a pop users password (new in 3.4.3)
# cd /home-dir-of-vpopmail/bin
# ./vpasswd user@domain.com
or
# ./vpasswd user@domain.com <password-for-user@domain.com>

III. INSTALLING QMAILADMIN
qmailAdmin is a free software package that provides a web interface for managing a qmail system with virtual domains. A version is available now for use with vpopmail. It provides admin for adding/deleting users, Aliases, Forwards, Mailing lists and Autoresponders.

Requirements:
Qmail
Vpopmail
Autorespond 2.0 (or greater)
Ezmlm or Ezmlm-idx

Installing Autoresponder
Download the installer on http://www.inter7.com
tar zxvf autorespond-2.0.2.tar.gz
cd autorespond-2.0.2
make && make install

Installing Ezmlm
EZmlm is a nice mailing list add-on to Qmail
EZmlm integrates seamlessly into Qmailadmin to provide a very user friendly mailing list management interface
Download the installer on http://www.inter7.com
tar zxvf ezmlm-0.53-idx-0.41.tar.gz
cd ezmlm-0.53-idx-0.41
make && make setup

Install qmailadmin
Download the installer on http://www.inter7.com
Type as root:
tar zxvf qmailadmin-1.2.0.tar.gz
cd qmailadmin-1.2.0
./configure –enable-modify-quota
# make
# make install-strip

That’s it! Now browse to http://www.yourdomain.com/cgi-bin/qmailadmin and you should see the login screen. Login with the postmaster account and password for the domain that you created

If you didn’t get any errors, Qmailadmin should be all set!

IV. INSTALLING SQWEBMAIL

Sqwebmail is a web based email client, similar to hotmail. It is extremely efficient and the html is configurable.  It is compatible with vpopmail

Note: SqWebMail DOES NOT support traditional Mailbox files, only Maildirs

Download the installer on http://www.inter7.com or directly on http://www.courier-mta.org/sqwebmail/
Unpack:
# tar xvf sqwebmail-4.0.4.20040524.tar
#./configure [options - see below]
#  make configure-check
# make
# make check
# make install-strip       # Do a make install if this doesn’t work
# make install-configure   # Install configuration files.
You can now access sqwebmail http://www.yourdomain.com/cgi-bin/sqwebmail

BACKING UP QMAIL SERVER
Backing up a qmail server is relatively easy. While different people may give you slightly different recommendations, you can ensure a safe backup of your qmail server if you backup the following 2 directories on a routine basis.
/home/vpopmail – backs up all your domain information, including mailboxes, passwords and the messages themselves.
/var/qmail – backs up all of your qmail settings. The /var/qmail/control directory is the most important directory in there to back up, but it won’t hurt to just back up the whole damn qmail directory.

For complete documentations, pls refer to:
Reference: http://www.lifewithqmail.org
http://www.qmailrocks.org
http://www.inter7.com/

Reference: http://www.freelinuxtutorials.com/tutorials/qmail-how-to/

Posted by linux at 5:48 am | permalink | Add comment

Linux working with FreeRadius and MySQL

Freeradius and MySQL

Software Requirements:

Any Linux distro, kernel 2.4xx-later(tested in CentOS,Fedora Core,RH)
MySQL Server 4.xx-5.xx
GCC compiler
vi editor

1.    Get the latest freeradius source code tarball from www.freeradius.org or get the rpm package using “yum”

2.    Unpack the tarball and install it.
#tar zxvf freeradius-xxx.tar.gz
#cd freeradius
#./configure
#make
#make install

3.    Start with a simple config using the standard text files, this will test if the Freeradius installed is working or not

a.    Edit /etc/raddb/clients.conf to enter the details of the NAS unit.You can enter “localhost” for testing purposes
b.    Edit /etc/raddb/users and create a sample user account

Sample:
“test”    Auth-Type := Local, User-Password == “hello”
Reply-Message = “Hello, %u”

c.    Edit /etc/raddb/radiusd.conf and change as needed

Run the radiusd service with the debug turned on to see what happens:

#radiusd –X

You can use radtest to test an account from the command line:

#radtest username password servername port secret

ex:
#radtest darwin mypass radius.owtel.com 1645 mysecret

And you should see something like this:

Sending Access-Request of id 226 to 127.0.0.1:1645
User-Name = darwin’
User-Password = ‘\304\2323\326B\017\376\322?K\332\350Z;}’
NAS-IP-Address = radius.owtel.com
NAS-Port = 1645

If you get an “Access Accept” response, that means Freeradius is running ok.

Setting up the Freeradius database in MySQL

1. First, if you will run the db on your localhost, MySQL server should be installed on your machine

#mysql –u root –p

mysql>CREATE DATABASE radius;
mysql>GRANT ALL PRIVILEGES ON radius.* to ‘root’@localhost’ IDENTIFIED BY ‘myrootpassword’;
mysql>FLUSH PRIVILEGES;

2. Create a schema for the database, use the SQL script file, it can be found in /src/modules/rlm_sql/drivers/rlm_sql_mysql/db_mysql.sql where you untar’d the FreeRadius

#mysql –u root –p rootpass radius < db_mysql.sql

where root and rootpass are your mysql root name and password respectively

Configuring FreeRadius to use MySQL

1.Edit /etc/raddb/sql.conf and enter the server, name and password details to connect your Mysql Server and Radius database:

# Connect info
server = “localhost”
login = “root”
password = “rootpass”

radius_db = “radius”

Query config for username, I used this:

sql_user_name = “%{User-Name}”

You will see several tables created. You just need to use one of those: radcheck. This table has the following structure:

2.    Edit /etc/raddb/radiusd.conf and add a line saying “sql” to the authorize {}section and add a line saying “sql” to the accounting{} section too between ‘unix’ and ‘radutmp’

radiusd.conf will look something like this:

authorise {
preprocess
chap
mschap
#counter
#attr_filter
#eap
suffix
sql
#files
#etc_smbpasswd
}

authenticate {
authtype PAP {
pap
}
authtype CHAP {
chap
}
authtype MS-CHAP{
mschap
}
#pam
#unix
#authtype LDAP {
#       ldap
#}
}

preacct {
preprocess
suffix
#files
}

accounting {
acct_unique
detail
#counter
unix
sql
radutmp
#sradutmp
}

session {
radutmp
}

The simplest way to populate users database is by inserting data on the radcheck table:

mysql> > INSERT INTO radcheck (UserName, Attribute, Value) VALUES (’darwin’, ‘Password’, ‘mypassword’);

Ref: - http://www.freelinuxtutorials.com/working-with-servers-or-daemon/linux-working-with-freeradius-and-mysql/

ANother Info:

Linux working with FreeRadius and MySQL

Freeradius and MySQL

Software Requirements:

Any Linux distro, kernel 2.4xx-later(tested in CentOS,Fedora Core,RH)
MySQL Server 4.xx-5.xx
GCC compiler
vi editor

1.    Get the latest freeradius source code tarball from www.freeradius.org or get the rpm package using “yum”

2.    Unpack the tarball and install it.
#tar zxvf freeradius-xxx.tar.gz
#cd freeradius
#./configure
#make
#make install

3.    Start with a simple config using the standard text files, this will test if the Freeradius installed is working or not

a.    Edit /etc/raddb/clients.conf to enter the details of the NAS unit.You can enter “localhost” for testing purposes
b.    Edit /etc/raddb/users and create a sample user account

Posted by linux at 5:40 am | permalink | Add comment

Testing your SIP Protocol via SIPp

Want to test your Asterisk PBX system if it can sustain load and large traffic? Then you can use this tool.
Sipp is a performance testing tool for the SIP protocol. Its main features are basic SIPStone scenarios, TCP/UDP transport, customizable (xml based) scenarios, dynamic adjustement of call-rate and a comprehensive set of real-time statistics.
Sipp can be used to test real SIP equipments and very useful to emulate thousands of user agents calling your SIP system.

Installation:

1.    Download the stable version of Sipp ( sipp-xxx.tar.gz)
2.    Uncompress the tarball file
#tar zxvf sipp-xxx.tar.gz
#cd sipp
#make

Using Sipp:

SIPp allows to generate one or many SIP calls to one remote system
Syntax: ./sipp -sn uac ip
#./sipp –sn uac 127.0.0.1
#./sipp -sn uac 192.168.17.10

Traffic Control:

SIPp generates SIP traffic according to the scenario specified. You can control the number of calls (scenario) that are started per second. This can be done either:
•    Interactively, by pressing keys on the keyboard
o    ’+’ key to increase call rate by 1
o    ’-’ key to decrease call rate by 1
o    ’*’ key to increase call rate by 10
o    ’/’ key to increase call rate by 10
•    At starting time, by specifying parameters on the command line:
o    ”-r” to specify the call rate in number of calls per seconds
o    ”-rp” to specify the “rate period” in milliseconds for the call rate (default is 1000ms/1sec). This allows you to have n calls every m milliseconds (by using -r n -rp m).
Note
Example: run SIPp at 7 calls every 2 seconds (3.5 calls per second)
./sipp -sn uac -r 7 -rp 2000 127.0.0.1
You can also pause the traffic by pressing the ‘p’ key. SIPp will stop placing new calls and wait until all current calls go to their end. You can resume the traffic by pressing ‘p’ again.
To quit SIPp, press the ‘q’ key. SIPp will stop placing new calls and wait until all current calls go to their end. SIPp will then exit.

Changing Screens:

Several screens are available to monitor SIP traffic. You can change of screen by pressing 1, 2, 3 or 4 keys on the keyboard.

Key ‘1′: Scenario screen. It displays a call flow of the scenario as well as some important informations.
Key ‘2′: Statistics screen. It displays the main statistics counters. The “Cumulative” column gather all statistics, since SIPp has been launched. The “Periodic” column gives the statistic value for the period considered (specified by -f frequency command line parameter).
Key ‘3′: Repartition screen. It displays the distribution of response time and call length, as specified in the scenario.
Key ‘4′: Variables screen. It displays informations on actions in scenario as well as scenario variable informations.

Ref: - http://www.freelinuxtutorials.com/quick-tips-and-tricks/testing-your-sip-protocol-via-sipp/

Posted by linux at 5:35 am | permalink | Add comment

MySQL change and recover password

Setting up mysql password is one of the essential task in systems administration

Note: Linux/Unix login root account for your operating system and MySQL root are different

You can use the built-in “mysqladmin” command to change MySQL root password. It can be executed anywhere as long the binary path is set on your Linux or Windows environment

Condition 1: If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

# mysqladmin -u root password NEWPASSWORD

Condition2 : However, if you want to change (or update) a root password, then you need to use following command

#mysqladmin -u root -p’oldpassword’ password newpass

For example, If old password is xyz, and set new password to 654321, enter:

# mysqladmin -u root -p’xyz’ password ‘654321′

Condition 3: Change MySQL password for other user

To change a normal user password you need to type (let us assume you would like to change password for darwin):

# mysqladmin -u darwin -p oldpassword password newpass

Condition 4: Changing MySQL root user password using MySQL sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type following command at shell prompt:

# mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user darwin:

mysql> update user set password=PASSWORD(”NEWPASSWORD”) where User=’darwin’;

4) Reload privileges:

mysql> flush privileges;
mysql> quit

Condition 5: Recover MySQL root password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.
Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password
Step # 3: Connect to mysql server as the root user
Step # 4: Setup new root password
Step # 5: Exit and restart MySQL server

Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe –skip-grant-tables &

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root

Output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD(”NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe –skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

 Ref: - http://www.freelinuxtutorials.com/quick-tips-and-tricks/mysql-change-and-recover-password/

Posted by linux at 5:32 am | permalink | Add comment

Backup and Restore MySQL database

Quick tip in backing up and restore your MySQL database:

Backing up and Restoring MySQL database

Backing up database:
Syntax:
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
o    [username] -database username
o    [password] -password for your database
o    [databasename] – the name of your database
o    [backupfile.sql] – the file to which the backup should be written.
Example:
mysqldump -u root -p asterisk > asteriskbackupmarch3.sql
(just input the password when prompt for password)

Multiple database:

Syntax:
mysqldump -u [username] -p [password] –databases  [databasename1] [databasename2] > [backupfile.sql]

Example:
mysqldump -u asteriskuser -p –databases asterisk asteriskcdrdb > multibackup.sql
(then input db password)

Backup file in compressed format
Syntax:
mysqldump –all-databases | bzip2 -c >databasebackup.sql.bz2
mysqldump –all-databases | gzip >databasebackup.sql.gz

Restoring Database:

mysql -u [username] -p [password] [database_to_restore] < [backupfile]

Example:
mysql –u asteriskuser –p asterisk < asteriskbackup.sql
<input password when prompt>
mysql –u asteriskuser –p asteriskcdrdb < asteriskcdrdbbackup.sql
<input password when prompt>

Restoring compressed backup files

Example:

gunzip < databasebackup.sql.sql.gz | mysql -u asteriskuser -p asterisk

Addon: Sample Shell Scripts for automating backups

Back up your database without overwriting the older backup

#!/bin/sh
date=`date -I`
mysqldump –all-databases | gzip > /var/backup/backup-$date.sql.gz

Ref: - http://www.freelinuxtutorials.com/quick-tips-and-tricks/backup-and-restore-mysql-database/

Posted by linux at 5:26 am | permalink | Add comment

How to connect linux to MSSQL

Here’s one trick to do that: - http://www.freelinuxtutorials.com/quick-tips-and-tricks/quick-tip-how-to-connect-linux-to-mssql/

Step 1. Install  FreeTDS

FreeTDS Website: http://www.freetds.org/ choose FreeTDS source distribution

Compile parameter: –prefix=/usr/local/freetds –enable-msdblib

Then, copy /etc/ld.so.conf, to /usr/local/freetds/lib; and then run ldconfig

Step 2. Change /usr/local/freetds/etc/freetds.conf

[sql2k]

host = your.mssql.server.ip
port = 1433
client charset = cp950
tds version = 8.0

b. tds version: 4.2 (for MS SQL Server 6.x); 7.0 (for 7.x); 8.0 (for 2000)

Step 3. Test FreeTDS connect to MS SQL Server

#cd /usr/local/freetds/bin
#./tsql -S sql2k -U sa
1> use mydatabase
2> select * from mytable
3> go

it shows mytable if success

quit tsql:

1>    quit

Step 4. Re compile PHP Source

PHP website: http://www.php.net/

Before you re compile, please use php run echo phpinfo(); check the existing configure parameter, and then add  –with-mssql=/usr/local/freetds

example:

./configure ‘–prefix=/usr/local/php_4.3.10′ ‘–localstatedir=/var’ ‘–disable-debug’ ‘–enable-pic’ ‘–disable-rpath’ ‘–enable-inline-
optimization’ ‘–with-bz2′ ‘–with-db4=/usr’ ‘–with-curl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-
openssl’ ‘–with-png’ ‘–with-pspell’ ‘–with-regex=system’ ‘–with-xml’ ‘–with-expat-dir=/usr’ ‘–with-dom’ ‘–with-dom-xslt=/usr’ ‘–with-dom-exslt=/usr’ ‘–with-xmlrpc=shared’ ‘–with-pcre-
regex=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–enable-bcmath’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-safe-mode’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-track-vars’ ‘–enable-trans-sid’ ‘–enable-yp’ ‘–enable-wddx’ ‘–with-pear=/usr/share/pear’ ‘–with-imap=shared’ ‘–with-imap-ssl’ ‘–with-kerberos’ ‘–with-ldap=shared’ ‘–with-mysql’ ‘–with- pgsql=shared’ ‘–with-snmp’ ‘–with-snmp=shared’ ‘–enable-ucd-snmp-hack’ ‘–with-unixODBC’ ‘–enable-memory-limit’ ‘–enable-bcmath’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–enable-dbx’ ‘– enable-dio’ ‘–enable-mcal’ ‘–enable-mbstring’ ‘–enable-mbstr-enc-trans’ ‘–enable-mbregex’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-mssql=/usr/local/freetds’

After compile、installation, cp php.ini-dist /prefix/lib/php.ini

Step 5. Startup Apache HTTP Server for testing

Sample Code:

<?php

mssql_connect(’sql2k’,’sa’,”);
mssql_select_db(’mydatabase’);
$rs = mssql_query(’select * from mytable’);
list($column01) = mssql_fetch_row($rs);
echo $column01;
?>

It show mytable if success.

Posted by linux at 5:21 am | permalink | Add comment