Installing Clamscan on CentOS 5

I spent a bit of time searching for an answer to this and found it in a couple of places. Here are the required step to get clamscan installed on Centos 5.

1. Download the rpmforge package
wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

2. import the rpmforge GPG key
rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

3. Check that you have a valid RPM file
rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm

4. Install rpmforge
rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm

5.  Install yum priorities
yum install yum-priorities

Yum-priorities allows you to add a priority parameter to each of the repositories listed in /etc/yum.repos.d. You need to do this to ensure that the base repositories always take precedence over the rpmforge repository.

6. Edit each of the .repo files in /etc/yum.repos.d adding a priority line to each repository like this:

name=CentOS-$releasever – Base

Give all of the repositories a priority of 1 except the repositories in the rpmforge.repo file – they should have a priority of 2

7. Install clamav (alter the filename if you have a 64 bit server)
yum install clamav.i386

8. Install the clamd daemon (you need this for freshclam which updates the virus database
yum install clamav.i386

9. Configure the clamd daemon to start at reboot
chkconfig clamd on

10. Start the clamd daemon
service clamd start

Run freshclam to update the database


mysqldump: Got error: 1017: Can’t find file: (errno: 24) when using LOCK TABLES

I was recently moving a site from one WHM/CPanel server to another WHM/CPanel server and found that this error was causing some problems. This was particularly interesting as I remember trying to move a CPanel account in the past (using /scripts/pkgacct) and we found that everything was fine except that none of the database tables had been backed up. On that occassion we were able to just recreate the empty tables as there wasn’t a whole lot of data but we never did get to the root cause of the problem.

This recent move was similar. It was actually a site that hosts around 2100 blogs with the WordPress WPMU version. Given that there were a lot of blogs with a lot of data, failure wasn’t an option so I decided to do a manual dump of the database. That’s when I saw the error from mysqldump. A quick Google of the error message turned up a similar issue and it wasn’t until after I read carefully that I found this person had the solution. It was in a bug report though and not all that descriptive so I thought it was worth blogging.

The cause of the problem is the default limit that MySQL has on open files. If you fire up your favourite SSH client and login to your server and issue the command:

mysqladmin variables

…it’s going to tell you this:

open_files_limit   | 1024

So, we now know that MySQL has a default limit of 1024 open files. That’s a lot of files…in most cases… but consider my situation where I have over 2000 blogs and each blog has multiple files. Even with 1 file per blog we’d be over that limit. Note that this issue should only happen with MyISAM databases as they use separate files for each table. Knowing that this open files limit was the issue my next step was to find out exactly how many files were in the database directory. To do that you can issue a command like:

ls /var/lib/mysql/my_database/ | wc -l

The /var/lib/mysql part is the default directory for MySQL MyISAM files and the my_database part would be the directory that is named the same as the database you are trying to back up. The command line above will list (ls) the files in the directory and the pipe to ‘wc -l’ will count how many words are displayed in the resulting ‘ls’ listing. In my case the number was:


That’s a heck of a lot of files! The fix was to edit /etc/my.cnf and add the following line to the [mysqld] section:


I then restarted the MySQL server and it completed the backup of the database and all of its tables.


Getting To Know SSH and The Unix Shell

If you don’t have an IT background, then working on your server is a bit like working on a car for the first time. There’s a lot of stuff under the hood but it all looks like a whole lot of hoses, wires and thingamajigs. That can be scary and it’s true to say that just as you can disable your car if you move the wrong wire, you can do damage to your server if you use the wrong commands.

The best way is to ease into it. Become comfortable with some of the simple commands before you try anything fancy. In this article I’m going to look at some basic commands that will provide you some information about your server.

The first thing to remember is that most flavours of Unix (e.g. RedHat, CentOS etc) are case sensitive and most commands should be entered in lower case. So, the command DF will  yield a ‘command not found’ error, whereas df will tell you how much disk space you have free.

In order to run these commands you will need to use a SSH client program. SSH or ‘Secure Shell’ has, for the most part, replaced the old and somewhat insecure Telnet program. They both do much the same thing except that Telnet is in clear text and SSH is an encrypted link. If you are using windows then you should download Putty which is a free SSH client. There is a setup guide at http://gears.aset.psu.edu/hpc/guides/putty/. Just ignore the part about enabling X11 Forwarding – we don’t need that.

Once you have installed Putty and successfully commected to your server you will see a prompt that looks something like this:

[joe@www admin]#

This is what we refer to as the ‘command prompt’ as it is the place where you enter any commands that you want the server to run.

So…what commands can you run without causing any problems? Thousands … literally … but we will look at just a handful here to get you started.

df – This command will tell you how much hard disk space your server is using (think of it as ‘disk free’). Let’s look at the output. Type df at the command prompt and pressyour ‘Enter’ key.

The output will look something like this:

[joe@www admin]#df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00   74718304   6661240  64200272  10% /
/dev/hda1               101086     11731     84136  13% /boot
tmpfs                   225228         0    225228   0% /dev/shm
/dev/hdc2            145739192    465284 137870756   1% /mnt/disk2
/dev/hdd1            240362656  66950244 161202612  30% /mnt/disk3

The important column is the second last column – the one with the percentage figure. That number tells you how much of the disk is in use. For example, the first disk in that list is using 13% of its total space and the last one is using 30% of its total space. If you would like to know more about the other numbers in that output, there’s a good primer at http://www.oracle.com/technology/pub/articles/calish_filesys.html.

free – this command will tell you how much total and free RAM your  server has. Type free at the command prompt and press your ‘Enter’ key. The output looks something like this:

[joe@www admin]#free

                        total        used          free        shared    buffers     cached
Mem:       2055416    1631192     424224          0      180224    1061592
-/+ buffers/cache:     389376    1666040
Swap:      2040244        208    2040036

From the above we can see that this server has 2GB of RAM (total) and that it is currently using approximately 1.6GB of that RAM. That doesn’t mean that the applications on the server are using most of the RAM though. Note the two columns ‘buffers’ and ‘cached’. The operating system uses buffers and cache internally to manage its own operations and optimize performance. In reality, the applications on the server are using around 389MB of RAM and the operating system is utilizing much of the remaining RAM.  The ‘Swap’ figures show how much ‘swap space’ the server has and how much it is using. Swap space is similar to Windows ‘virtual memory’. If the server uses up all of the physical RAM it will start to swap idle programs out to disk. Generally speaking you should ensure the server has enough physical RAM that it doesn’t need to swap to disk. Disk based memory is much slower than your ‘real’ RAM.

Now that we’ve covered a couple of the simple command, there’s a good list of some other commands at http://www.reallylinux.com/docs/basic.shtml.

Just be careful if you use the passwd command. It will change your password instantly. Oh, and don;t go changing your password to anything simple. Remember, security starts with a strong password!


WHM/CPanel: #2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)

Tjis is quite a common error and fortunately there seems to be a ‘silver bullet’. The answer was posted on the CPanel forums by Dawzz.

pico /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php
or if your server doesn’t have pico:

nano /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php
Look for the line that says:

$cfg[‘Servers’][$i][‘socket’] = ”;

and change it to:

$cfg[‘Servers’][$i][‘socket’] = ‘/var/lib/mysql/mysql.sock’;
then change the next line from:

$cfg[‘Servers’][$i][‘connect_type’] = ‘tcp’;

$cfg[‘Servers’][$i][‘connect_type’] = ‘socket’;

Leave a comment if that worked for you!


Fantastico Error – Fantastico Is Not Installed

I had this error show up on a couple of servers today. A search on Google revealed that it’s not an entirely uncommon problem and there seemed to be a host of possible fixes.

After trying a few things that were suggested in forums (and didn’t fix the problem) I deleted the Fantastico files and did a clear re-install. No dice – I still had the same error message:

Fantastico is not installed at the default location /usr/local/cpanel/3rdparty/fantastico. Either move the Fantastico directory from it’s current location to /usr/local/cpanel/3rdparty/fantastico OR enable ioncube loaders in WHM -> Tweak settings.

Not being a quitting kind of guy, I continued to trawl the forums and eventually found the solution (for me, anyway). It seems that WHM isn’t putting the correct entry for the ioncube loaders into the CPanel php.ini. So, here’s what fixed it for me. Log in to your server as root and do the following:

cd /usr/local/cpanel/3rdparty/etc

pico -w /var/cpanel/3rdparty/etc/php.ini

…then add this line at the bottom of your php.ini file:


If you get ‘command not found’ or similar then instead of pico try nano to edit the php.ini

You may also need to add that line to the bottom of /var/cpanel/3rdparty/etc/php.ini … but only if that file exists. None of my servers had a 3rdparty directory under /var/cpanel.

Here is a link to the forum post where I found this info.


…and it refers to this post: