Disable Stats Programs for a User

There are some cases where you may want to disable stats programs from running for certain users. To do so, open up their user file in /var/cpanel/users and add these lines:

STATGENS=WEBALIZER,AWSTATS,ANALOG
skipanalog=0
skipawstats=1
skipwebalizer=0

Of course, 1=yes and 0=no, and if the stats program is not enabled in the server it won’t run at all, regardless of whether it is enabled for a specific user.

Remove All Spam and Trash from Server

A buildup of spam and trash in user accounts can occupy several gigs worth of space. To easily remove spam and trash from your users’ accounts, you can use the following commands:

Maildir/Courier-IMAP:

rm -rf /home/*/mail/*/*/.spam/*
rm -rf /home/*/mail/.spam/*
rm -rf /home/*/mail/*/*/.Trash/cur/*
rm -rf /home/*/mail/*/*/.Trash/new/*

CPPOP:

rm -rf /home/*/mail/*/*/spam
rm -rf /home/*/mail/spam
rm -rf /home/*/mail/INBOX.Trash
rm -rf /home/*/mail/*/*/INBOX.Trash

To delete the cPanel trash folders:

rm -rf /home/*/.trash/*

Upgrading ClamAV – cPanel

Sometimes cPanel can be late with pushing out critical updates for third-party software. At the time of this writing, cPanel’s latest release of ClamAV is 0.91 which was determined to have a major security exploit, so all users are encouraged to update to 0.92. This upgrade guide assumes that you used cPanel’s plugin installer to successfully run ClamAV on your system.

cd /usr/local/cpanel/modules-install/clamavconnector-Linux-i686
wget http://freshmeat.net/redir/clamav/29355/url_tgz/clamav-0.92.tar.gz
wget http://downloads.sourceforge.net/clamav/clamav-0.92.tar.gz.sig
tar -xvzf clamav-0.92.tar.gz
wget http://missysadmin.com/files/clamav/install2
chmod 755 install2

You’ll need to check the 2nd and 3rd line in the install2 script to make sure they match the old and new versions of ClamAV.  To find the old version, run clamd –version.

AVV=0.92
AVVOLD=0.91.2

From here, just run ./install2 and let the installation run. You can confirm the upgrade by calling the binary with the version switch:

root@server [~]# clamd –version
ClamAV 0.91.2/5186/Wed Dec 19 22:38:25 2007

At this point it’s also a good idea to uncheck the ‘install and keep updated’ box for ClamAV in WHM.

Upgrading to Perl 5.8.8 – cPanel

Perl 5.8.8 has a lot of improvements over 5.8.7, and is highly recommended for use on cPanel 11.  Upgrading is simple:

wget http://layer1.cpanel.net/perl588installer.tar.gz
tar xfvz perl588installer.tar.gz
cd perl588installer
./install

The [pretty much] Complete Guide to Installing ffMPEG and Audio Binaries

I know you’ve provably seen a lot of guides on how to install ffMPEG, but I’ve noticed that most of them are incomplete and don’t cover the possible issues that can arise during installation. I’ve installed ffMPEG on dozens of servers and have devised a standardized procedure on what I feel is the best way to perform this installation.

This walkthrough has been tested on systems running Redhat 9, RHEL 4, and CentOS 4.5 and it may also work on other distributions and versions. Our servers also run cPanel 11, but this is in no way required in order to install ffMPEG. I assume at this point that you have root access and that yum (or another similar package manager) is installed.

ffMPEG commonly consists of and includes the following software:

– Essential / MPlayer
– FLVtool2 (Requires a Ruby Core)
– LAME MP3 Encoder
– php-ffMPEG
– ffMPEG
– libOgg
– libvorbis

To start out, enter into a temporary source directory and download all the binaries:

cd /usr/src
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2

*These are the latest stable versions at the time this article was written. If you are unable to download any of the above, you’ll need to visit the distributor’s site and download the latest stable version available.

Now extract everything:

bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar
tar zxvf flvtool2-1.0.6.tgz
tar zxvf lame-3.97.tar.gz
bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar
bunzip2 MPlayer-1.0rc2.tar.bz2 ; tar -xvf MPlayer-1.0rc2.tar

Create and import the Codecs directory:

mkdir /usr/local/lib/codecs/
mv essential-20061022/* /usr/local/lib/codecs/
chmod -Rf 755 /usr/local/lib/codecs/

Install Subversion and Ruby

yum install subversion
yum install ruby  (If you’re on cPanel you can alternatively use /scripts/installruby)
yum install ncurses-devel

Get ffMPEG and MPlayer from SVN:

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

Install LAME:

cd /usr/src/lame-3.97
./configure && make && make install

Install libOgg and libVorbis:

yum install libogg.i386
yum install libvorbis.i386
yum install libvorbis-devel.i386

Install flvtool2

cd /usr/src/flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Install MPlayer:

cd /usr/src/MPlayer-1.0rc2

Install ffMPEG:

cd /usr/src/ffmpeg/ ./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared make && make install

This is the typical configure line that I use, but you can customize this to what you need. For available configure options, type ./configure –help. Your custom configuration may require the installation of additional software on the server.

ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50 ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51 ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49 ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0 ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51

You may get an error about a library path not being found, if so, run

export LD_LIBRARY_PATH=/usr/local/lib

If this is being installed on a dedicated server, you might also get an error about the /tmp directory not be executable, which is common when installing on a dedicated server with a separate /tmp partition mounted noexec. In this case, you will need to create a tmp dir in the ffmpeg folder and use that as the tmp disk for now:

mkdir tmp chmod 777 tmp export TMPDIR=./tmp

Then run the configure command and set the TMPDIR variable back.

export TMPDIR=/tmp

Install ffMPEG-php

cd /usr/src/ffmpeg-php-0.5.0/ phpize ./configure && make && make install ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg ln -s /usr/local/bin/mplayer /usr/bin/mplayer

When the installation is complete, it will give you a long path to the shared libraries. This needs to be copied to the php.ini as so:

[ffmpeg] extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so

or in most cases where the extension_dir variable is set, just do:

extension=”/ffmpeg.so”

The ‘no-debug-non-zts-xxxxxxxx’ directory will be the one provided during installation. When this is done, restart Apache and check that the module is loaded in PHP:

/etc/init.d/httpd restart php -r ‘phpinfo();’ | grep ffmpeg

Look for this:

ffmpeg
fmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0

If you only get output for the ‘PWD’ variables, make sure that the extension_dir path is correct in the phpinfo file. Sometimes there are two specified, and if that is the case then the incorrect one should be commented out.

Test out ffmpeg for errors just by typing ffmpeg at the command line. The most common error is:

ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open…

To correct this, edit /etc/ld.so.conf and add the line

/usr/local/lib

then save and exit.

Now run this command to reload the library cache:

ldconfig -v

You’re all done…enjoy!

./configure && make && make install

Creating and Installing an SPF Record

Have you ever received a bounce for spam that was sent by you…only it wasn’t sent by you? Email spoofing is one of the easiest concepts to understand for us, but the hardest to explain to end users who confuse spoofing with email hacking and hijacking. The way I explain it to our customers is that spoofing is simply when someone (usually spammers) sends an email that looks as if it came from one person, when it really came from someone else.

Regardless of what some email providers say, there is no honest and straight forward way to keep people from spoofing your email, unless you have access to the real sender’s mail system. However, there is a way to keep legitimate mail servers from accepting spoofed email by creating an SPF record for your domain.

An SPF record (sender policy framework) in short is a DNS record that you add to your domain’s zone file to specify which hosts are allowed to send mail on behalf of your domain. For the most part you would only want the server hosting your domain to be able to send mail, but hat most of our customers don’t realize is that they unknowingly spoof email all the time! Since ISP’s nowadays block SMTP port 25 for third-party mail servers, a lot of our customers use their ISP to send mail for their domain. This is basically how email is spoofed…you put an email address as the ‘from’ address in an email, and send it from a different mail server. Even though this is legitimate email, they are basically allowing their ISP’s mail servers to send their domain’s email, even though their ISP has no authority or management rights over that email, since the domain is hosted on another server.

We usually require our customers to generate their own SPF records so that they can specify what servers they want to be able to send mail from, that way our hands stay clean if the SPF record causes them to not be able to send email. If you go to www.openspf.org you can easily generate a custom SPF record to add to your DNS zone with little to no hassle. The questions can be a little confusing for newbies, so here’s a quick walkthrough on how to answer them.

Question 1: A-Record

linuxbabu.net's IP address is 75.126.142.72 (srv2.webhostingsuite.com).
Does that server send mail for linuxbabu.net?

The wizard will attempt to resolve the domain to an IP, then do a rDNS on the IP for a hostname. You usually want to say YES unless your mail is hosted on a different server.

Question 2: MX-Record

This wizard found 2 names for the MX servers for linuxbabu.net:
srv2.webhostingsuite.com and linuxbabu.net.
MX servers receive mail for linuxbabu.net.
Do they also send mail from linuxbabu.net?

In most cases, this will be true. Exceptions for this is if you have an irregular MX record modification, or are using another outgoing mail server or domain to send mail.

Question 3: PTR

Do you want to just approve any host whose name ends in linuxbabu.net?

Typically, you do not want to enable this setting unless you have mail accounts set up for subdomains or domains that are similar in ending that need to relay through this domain. Or, if you use a subdomain as your sending host (like mail.domain.com, etc)

Question 4: A subs

Do any other servers send mail from linuxbabu.net?

The answer is usually no. The only other server that would send on behalf of that domain would be the server name (you may need to ask your host for this), but this was already allowed in question 1. The next two fields can be left blank, unless you specifically have information to add to them.

Question 5: Include

Could mail from linuxbabu.net originate through servers belonging to some other domain?

Fill in this field mainly if you are planning on using another mail server or domain (such as your ISP, gmail, etc.) to send mail. Otherwise say no.

Question 6: ~all

Do the above lines describe all the hosts that send mail from linuxbabu.net?

Check your answers and hit yes.
At the bottom of the page you’ll see the nicely-generated SPF record that will look something like this:

"v=spf1 a mx ~all"

Adding the Zone Entry

You can add the SPF record either WHM (if you are on a cPanel server) or manually in the zone file of that domain.

The line will look something like this:

linuxbabu.net. 14400 IN TXT "v=spf1 a mx ~all"

You can then verify the addition by doing a dig on the domain:

dig linuxbabu.netTXT

Disabling Apache Server Signatures

Apache by default puts a “signature” at the end of error pages and directory listings…here is an example of what this looks like:

Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.5 Server at missysadmin.com Port 80

Now, some people may not want to broadcast what type of server they are running or what’s on it, for reasons of security.  You can easily disable this in your httpd.conf file:

ServerSignature Off

service httpd restart

APF “Unable to load iptables module” Error

Upon upgrading the Linux Kernel version (usually in CentOS 4.6 – 5) you may get the following error when trying to start APF:

Unable to load iptables module (ipt_state), aborting.

To fix this, open /etc/apf/internals/functions.apf and locate the following lines:

ml ipt_state 1
ml ipt_multiport 1

And replace them with:

ml xt_state
ml xt_multiport

Then restart APF.

Yum ‘rpmdb’ Error

To our surprise a bad yum release hosed several of our systems.  While the errors varied, the common link between them was the frightful message:

rpmdb: PANIC: fatal region error detected; run recovery

This problem can usually be corrected by running the following commands:

cd /var/lib/rpm

rm -f __db*

rpm –rebuilddb -vv