Archive for the ‘CentOS’ 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.

Dependencies

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 http://src.chromium.org/svn/trunk/tools/depot_tools

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 http://modpagespeed.googlecode.com/svn/tags/ in your browser
# then copy link to /src ie. http://modpagespeed.googlecode.com/svn/tags/X.X.X.X/src
gclient config  http://modpagespeed.googlecode.com/svn/tags/0.9.1.1/src
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 centos.sh and change parameters according to your needs. Then run it.

vim install/centos.sh
cd install
./centos.sh
./centos.sh staging
./centos.sh 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 mod_pagespeed.so is in Apache module directory and if not copy it there.

locate mod_pagespeed.so
cp /tmp/mod_pagespeed.install/mod_pagespeed.so /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/mod_pagespeed.so

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

References:

http://code.google.com/speed/page-speed/docs/using_mod.html
http://code.google.com/p/modpagespeed/wiki/HowToBuild

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

or

apt-get install php5-memcache

If above is not an option try below method.

pecl install memcache

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

vim /etc/php.ini

Add this line:

extension=memcache.so

Restart web server

service httpd restart

Test out our installation.

<?php
$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 ‘127.0.0.1’.

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 http://monkey.org/~provos/libevent/

cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar -xzvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local
make
make install
cd ..

Now lets install memcached. Check for latest stable version at http://memcached.org/

wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
tar -xzvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make
make install

More information about LDFLAGS http://en.wikipedia.org/wiki/Linker

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

memcached -u root -d

or

memcached -u root -d -m 512 -l 127.0.0.1 -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

Problem

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-2.1.2.8.x86_64 (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.

Solution

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 23, April, 2009

Category: CentOS, Linux

Tags: , , ,

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

python setup.py install

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

vim xsend.py

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.

#!/usr/bin/python
# $Id: xsend.py,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"
 sys.exit(0)

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

jidparams={}
if os.access(os.environ['HOME']+'/.xsend',os.R_OK):
 for ln in open(os.environ['HOME']+'/.xsend').readlines():
 if not ln[0] in ('#',';'):
 key,val=ln.strip().split('=',1)
 jidparams[key.lower()]=val
for mandatory in ['jid','password']:
 if mandatory not in jidparams.keys():
 open(os.environ['HOME']+'/.xsend','w').write('JID=your_jabber_id@your_jabber_server.com\nPASSWORD=your_password')
 print 'Please point ~/.xsend config file to valid JID for sending messages.'
 sys.exit(0)

jid=xmpp.protocol.JID(jidparams['jid'])
cl=xmpp.Client(jid.getDomain(),debug=[])

con=cl.connect()
if not con:
 print 'could not connect!'
 sys.exit()
print 'connected with',con
auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource())
if not auth:
 print 'could not authenticate!'
 sys.exit()
print 'authenticated using',auth

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

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

#cl.disconnect()

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.

./xsend.py your_main_jabber@your_jabber.com Hello world!

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