Categories
CentOS 5.5 Tutorials

Apache with mod_pagespeed on CentOS 5.5

mod_pagespeed is an open-source Apache module that automatically optimizes web pages and resources on them. It does this by rewriting the resources using filters that implement web performance best practices.

Read more http://code.google.com/speed/page-speed/docs/module.html

This tutorial will show you how to install Apache with mod_pagespeed on CentOS 5.5.

Let’s begin.

# yum install yum-priorities
# yum install httpd

Add the mod_pagespeed YUM repository

# vi /etc/yum.repos.d/mod-pagespeed.repo

CentOS 5.5 32 Bit

[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/i386
enabled=1
gpgcheck=0

CentOS 5.5 64 Bit

[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64
enabled=1
gpgcheck=0

Now lets install mod_pagespeed

# yum install mod-pagespeed-beta

Done! All that is left is to read more about using mod_pagespeed, its configuration and configuring handlers at Using mod_pagespeed

Categories
CentOS 5.5 Tutorials

Installing Smokeping on CentOS 5.5

In this CentOS 5.5 tutorial we will be installing Smokeping and SmokeTrace on a CentOS 5.5 i386 server. The assumption is that you have a basic to medium understanding of Apache but if you follow this tutorial you should be able to complete the task successfully.

A bit on the software that we’ll be using:

Smokeping
SmokePing keeps track of your network latency:

* Best of breed latency visualisation.
* Interactive graph explorer.
* Wide range of latency measurment plugins.
* Master/Slave System for distributed measurement.
* Highly configurable alerting system.
* Live Latency Charts with the most ‘interesting’ graphs.
* Free and OpenSource Software written in Perl written by Tobi Oetiker, the creator of MRTG and RRDtool

http://oss.oetiker.ch/smokeping/

Preliminary Note:
I am using a CentOS 5.5 i386 base installation in this tutorial.

* www.how2centos.com (IP 10.0.0.100): CentOS 5.5 i386 base installation

Lets begin by installing the framework required by Smokeping.

# yum install yum-priorities

Install the EPEL i386 YUM Repository

# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install the RPMForge i386 YUM Repository

# rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# yum install httpd
# yum install rrdtool
# yum install fping
# yum install echoping
# yum install curl
# yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI 
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.1.tar.gz
# tar zxvf smokeping-2.4.1.tar.gz
# mv smokeping-2.4.1 /opt/smokeping
# cd /opt/smokeping
# cd bin/
# cp smokeping.dist smokeping
# cd ../htdocs/
# cp smokeping.cgi.dist smokeping.cgi
# cp tr.cgi.dist tr.cgi
# cd ../etc/
# cp config.dist config
# cp basepage.html.dist basepage.html
# cp smokemail.dist smokemail
# cp tmail.dist tmail
# cp smokeping_secrets.dist smokeping_secrets
# chmod 600 /opt/smokeping/etc/smokeping_secrets
# vi /opt/smokeping/bin/smokeping

Replace this:

#!/usr/sepp/bin/perl-5.8.4 -w
# -*-perl-*-

use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl);
use lib qw(lib);

use Smokeping 2.004000;

Smokeping::main("etc/config.dist");

With This:

#!/usr/bin/perl -w
# -*-perl-*-

use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs/);
use lib qw(/opt/smokeping/lib);

use Smokeping 2.004000;

Smokeping::main("/opt/smokeping/etc/config");

or you can Patch the file:

# cd /opt/smokeping/bin
# vi /opt/smokeping/bin/smokeping.patch
*** /opt/smokeping/bin/smokeping.dist   2008-06-10 15:08:07.000000000 +0200
--- /opt/smokeping/bin/smokeping        2010-08-04 16:43:08.000000000 +0200
***************
*** 1,12 ****
! #!/usr/sepp/bin/perl-5.8.4 -w
  # -*-perl-*-

! use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl);
! use lib qw(lib);

  use Smokeping 2.004000;
!
! Smokeping::main("etc/config.dist");

  =head1 NAME

--- 1,12 ----
! #!/usr/bin/perl -w
  # -*-perl-*-

! use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs/);
! use lib qw(/opt/smokeping/lib);

  use Smokeping 2.004000;
!
! Smokeping::main("/opt/smokeping/etc/config");

  =head1 NAME

# patch -p1 -i smokeping.patch /opt/smokeping/bin/smokeping
patching file /opt/smokeping/bin/smokeping
# vi /opt/smokeping/htdocs/smokeping.cgi

Replace this:

#!/usr/sepp/bin/speedy -w
# -*-perl-*-

use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl);
use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib);
use CGI::Carp qw(fatalsToBrowser);

use Smokeping 2.004000;

Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config");

With this:

#!/usr/bin/speedy -w
# -*-perl-*-

use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs);
use lib qw(/opt/smokeping/lib);
use CGI::Carp qw(fatalsToBrowser);

use Smokeping 2.004000;

Smokeping::cgi("/opt/smokeping/etc/config");

or you can Patch the file:

# cd /opt/smokeping/htdocs/
# vi /opt/smokeping/htdocs/smokeping_cgi.patch
***************
*** 1,13 ****
! #!/usr/sepp/bin/speedy -w
  # -*-perl-*-

! use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl);
! use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib);
  use CGI::Carp qw(fatalsToBrowser);

  use Smokeping 2.004000;

! Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config");

  =head1 NAME

--- 1,13 ----
! #!/usr/bin/speedy -w
  # -*-perl-*-

! use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs);
! use lib qw(/opt/smokeping/lib);
  use CGI::Carp qw(fatalsToBrowser);

  use Smokeping 2.004000;

! Smokeping::cgi("/opt/smokeping/etc/config");

  =head1 NAME

# patch -p1 -i smokeping_cgi.patch /opt/smokeping/htdocs/smokeping.cgi
patching file /opt/smokeping/htdocs/smokeping.cgi
# cd /opt/smokeping/htdocs
# vi /opt/smokeping/htdocs/tr.cgi

Change this:

#!/usr/sepp/bin/speedy-5.8.8 -w
use strict;
use lib qw(/home/oposs/smokeping/software/lib);
use lib qw(perl);

To this:

#!/usr/bin/speedy -w
use strict;
use lib qw(/opt/smokeping/lib);
use lib qw(perl);

or you can Patch the file:

# vi /opt/smokeping/htdocs/tr_cgi.patch
*** /opt/smokeping/htdocs/tr.cgi.dist   2008-06-14 00:02:34.000000000 +0200
--- /opt/smokeping/htdocs/tr.cgi        2010-08-06 15:01:31.000000000 +0200
***************
*** 1,6 ****
! #!/usr/sepp/bin/speedy-5.8.8 -w
  use strict;
! use lib qw(/home/oposs/smokeping/software/lib);
  use lib qw(perl);

  use CGI;
--- 1,6 ----
! #!/usr/bin/speedy -w
  use strict;
! use lib qw(/opt/smokeping/lib);
  use lib qw(perl);

  use CGI;
# patch -p1 -i tr_cgi.patch /opt/smokeping/htdocs/tr.cgi
patching file /opt/smokeping/htdocs/tr.cgi
# mkdir -p /var/www/html/smokeping/img /var/www/html/smokeping/script/ /opt/smokeping/data /opt/smokeping/var
# chown -R apache:apache /var/www/html/smokeping/img
# ln -s /opt/smokeping/htdocs/cropper /var/www/html/smokeping/cropper
# ln -s /opt/smokeping/htdocs/resource /var/www/html/smokeping/resource
# ln -s /opt/smokeping/htdocs/script/Tr.js /var/www/html/smokeping/script/Tr.js
# ln -s /opt/smokeping/htdocs/smokeping.cgi /var/www/html/smokeping/smokeping.cgi
# ln -s /opt/smokeping/htdocs/tr.cgi /var/www/html/smokeping/tr.cgi
# chmod 4775 /bin/traceroute
vi /etc/httpd/conf/httpd.conf

change > #AddHandler cgi-script .cgi
to > AddHandler cgi-script .cgi

Under <Directory “/var/www/html”>

change > Options Indexes FollowSymLinks
to > Options Indexes FollowSymLinks ExecCGI

# vi /opt/smokeping/etc/basepage.html

Change this:





To this:





or you can Patch the file:

# cd /opt/smokeping/etc/
# vi /opt/smokeping/etc/basepage.patch
56,59c56,59
< 
< 
< 
< 
---
> 
> 
> 
> 
# patch -p1 -i basepage.patch /opt/smokeping/etc/basepage.html
patching file /opt/smokeping/etc/basepage.html
# vi /opt/smokeping/htdocs/tr.html

Change this:


	
	  
		SmokeTrace
	  
	

To this:


	
	  
		SmokeTrace
	  
	

# ln -s /opt/smokeping/htdocs/tr.html /var/www/html/smokeping/tr.html

Lets create a basic Config file for Smokeping to get started:

# vi /opt/smokeping/etc/config
*** General ***

owner    = Peter Random
contact  = some@address.nowhere
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /var/www/html/smokeping/img
imgurl   = http://www.how2centos.com/smokeping/img
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   = http://www.how2centos.com/smokeping/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail
tmail = /opt/smokeping/etc/tmail

# specify this to get syslog logging
syslogfacility = local0

# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no

*** Alerts ***
to = alertee@address.somewhere
from = smokealert@company.xy

+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times  in a row

*** Database ***

step     = 300
pings    = 20

# consfn mrhb steps total

AVERAGE  0.5   1  1008
AVERAGE  0.5  12  4320
    MIN  0.5  12  4320
    MAX  0.5  12  4320
AVERAGE  0.5 144   720
    MAX  0.5 144   720
    MIN  0.5 144   720

*** Presentation ***

template = /opt/smokeping/etc/basepage.html

+ charts

menu = Charts
title = The most interesting destinations

++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f

++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds

++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f

++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds

+ overview

width = 600
height = 50
range = 10h

+ detail

width = 600
height = 200
unison_tolerance = 2

"Last 3 Hours"    3h
"Last 30 Hours"   30h
"Last 10 Days"    10d
"Last 400 Days"   400d

#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location

*** Probes ***

+ FPing

binary = /usr/sbin/fping

*** Targets ***

menuextra = (TR)

probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
         Here you will learn all about the latency of our network.

+ hosts
menu= Targets

++ How2CentOS

menu = How2CentOS.com
title = How2CentOS.com
alerts = someloss
host = www.how2centos.com

++ CentOS

menu = CentOS.org
title = CentOS.org
alerts = someloss
host = www.centos.org

Lets create a service startup script for Smokeping

# vi /etc/init.d/smokeping
#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : How2CentOS - http://www.how2centos.com

# Get function from functions library
. /etc/init.d/functions

# Start the service Smokeping
start() {
        echo -n "Starting Smokeping: "
        /opt/smokeping/bin/smokeping >/dev/null 2>&1
        ### Create the lock file ###
        touch /var/lock/subsys/smokeping
        success $"Smokeping startup"
        echo
}

# Restart the service Smokeping
stop() {
        echo -n "Stopping Smokeping: "
        kill -9 `ps ax | grep "/opt/smokeping/bin/smokeping" | grep -v grep | awk '{ print $1 }'` >/dev/null 2>&1 && killall speedy_backend
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/smokeping
        success $"Smokeping shutdown"
        echo
}

### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status Smokeping
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac

exit 0
# chmod 755 /etc/init.d/smokeping

Finally lets add Apache and Smokeping to startup and get them started:

# chkconfig smokeping on
# chkconfig httpd on
# service smokeping start
Starting Smokeping:		[  OK  ]
# service httpd start
Starting httpd:		[  OK  ]

Now browse to your new installed Smokeping and Smoketrace installation

http://www.how2centos.com/smokeping/smokeping.cgi

Categories
CentOS 5.2 Tutorials CentOS 5.3 Tutorials CentOS 5.4 Tutorials CentOS 5.5 Tutorials

CentOS: The most popular Linux distribution for web servers

It’s a great day for CentOS and its community because, according to Web Technology Surveys, in July 2010, “For the first time, CentOS is now leading the Linux distribution statistics on web servers with almost 30% of all Linux servers.”

CentOS Webserver survey

Read more at W3Techs

Categories
CentOS

XSLCache is in PECL

Originally developed by NYTimes, XSLCache extension for PHP is finally in PECL repository and ready for it’s first PECL-release.

“The XSL Cache extension is a modification of PHP’s standard XSL extension that caches the parsed XSL stylesheet representation between sessions for 2.5x boost in performance for sites that repeatedly apply the same transform. Although there is still some further work that could be done on the extension, this code is already proving beneficial in production use for a few applications on the New York Times’ website.”

Installation, from now on, should be as simple as pecl install xslcache

I have modified the linux installing guide, Installing and upgrading to PHP 5.2.9 on CentOS and Red Hat Linux 5.3 x86_64 to reflect this change.