≡ Menu


WordPress: Redirecting Old Tag URL to New Tag Location

Recently, I had noticed lots of 404 error generated by my wordpress software. My old wordpress tag structure changed from:


As a result lots of error 404 was dumped into my log file. I wrote a small php code to get rid of the problem:
[click to continue…]

Troubleshooting Lighttpd Chrooted RedHat PHP Version 5.1.6-20.el5_2.1

It appears that latest php version 5.1.6-20.el5_2.1 under RHEL / CentOS Linux v5.2 has made some major changes. As a result choort jail setup using previous instructions no longer works.

PHP is crashing with segmentation fault errors. So I had to trace php errors using strace command. After spending couple of hours I found solution for following errors:

Sep 15 03:26:59 lightyproxy kernel: php-cgi[19106]: segfault at 0000003151c1b4b8 rip 0000003151e98477 rsp 00007fff9ecdde20 error 6
Sep 15 03:26:59 lightyproxy kernel: php-cgi[19107]: segfault at 0000003151c1b4b8 rip 0000003151e98477 rsp 00007fff9ecdde20 error 6
Sep 15 03:26:59 lightyproxy kernel: php-cgi[19108]: segfault at 0000003151c1b4b8 rip 0000003151e98477 rsp 00007fff9ecdde20 error 6
Sep 15 03:26:59 lightyproxy kernel: php-cgi[19110]: segfault at 0000003151c1b4b8 rip 0000003151e98477 rsp 00007fff9ecdde20 error 6
WARNING! These examples / workaround is only for RHEL / CentOS 5.2 and not for Debian / Ubuntu / FreeBSD lighttpd chroot instructions.

You need to copy entire /etc/ and /usr/share/zoneinfo/ to jail. If your jail is located at /jail directory enter following commands:
# service lighttpd stop
# D=/path/to/chroot/jail
# mkdir /root/jail.etc
# /bin/cp -avr $D/etc/* /root/jail.etc
# /bin/cp -avr /etc/* $D/etc/

Copy back original customized files such as passwd, group, php.ini :
# cp -avr /root/jail.etc/* $D/etc/
Now copy /usr/share/zoneinfo/:
# cd $D/usr/share
# cp -avr /usr/share/zoneinfo/ .

Copy all latest php-cgi and all extensions to $D
# cd $D/usr/bin
# cp /usr/bin/php-cgi .
# l2chroot php-cgi

Copy php modules (for 64 bit use $D/usr/lib64):
# cd $D/usr/lib/
# cp -avr /usr/lib/php/ .
# cd php/modules
# for l in *.so; do l2chroot $l; done

Start lighttpd:
# service lighttpd start
This should fix all errors. Watch /var/log/messages for php errors:
# tail -f /var/log/messages

Download of The Day: WordPress 2.6

Wordpress Logo

WordPress 2.6 has been released and available for download almost a month ahead schedule. New
features in wordpress 2.6:

=> Wiki-like tracking of edits
=> Post from wherever you are on the web
=> Turbo-speed your blogging - Gears is an open source browser extension project started by Google that developers like us can use to give you features we wouldn’t normally be able to.
=> SSL login support
=> Theme Previews: See it before your audience does and much more

Download WordPress 2.6

=> Visit official download page.

Related: Upgrade wordpress quickly in 3 easy steps from UNIX shell prompt

How To Find Out If ISP Is Throttling BitTorrent Traffic

You can now easily determine if your ISP throttling and shaping Bittorrent traffi with simple online tool.

From the project web page:

Certain ISPs have been shown to rate limit or block BitTorrent traffic sent by their customers. While there are multiple reports of this on the web, only a few ISPs have admitted that they manipulate BitTorrent traffic. And, to date, it is hard for users without networking expertise to gain evidence about the behavior of their ISP.

This test suite creates a BitTorrent-like transfer between your machine and our server, and determines whether or not your ISP is limiting such traffic. This is a first step towards making traffic manipulation by ISPs more transparent to their customers.

=> Glasnost: Test if your ISP is manipulating BitTorrent traffic

You can also load this tool on your own server or laptop computer running Apache and PHP 4.3 or above:
$ cd /var/www/
$ sudo apt-get install libpcap0.8 libpcap0.8-dev
$ wget http://broadband.mpi-sws.mpg.de/transparency/glasnost-1.1.tgz
$ tar -zxvf glasnost-1.1.tgz
$ cd glasnost
$ make
$ su -c "chmod a+s bt_client"
$ mkdir logs
$ chmod 0777 logs

Fire a web browser and type http://localhost/glasnost/selftest.php or http://your-domain.com/glasnost/selftest.php

Updated for accuracy!

mod_compress: Lighttpd Gzip Compression To Improve Download and Browsing Speed

Gzip is the most popular and effective compression method. Most modern web browser supports and accepts compressed data transfer. By gziping response time can reduced by 60-70% as compare to normal web page. The end result is faster web site experience for both dial up (they're not dead yet - I've dial up account for backup purpose) and broadband user. I've already written about speeding up Apache 2.x web access or downloads with mod_deflate.

mod_compress for Lighttpd 1.4.xx

Lighttpd 1.4.xx supports gzip compression using mod_compress. This module can reduces the network load and can improve the overall throughput of the webserver. All major http-clients support compression by announcing it in the Accept-Encoding header as follows:

Accept-Encoding: gzip, deflate

If lighttpd sees this header in the request, it can compress the response using one of the methods listed by the client. The web server notifies the web client of this via the Content-Encoding header in the response:

Content-Encoding: gzip

This is used to negotiate the most suitable compression method. Lighttpd support deflate, gzip and bzip2.

Configure mod_compress

Open your lighttpd.conf file:
# vi /etc/lighttpd/lighttpd.conf
Append mod_compress to server.modules directive:
server.modules += ( "mod_compress" )
Setup compress.cache-dir to stored all cached file:
compress.cache-dir = "/tmp/lighttpdcompress/"
Finally, define mimetypes to get compressed. Following will allow to compress javascript, plain text files, css file,xml file etc:

compress.filetype           = ("text/plain","text/css", "text/xml", "text/javascript" )

Save and close the file. Create /tmp/lighttpdcompress/ file:
# mkdir -p /tmp/lighttpdcompress/
# chown lighttpd:lighttpd /tmp/lighttpdcompress/

Restart lighttpd:
# /etc/init.d/lighttpd restart

How do I enable mod_compress per virtual host?

Use conditional $HTTP host directive, for example turn on compression for theos.in:

$HTTP["host"] =~ "theos\.in" {
  compress.cache-dir = "/var/www/cache/theos.in/"

PHP dynamic compression

Open php.in file:
# vi /etc/php.ini
To compress dynamic content with PHP please enable following two directives:
zlib.output_compression = On
zlib.output_handler = On

Save and close the file. Restart lighttpd:
# service lighttpd restart

Cleaning cache directory

You need to run a shell script for cleaning out cache directory.

See also:

PHP Programming Tutorial: Merge and Filter RSS / Atom Feed With XQuery

I've already written about merging two feeds using MagpieRSS and FeedCreator php classes. However, I wasn't aware of XQuery query language that is designed to query collections of XML data. It seems similar to SQL. You can use XQuery to speed your merging and filtering of RSS / atom information (feed) easily. In this tutorial:

You will learn the basics of XQuery processing of RSS and Atom feeds to turn a single feed into an HTML document. Then you produced a more complete solution for outputting the information in a format that suits your needs, including sorting, merging multiple feeds and even handling different feed and source information types. XQuery makes it much easier to merge and filter information from XML documents when you embed the filtering instructions right into the document that you use to generate the output format. You can use that functionality to aggregate information from RSS and Atom feeds into the format you need. In this article, look at the structure of the RSS and Atom formats and how XQuery can simplify the display of that information.

=> Aggregate RSS and Atom information using XQuery

Coverity Scan: Security Holes Found in Open Source Projects

Coverity Logo

Coverity is a company that creates tools for software development. Its premiere product is Prevent, a static-analysis code inspection tool. Coverity offers the results of Prevent's analysis for free to open source developers.

From the project home page:

In collaboration with Stanford University, Coverity is establishing a new baseline for software quality and security in open source. Under a contract with the Department of Homeland Security, we apply the latest innovations in automated defect detection to uncover some of the most critical types of bugs found in software.

So the most notable use of Prevent is under a U.S. Department of Homeland Security contract, in which it is used to examine over 150 open source applications for bugs. Popular open source projects, such as Samba, the PHP, Perl, and Tcl dynamic languages used to bind together elements of Web sites, and Amanda, the popular open source backup and recovery software running on half a million servers, were all found to have dozens or hundreds of security exposures and quality defects.

For example, over 75% of the defects Scan identified in Samba were fixed within two reviews of the Scan analysis.
Over 75% of the defects Scan identified in Samba were fixed within two reviews of the Scan analysis.
(Fig. 01: Samba Project Code Scan Result)

=> More information about project and bugs (including charts) available at offical web site.

A total of 7,826 open source project defects have been fixed through the Homeland Security review, or one every two hours since it was launched in 2006, according to David Maxwell, open source strategist for Coverity, maker of the source code checking system, the Prevent Software Quality System, that's being used in the review.

This project is really helping out to improve overall open source software quality.