You Are Here Home > Server

Server

MySQL: ERROR 1114 (HY000) at line 4424: The table ‘X’ is full

Even though this could be a limitation by your file system check the value of the system variable:

myisam_data_pointer_size

If it’s set to 4 then the table can be a maximum of 4GB in size but if it’s set to 6 then the table can be a maximum of 256TB…

To fix this try:

edit /etc/my.cnf

And add this line to the end of it:

myisam_data_pointer_size = 6

Save it and restart mysql:

service mysql restart

I hope this helps…

MySQL: ERROR 1114 (HY000) at line 4424: The table ‘X’ is full
Comments (0)   Filed under: MySQL, Operating Systems, Server   Posted by: Codehead

WHM/cPanel: MySQL Errors While Manually Transferring Accounts

Errors like:

DELIMITER must be followed by a ‘delimiter’ character or string
or
ERROR X (X): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near

If you get those errors the chances are that the MySQL version on the source and destination servers don’t match, most probably the destination server runs an older version of MySQL, to fix this issue, you must let /scripts/pkgacct know your version of MySQL, find out the version, then do something like this:

/scripts/pkgacct UNAME –mysql 4.1
Note: 2 dashes before mysql, they are not showing up here…

Please note that, in my case, my MySQL server was version 4.1 so you may need to change this version number to match your own destination server’s MySQL server version.

I hope this helps someone :)

WHM/cPanel: MySQL Errors While Manually Transferring Accounts
Comments (0)   Filed under: MySQL, Server, WHM/cPanel   Posted by: Codehead

CentOS-Yum: warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6

Try:

rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
rpm –import ftp://mirrors.easynews.com//linux/centos/RPM-GPG-K
:)

CentOS-Yum: warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Comments (3)   Filed under: CentOS, Linux, Security, Server   Posted by: Codehead

Manually move WHM/cPanel accounts – WHM account transfer function timeout

Before you do it
You will have to make sure that both Apache web servers are the same version, I didn’t and it caused some problems.

My hosting company also mentioned that both cPanels must be the same version too, but I’m not sure about this.

You will also need root access to both servers and an SSH client like putty, so go ahead and connect to both servers.

Manually Moving WHM/cPanel accounts
Follow these steps:
1 – In your old server do:
/scripts/pkgacct “username” <------- Don't type the quotes

2 - After the first step is done do:
scp /home/username.tar.gz root@IP:/home/ <------- Where IP is the IP of your destination server

You will be asked for the root password.

3 - In your destination server do:
cd /home
/scripts/restorepkg “username” <------- Don't type the quotes

Disclaimer
Do this at your own risk, it worked fine on my version of WHM/cPanel/CentOS.

Manually move WHM/cPanel accounts – WHM account transfer function timeout
Comments (3)   Filed under: Server, WHM/cPanel   Posted by: Codehead

The nx service is not available or the nx access was disabled – CentOS

If you follow the instruction here:
http://wiki.centos.org/HowTos/FreeNX

You will get an error message from NX client:
The nx service is not available or the nx access was disabled

To fix this, connect to your SSH and type:
cat /var/lib/nxserver/home/.ssh/client.id_dsa.key

Copy the text you get and in your NX client, on your login dialog box go to:
Configure… > General Tab > Key

And paste the text there and you will be fine :)

The nx service is not available or the nx access was disabled – CentOS
Comments (10)   Filed under: CentOS, Server   Posted by: Codehead

A PHP script for dealing with DoS attacks

Here is a simple script that will show you what IP addresses are making how many requests to your server.

<?php
 
## Functions ##
 
function getIP($line) {
	ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$line,$regMatch);
	$ip = $regMatch[0];
	if($ip) return $ip; else return "false";
}
 
function processString($string, $size = 18) {
	$string = "[ ".$string;
	$length = strlen($string);
	$toAdd = $size - $length;
 
	for($x = 0; $x < $toAdd; $x++) {
		$string = $string." ";
	}
	$string = $string."]";
	return $string;
}
 
## Code ##
 
while (true) {
	$cmd = "netstat -n | awk '{ print $5 }'";
	exec($cmd, $netstatArray);
	$ipArray = array();
 
	foreach($netstatArray as $line) {
		$ip = getIP($line);
		if($ip != "false" && ip != "127.0.0.1") {
			if(array_key_exists($ip, $ipArray))
						 {
									$ipArray[$ip]+=1;
						 }
						 else // if not, count=1
						 {
									$ipArray[$ip] = 1;
						 }
		}
	}
 
	asort($ipArray);
 
	system("clear");
	foreach($ipArray as $ip => $count) {
		if ($count < 15)
			continue;
		echo processString($ip);
		echo "\t" .processString(gethostbyaddr($ip), 55);
		echo "\tTimes Accessed: " .$count ."\n";
	}
 
	echo str_repeat("-", 50) ."\n";
	exec("top -n 1", $top_str);
	preg_match("#load average:(.+)#i", $top_str[0], $match);
	echo "Load Average: " .$match[1] ."\n";
	echo str_repeat("-", 50) ."\n";
	echo 'Showing $count >= 15: (Escape with ctrl+c)' ."\n";
 
	sleep(10);
}
 
?>

After identifying the IP addresses that are sending many requests at once to crash your server, you can ban them using a firewall software. I personally recommend APF: http://rfxnetworks.com/apf.php

You can do:
apf -d THEIPADDRESS SOMECOMMENTLIKEPOSSIBLEDOS

This script was originally written by a former employee of Acenet Inc and was modified by me. Acenet Inc is a great web hosting company with great support and fantastic staff members who will help you 24×7.

Here is some info about Denial of Service attacks (DoS attacks).
http://en.wikipedia.org/wiki/Denial-of-service_attack

I hope this helps someone.

A PHP script for dealing with DoS attacks
Comments (4)   Filed under: PHP, Security, Server   Posted by: Codehead

Slowing down Yahoo! Slurp (Yahoo! Search Bot)

A few weeks ago one of our servers started to crash every few days.

After investigating this issue for a while we found 100s of IP addresses from Yahoo! and Inktomi Corporation which is the company who developed Yahoo! Slurp.

So basically Yahoo! was launching DOS attacks against our server although unintentional but very annoying. It also shows that their technology is not as advanced as Google or other search engines or it’s buggy, Whatever you think, crashing people’s servers with your search bot is not cool at all and shows that you have to work on it a little more…

If you have the same problem here is a simple solution Yahoo! suggest; open your robots.txt (create it if you don’t have it and place it in your root folder) and add these lines to it:

User-agent: Slurp
Crawl-delay: 1

Only Yahoo! will understand the line Crawl-delay: X and Yahoo! suggests that you use a small number between 0.5 and 1.

Slowing down Yahoo! Slurp (Yahoo! Search Bot)
Comments (0)   Filed under: Annoying Stuff, Search Engines, Server   Posted by: Codehead

A little Program For Monitoring Your Websites, With Alarm

I hope someone will find this useful:

###
 #    Hamid Alipour
###
 
###
 # Config
#####################################################
urls = ['http://www.P U T  Y O U R  U R L S  H E R E.com/']
url_timeout = 5
sleep_time = 5 * 60
failed_count_before_alarm = 10
sleep_time_on_failure = 15
#####################################################
 
import urllib2
import winsound
import time
 
class SiteMonitor:
 
    def __init__(self):
        pass
 
    def start(self):
        while True:
            for url in urls:
                if not self.check_url(url):
                    if not self.is_it_live(url):
                        self.alarm()
            self.sleep(sleep_time)
 
    def is_it_live(self, url):
        failed_count = 0
        while failed_count < failed_count_before_alarm:
            if not self.check_url(url):
                failed_count += 1
            else:
                return True
            self.sleep(sleep_time_on_failure)
        return False
 
    def check_url(self, url):
        print 'Checking...' + url + '...',
        try:
            urllib2.urlopen(url, timeout=url_timeout)
        except:
            print 'Failed!'
            return False
        print 'Done it\'s up!'
        return True
 
    def alarm(self):
        print 'Too many failures...'
        while True:
            print 'Alarm...'
            winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
 
    def sleep(self, seconds):
        print 'Sleeping for ' + str(seconds) + ' second(s)...'
        time.sleep(seconds)
        print 'Waking up...'
 
def main():
    SiteMonitor().start()
 
if __name__ == "__main__":
    main()

Save it as sitemonitor.py and run it like:
python sitemonitor.py

Or just double click on the file.

Please note: in order to run this, you will have to install Python:
http://www.python.org/download/

A little Program For Monitoring Your Websites, With Alarm
Comments (1)   Filed under: Python, Server   Posted by: Codehead

Fixing libxml, php bug and issues with HTML entities; libexpat

There is another way to fix this issue and I didn’t write about it because I couldn’t make it work at first.
Apparently I was missing one line :)

First you will need to find out where libexpat is located on your server, it’s probably here:
/usr/lib

To find out for sure, open this folder (/usr/lib) and look for the file:
libexpat.so

If you can’t find it, log in as root via SSH and enter:
whereis libexpat.so

This should list the folder in which libexpat is located.

After all this you will need to compile PHP to use libexpat instead of libxml, so go to:
/var/cpanel/easy/apache/rawopts/

And create a file and name it “all_php5″ (no quotes), if there is a file with this name edit it and add these lines to the end of it:
–with-expat=builtin
–with-libexpat-dir=/usr/lib

(lines start with two dashes “-” that are not showing up here for some reason)
Remember that depending on where libexpat is located on your server you might need to edit the second line.

Now compile Apache and everything should work fine!

Fixing libxml, php bug and issues with HTML entities; libexpat
Comments (0)   Filed under: Annoying Stuff, Programming, Server, Web Development   Posted by: Codehead

Fixing libxml, php bug and issues with HTML entities; downgrading libxml

When you parse XML with PHP and libxml 2.7.0, all HTML entities were stripped out and this annoying bug messed up a lot of things and no one seems to care enough to fix this.

This bug is also reported here:
http://bugs.php.net/bug.php?id=45996
http://bugs.typo3.org/view.php?id=9359&nbn=2

From reading these few resources, I knew I had to downgrade to an older version of libxml but since I’m not very good at Linux I had no idea how to.

But I finally figured this out and here is how to do it with WHM/cPanel:

First you will have to install an older version of libxml, I installed libxml 2.6.30.
You will need an SSH client and you will have to login to your server with root, I use Putty:
http://www.chiark.greenend.org.uk/~sgtatham/putty/
Download it, run it, enter the IP address of your server, enter root and enter your password.
Then do:

cd /opt

mkdir libxml

cd libxml

wget http://xmlsoft.org/sources/libxml2-2.6.30.tar.gz

tar xvzf libxml2-2.6.30.tar.gz

cd libxml2-2.6.30

./configure –bindir=/opt/libxml/ –sbindir=/opt/libxml/ –libexecdir=/opt/libxml/ –datadir=/opt/libxml/ –sysconfdir=/opt/libxml/ –sharedstatedir=/opt/libxml/ –libdir=/opt/libxml/ –includedir=/opt/libxml/ –oldincludedir=/opt/libxml/

make && make install

Now you will need to update yum.conf to prevent it from updating libxml back, so edit:
/etc/yum.conf

And find the line that starts with:
exclude=

And add libxml* to the end of it so this line should look something like this:
exclude=apache* bind-chroot courier* dovecot* exim* httpd* mod_ssl* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail* libxml*

Now we will have to let WHM know that we want to compile PHP with this new libxml path so go to:
/var/cpanel/easy/apache/rawopts/

There might be a file there named: “all_php5″ (no quotes) if there is edit it if there is not create it and add these lines to the end of it:
–with-libxml-dir=/opt/libxml
–with-libxml-dir=/opt/libxml/

Now go ahead and build Apache and PHP using:
WHM >> Main >> Software >> Apache Update

You should be all set.

Please note:
1 – Do this on your own risk.
2 – I’m not very good at Linux so please let me know if there is an easier method.
3 – This worked great on my CentOS.
4 – If you have never used WHM’s Apache Update, go ahead and read about it first.

Fixing libxml, php bug and issues with HTML entities; downgrading libxml
Comments (15)   Filed under: Annoying Stuff, PHP, Server, Web Development   Posted by: Codehead
Older Posts »