Archive for the ‘Linux’ Category

Posted by 6bytes at 17, November, 2010

Category: Apache, CentOS

Tags: , , , ,

I’m not going to write about whether I think mod_pagespeed is good or not, is it suitable for your website, why you should use it or not. I’ll focus only on installation.

Since you’re here and still reading I assume you want to speed up your website with Google’s mod_pagespeed. If you’re on a machine where for any reason installing from .rpm or .deb is not possible read on.


First we need to install Chromium ‘depot_tools’, which are used to build multiple open-source projects with dependencies on other open-source projects.

mkdir ~/bin
cd ~/bin
svn co

You will need to add the depot_tools to your path. i.e. in bash:

export PATH=$PATH:~/bin/depot_tools

Check out mod_pagespeed and dependencies

mkdir ~/mod_pagespeed    # any directory is fine
cd ~/mod_pagespeed
# always check for latest version by going to in your browser
# then copy link to /src ie.
gclient config
gclient sync --force     # this will download all source code

Compile mod_pagespeed

cd ~/mod_pagespeed/src
make BUILDTYPE=Release   # BUILDTYPE defaults to 'Debug'

Install mod_pagespeed

First edit and change parameters according to your needs. Then run it.

vim install/
cd install
./ staging
./ install

Restart Apache

/etc/init.d/httpd restart

Check if Apache loaded mod_pagespeed.

httpd -M # list static and shared modules, mod_pagespeed should be here
httpd -l # list compiled in modules

If above doesn’t work try something like this:

/usr/src/httpd/httpd -M
/usr/src/httpd/httpd -l

If it’s there go to /etc/httpd/pagespeed.conf and configure it. I’ll write a bit more about configuring mod_pagespeed in my next post. If it’s not there make sure is in Apache module directory and if not copy it there.

cp /tmp/mod_pagespeed.install/ /usr/local/apache2/modules/

Edit your Apache configuration file and add Include /etc/httpd/pagespeed.conf if it isn’t already there. Next edit /etc/httpd/pagespeed.conf and add

LoadModule pagespeed_module /usr/local/apache2/modules/

Restart Apache and you should see something like X-Mod-Pagespeed: in your website’s response headers.


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 20, August, 2009

Category: CentOS, Linux


Sometimes after running yum update or yum install something you’re getting missing dependency error messages. Like this:

--> Missing Dependency: /usr/lib64/python2.4 is needed by package
gamin-python-0.1.7-8.el5.x86_64 (installed)
--> Missing Dependency: /usr/lib64/python2.4 is needed by package
libxml2-python-2.6.26- (installed)

This means that some other package needs to be installed in order to install the one you want. If you have all dependencies installed and you’re still getting those messages all you need to do is clean yum’s cache.


Run one of these (taken from yum manual):

The following are the ways which you can invoke yum in clean mode. Note that “all files” in the commands below means “all files in currently enabled repositories”. If you want to also clean any (temporarily) disabled repositories you need to use –enablerepo=’*’ option.

yum clean packages

Eliminate any cached packages from the system. Note that packages are not automatically deleted after they are downloaded.

yum clean headers

Eliminate all of the header files which yum uses for dependency resolution.

yum clean metadata

Eliminate all of the files which yum uses to determine the remote availability of packages. Using this option will force yum to download all the metadata the next time it is run.

yum clean dbcache

Eliminate the sqlite cache used for faster access to metadata. Using this option will force yum to recreate the cache the next time it is run.

yum clean all

Runs yum clean packages and yum clean headers, yum clean metadata and yum clean dbcache as above.

Now run again your yum update or any other yum install command and it should be fine.

Posted by 6bytes at 14, August, 2009

Category: Linux, PHP


PHP has a bug with applying summertime in some timezones. If you’ve set correct timezone in your php.ini file and running

< ?php
echo date("r");

still gives you wrong time its quite possible that you’ve just found this bug.


To correct this you need to install new timezone file. Run below command on your server:

$ pecl install timezonedb

Successful installation should result in something like this

Build process completed successfully
Installing '/usr/local/lib/php/extensions/debug-non-zts-20060613/'
install ok: channel://
configuration option "php_ini" is not set to php.ini location
You should add "" to php.ini

open your php.ini file

$ vim /etc/php.ini

add line “” as instructed.

If PHP now surprises you with

PHP Warning:  PHP Startup: Unable to load dynamic library './' - 
./ cannot open shared object file: No such file or directory in 
Unknown on line 0

you need to add full path to the “” file in your php.ini
Install process returns the full path to “” but if you need to find it type:

$ find / -name

edit your php.ini once more and change




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.