Webhosting Blog

Archive for September, 2010

Clearing filesystem memory cache


The new linux kernels provide us the provision to clear page cache and/or inode and dentry caches  which can help free to clear a lot of memory.

Following command can help you to check the memory usage.

[root@server~]# free -m

In order to free  pagecache use following command:

[root@server~]# echo 1 > /proc/sys/vm/drop_caches

In order to free dentries and inodes:

[root@server~]# echo 2 > /proc/sys/vm/drop_caches

In order to free pagecache, dentries and inodes:

[root@server]# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable. So run a sync command for this.

[root@server]# sync; echo 3 > /proc/sys/vm/drop_caches


0 MB for a MYSQL DB in cPanel


Sometimes after migration of a database or after restoring the cpanel shows 0 MB for the database size even the database is not empty.
In order to remove this error you can follow following steps:

1) Login to the server as root

2)Open the file /var/cpanel/cpanel.config

[root@server ~]# vi /var/cpanel/cpanel.config

3) In the file locate the line “disk_usage_include_sqldbs”.

Check if the disk_usage_include_sqldbs=0

Change it to 1 if it is 0.

4)Once done run following command .

[root@server ~]# /scripts/update_db_cache

This command will update the cache stored for the databases.
This should now correct your error.


Error after changing WHM theme


WHM Themes are the GUI (Graphic User Interface) of WebHost Manager and cPanel – they control the “look and feel” of these applications. However after changing the WHM theme sometimes you can deal with following error while trying to revert the changed theme.

Error: [a fatal error or timeout occurred while processing this directive]file error – /usr/local/cpanel/whostmgr/docroot/themes/canarias/templates/setmytheme.tmpl: not found

This error is generally encountered when the theme is not set properly.

Follow following steps to resolve the error:

1) The file that stores the WHM theme is located as follows: For root the path is: /root/.whmtheme

2) Login to the server as the root user.

3) View the current theme of the server with the following command.

[root@server~]# vi /root/.whmtheme

4)To set the WHM theme back to the default, you an use the following:

[root@server~]# echo “x” > /root/.whmtheme

Thats It!! Now login to your WHM again. Error Resolved!


Forcing a www to a domain


Forcing a domain to follow to redirect to www is a very simple task.

Eg. http://mydomain.com should redirect to http://www.mydomain.com.

The question would be rather why one should force using www for a domain. A very simple and straight answer is for search engine optimization!
Search engines like Google and others may penalize for having duplicate contents and hence dropping you in rankings in the search engine. In order to avoid this from happening, we can force the domain to use www. We can use the .htacces file for this task. It is important for one to modify the .htaccess file in the document root of your domain to prevent duplicate content in search engines.

1) Use following steps in the document root of your domain.

[root@server~]# cd /home/username/public_html

2) Open the .htacess file with any of your favorite editors

[root@server~]# vi .htaccess

Insert the following code in file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname.com
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L]

Save the file.

3) Assign appropriate ownership to the file.

This will redirect all requests to the non-www version of your site to the www version using 301.


phpMyAdmin – Error : Cannot start session without errors


Sometimes in WHM while administering PhpMyadmin you may deal with following error.

Follow following steps in order to remove the error.

1. Login in to the server with the root user.

2) Open the file /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini.

[root@server~]# vi /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini

3) Locate the entry for :

session.save_handler = sqlite
session.save_path =/var/cpanel/userhomes/cpanelphpmyadmin/sessions/phpsess.sdb

4) Change this entries to following:

session.save_handler = files
session.save_path = /tmp

5) Save & Exit the file.

6) Now restart the Apache service on the server.

[root@server~]# /etc/init.d/httpd restart

This should sort the issue now.


Can’t create/write to file ‘/tmp/#sql_50e0_0.MYD’ (Errcode: 17)


While adding a sql statement to a DB sometimes you face an error as follows:

Can’t create/write to file ‘/tmp/#sql_50e0_0.MYD’ (Errcode: 17)

Follow following steps in order to remove the error.

1) Navigate to the document root of the domain.

[root@server ~]# cd /home/username/public_html

2) locate the servers main php.ini

[root@server ~]# php -i | grep php.ini

Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

3) Copy the file /usr/local/lib/php.ini to the public_html folder.

[root@server ~]# cp /usr/local/lib/php.ini  .

4) Open the php.ini file
[root@server ~]#  vi php.ini

Locate the line “session.save_path = /tmp

change it to “session.save_path = /home/username/public_html/tmp

Save and quit the file.

5) Now create the directory/home/username/public_html/tmp

[root@server ~]# mkdir /home/username/public_html/tmp

6) Assign respective ownership

[root@server ~]# chown username.username /home/username/public_html/tmp

7) Assign full permissions to the folder

[root@server ~]# chmod 777 /home/username/public_html/tmp

Now try adding the sql statement to the database. This should remove the error.


Directory index forbidden by rule


I installed joomla successfully, and tried to access the administrative URL:: http://www.xyz.co.uk/administrator/ and I got a 403 error.

1) Checking for the error log on the server it displayed me:

[Thu Sep  2 04:48:54 2010] [error] [client XX.XX.XX.XX]Directory index forbidden by rule: /home/xyz/public_html/xyz.co.uk/administrator/

This error occurred because of multiple index files in the “administrator” folder.

Follow following steps in order to remove the error.

2) Go to directory /home/xyz/public_html/xyz.co.uk/administrator/.

[root@server~]# cd home/xyz/public_html/xyz.co.uk/administrator/
[root@server administrator/]# ls -l index*
index2.php
index3.php
index.php

3) Open the .htaccess file for the directory and mention the index file to be used.

[root@server administrator/]# vi .htaccess

Insert following line

DirectoryIndex index.php

Save the file.

4) Try to access the URL http://www.xyz.co.uk/administrator/ now. The error should now be sorted out..

Note:: xyz.co.uk is an example. You may replace it with the respective domain name.


Webmail Shows Internal Server: Error User is Over Quota.


While login to Webmail it shows :

Internal Server Error User ‘username’ is over quota
(even if the user is not overquota!)

when you get the above error then follow the steps :

[root@server~]# cd /var/cpanel/overquota

[root@server /var/cpanel/overquota]# rm -f <cpanel username>

Now if you try to login to webmail, it should not give you any error.