Posts Tagged ‘Linux’

Posted by 6bytes at 24, March, 2010

Category: Linux

Tags: , ,

If you want to avoid situation when after server restart you have to start lots of services manually, a little thing like chkconfig would come in handy.
First you might want to take a look at a list of services handled by chkconfig:

chkconfig --list

You should see something like this:

mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
named           0:off   1:off   2:off   3:on    4:off   5:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

To add for example mysql to autostart list simply type:

chkconfig --add mysql on

To remove a service from autostart list type:

chkconfig --del mysql

For full list of chkconfig options go here.

Posted by 6bytes at 13, March, 2010

Category: CentOS, Linux, PHP

Tags: , , ,

After installing memcached daemon we have to install memcache PHP extension.

yum install php-pecl-memcache


apt-get install php5-memcache

If above is not an option try below method.

pecl install memcache

After successful installation add extension to your php.ini file.

vim /etc/php.ini

Add this line:

Restart web server

service httpd restart

Test out our installation.

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ('Can\'t connect!');
$version = $memcache->getVersion();
echo 'Server version: '.$version;

You should see your server’s version number. If you see a blank page make sure that memcached daemon is working. If you’re getting “Can’t connect!” message despite running daemon try changing ‘localhost’ to ‘’.

Posted by 6bytes at 13, March, 2010

Category: CentOS, Linux

Tags: , , , ,

Before we install memcached we need a dependency library libevent. Check for latest stable version at

cd /usr/local/src
tar -xzvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local
make install
cd ..

Now lets install memcached. Check for latest stable version at

tar -xzvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make install

More information about LDFLAGS

Run memcached as a daemon. Basic options: d = daemon, m = memory, u = user, l = IP to listen to, p = port

memcached -u root -d


memcached -u root -d -m 512 -l -p 11211

To stop daemon type

pkill memcached

Now we’re off to installing php extension memcache.

Posted by 6bytes at 23, April, 2009

Category: CentOS, Linux

Tags: , , ,

First download and unpack xmpppy.  To install it go into the unpacked directory and run:

python install

Next you need a script that will do the sending.  Use your favourite text editor to create file i.e.:


Just paste below script which was taken from original site.  Create another jabber account that you’ll send messages from and remember to change values in line 20 to those new login details.

# $Id:,v 1.8 2006/10/06 12:30:42 normanr Exp $
import sys,os,xmpp,time

if len(sys.argv) < 2:
 print "Syntax: xsend JID text"

text=' '.join(sys.argv[2:])

if os.access(os.environ['HOME']+'/.xsend',os.R_OK):
 for ln in open(os.environ['HOME']+'/.xsend').readlines():
 if not ln[0] in ('#',';'):
for mandatory in ['jid','password']:
 if mandatory not in jidparams.keys():
 open(os.environ['HOME']+'/.xsend','w').write('[email protected]\nPASSWORD=your_password')
 print 'Please point ~/.xsend config file to valid JID for sending messages.'


if not con:
 print 'could not connect!'
print 'connected with',con
if not auth:
 print 'could not authenticate!'
print 'authenticated using',auth

#cl.SendInitPresence(requestRoster=0)   # you may need to uncomment this for old server
print 'sent message with id',id

time.sleep(1)   # some older servers will not send the message if you disconnect immediately after sending


All you need to do now is to run the script 🙂 First run will create a file in you home directory which should contain username and password from line 20. Second run should accually send the message.

./ [email protected] Hello world!

Now set up your monitoring scripts that will send you jabber messages when something goes wrong.