Latest blog entry

ERROR: Can’t open or parse the config freshclam.conf

January 28, 2014    |   Posted by admin   |    Category: Linux Administration

While updating the ClamAV database using the ‘freshclam’ command, you may receive the “can’t open or parse the config file freshclam.conf” message.

root@vps:~# freshclam
ERROR: Please edit example config file /usr/local/etc/freshclam.conf
ERROR: Can't open/parse the config file /usr/local/etc/freshclam.conf

The reason is, with the default installation, the ‘Example’ variable is set to On which makes the configuration file work as a example and not the real configuration file.

To fix the issue, edit the freshclam.conf file

# nano /usr/local/etc/freshclam.conf

and remove or comment the line that says ‘Example’.

#Example

Save the file and execute the freshclam command to update the ClamAV database.

Comments Off on ERROR: Can’t open or parse the config freshclam.conf

How to make Tomcat work on port 80 instead of 8080?

January 11, 2014    |   Posted by admin   |    Category: cPanel Management, Linux Administration

Sometimes people host applications that are fully Java based and don’t require a Webserver to access their application. However, in such a case, the application has to be accessed with port 8080 i.e. http://domainname:8080 which is not feasible.

There are 2 ways for the Java application to work on port 80, so people don’t have to mention port 8080 in their URL We will take a look at each of the above 2 options below:

1. The easiest way is to change the Tomcat port from port 8080 to 80 in the conf/server.xml file. This file is inside the Tomcat folder. 

To locate the file, update the mlocate database first (this command will take sometime to complete):

# updatedb

now, search the server.xml file using the locate command:

# locate server.xml

Open the file in the edit mode

# nano server.xml

and search for the below section

<Connector port="8080" Protocol="HTTP"
maxHttpHeaderSize="8192"
connectionTimeout="20000"
/>

Replace port 8080 with 80 and restart the Tomcat service.

2. The second method is to use iptables rules to redirect traffic received on port 80 to port 8080.

To add the iptables redirect rules, SSH to your server as root and execute the below commands:

# iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j \
REDIRECT --to-port 8080

To make the rules permanent

# service iptables save

Applying any of the above 2 methods will make the Java application work without the use of port 8080 in the URL.

Comments Off on How to make Tomcat work on port 80 instead of 8080?

How to install Tomcat 7 on a cPanel server?

May 7, 2013    |   Posted by admin   |    Category: cPanel Management

cPanel’s easyapache script by default install Tomcat version 5.5 and provides no option to upgrade to version 7.x if required, so people who requires Tomcat 7 will have to install/upgrade tomcat manually but the newer version won’t be recognized by cPanel by default and people will have to configure domains manually in the tomcat configuration files.

There is a workaround though, so once Tomcat 7 is installed and some small changes are made, it can be managed from WHM also.

1) Start by installing the available Tomcat version provided by cPanel using the easyapache script. It will install Java on your server so you don’t have to install it manually. cPanel will install Tomcat under /usr/local/jakarta/ directory and a link to tomcat inside it.

# ls -la /usr/local/jakarta
drwxr-xr-x  13 tomcat nobody 4096 Apr 29  2009 apache-tomcat-5.5.25/
lrwxrwxrwx   1 root   root     39 Apr 29  2009 tomcat -> /usr/local
/jakarta/apache-tomcat-5.5.25/

2) Download Tomcat 7 in the /usr/local/jakarta directory and extract it

# cd /usr/local/jakarta
# wget http://apache.cs.utah.edu/tomcat/tomcat-7/v7.0.39/\
bin/apache-tomcat-7.0.39.tar.gz
# tar -zxf apache-tomcat-7.0.39.tar.gz

3) Once the tomcat file is extracted, a new directory ‘apache-tomcat-7.0.39’ will be created under the jakarta folder. Now, remove the old ‘tomcat’ link and create a new symlink to point to the new tomcat directory i.e.

# rm -f tomcat
# ln -s /usr/local/jakarta/apache-tomcat-7.0.39 tomcat

so it looks like follows:

# ls -la /usr/local/jakarta
 drwxr-xr-x  13 tomcat nobody apache-tomcat-5.5.25/
 drwxr-xr-x   9 root   root apache-tomcat-7.0.39/
 -rw-r--r--   1 root   root apache-tomcat-7.0.39.tar.gz
 lrwxrwxrwx   1 root   root tomcat -> /usr/local/jakarta
/apache-tomcat-7.0.39/

4) Now goto the new tomcat directory and compile the newer version

# cd /usr/local/jakarta/tomcat/bin
# tar -zxf commons-deamon-native.tar.gz
# cd commons-daemon-1.0.14-native-src/unix
# ./configure
# make
# cp jsvc ../..   (copies the new file to the bin directory)

5) Now copy the server.xml and workers.properties from the old tomcat installation to the new one. This is required if you already have tomcat enabled on some websites before the upgrade.

# cp -p /usr/local/jakarta/apache-tomcat-5.5.25/conf/server.xml \
/usr/local/jakarta/tomcat/conf/
# cp -p /usr/local/jakarta/apache-tomcat-5.5.25/conf/workers.properties\
/usr/local/jakarta/tomcat/conf/

6) Now, restart the tomcat server

# /usr/local/jakarta/tomcat/bin/shutdown.sh
# /usr/local/jakarta/tomcat/bin/startup.sh
# /etc/init.d/httpd restart

7) Check the tomcat version in use:

# sh /usr/local/jakarta/tomcat/bin/version.sh

If for any reason, you would like to go back to the older Tomcat version, just goto the jakarta folder and change the ‘tomcat’ symlink to the older tomcat folder and restart the tomcat server.

Comments Off on How to install Tomcat 7 on a cPanel server?

How to install ClamAV antivirus on Linux / cPanel?

April 7, 2013    |   Posted by admin   |    Category: cPanel Management

ClamAV is a anti-virus software that detects various malicious softwares and viruses. It can also be installed and configured in front of a mail server to scan emails. It provides command line scanning and automatic database update.

You can install ClamAV on a cPanel server from WHM as well as via SSH.

1) Login to WHM and goto the cPanel section
2) click Manage Plugins
3) select the checkbox "Install and Keep Updated" in ClamAV section.
4) Click Save at the bottom of the page.

It will take a few minutes for the installation to complete. Once done, enable the following checkboxes from WHM >> Plugins >> Configure ClamAV Scanner and click Save.

Scan Entire Home Directory
Scan Mail
Scan Public FTP Space
Scan Public Web Space

Each individual users will have a Virus Scanner option in his cPanel from where he can scan his files, emails etc.

The second method of ClamAV installation is through SSH. Login to the server and goto module-install directory and run the installer

# cd /usr/local/cpanel/modules-install/clamavconnector-Linux-i686/
# ./install

That’s it. If you now plan to scan the server side files OR the website files of any account, the following commands are very much useful and provide you with a quick result.

Updating the antivirus database first:

# freshclam

To scan a directory and print a list of the infected files:

# clamscan -ri /home

Scan and directly remove the infected files and emails

# clamscan -ri –remove /home
Comments Off on How to install ClamAV antivirus on Linux / cPanel?

Munin Unable to Generate Mysql Stats

January 27, 2013    |   Posted by admin   |    Category: cPanel Management

Munin plugin is known to have issues while generating Mysql graphs. The mysql graph remains empty due to a bug in the Perl library that causes the path to the mysqladmin to be lost.

The solution is to specify the path to mysqladmin in the /etc/munin/plugin-conf.d/cpanel.conf file. Edit the file

# nano /etc/munin/plugin-conf.d/cpanel.conf

and add the below line in the [mysql*] section

env.mysqladmin /usr/bin/mysqladmin

The mysql section should look like follows

[mysql*]
user root
group wheel
env.mysqladmin /usr/bin/mysqladmin

Restart the munin-node  service and see if it works. If it doesn’t, it indicates munin cannot read the values of mysql variables i.e. the username/password of mysql.

In such a case, have munin read the Mysql password from the .my.cnf file directly which is residing under the /root directory. To achieve this, create a file say, /root/mysqlpass

# nano /root/mysqlpass

and add the following command

/usr/bin/mysqladmin -uroot -p`cat /root/.my.cnf | grep pass \
| sed s/pass// | sed s/=// | sed s/\"//g` $@

The sed command may look confusing but it just removes words and characters around the password.

Set executable permission on the file

# chmod 755 /root/mysqlpass

Now edit the /etc/munin/plugin-conf.d/cpanel.conf file again and replace

env.mysqladmin /usr/bin/mysqladmin

with

env.mysqladmin /root/mysqlpass

Once done, restart the munin-node service and munin will start generating the Mysql graphs

Comments Off on Munin Unable to Generate Mysql Stats