Archive for March, 2010

Memcached PHP

Posted in Technical on March 30th, 2010 by iyoung – Be the first to comment

Installing memcached for php on CentOS is as easy as: -

[code]

yum install memcached

yum install php-pecl-memcache

service httpd graceful

[/code]

Once installed you can start the memcached service as either a standalone service or as a daemon.

Run as any user other than root, starts as a normal process using up to 1 gig of RAM.

[code]

memcached -m1024

[/code]

Or as a daemon

[code]

memcached -d -m1024

[/code]

You can always get more info about memcached’s options with

[code]

man memcached

[/code]

PHP memcache documentation http://php.net/manual/en/book.memcache.php

Memcached’s site http://memcached.org/


Easter Egg Run 2010 Nottingham

Posted in Biking on March 28th, 2010 by iyoung – 1 Comment

Had a great day today on the Easter Egg run taking Easter eggs for disadvantaged kids. So many bikes of all kinds there, cruising along throughout Nottingham and out to Mansfield.

easter egg run

Bikes all gathering before departing on the Easter Egg run

Must have been thousands of bikes there, I suspect cars got a bit peeved hehe. The weather was perfect for it though and got me in the mood for riding for the rest of the day, went off for a cruise throughout the country lanes.


Ouchh!

Posted in Films on March 23rd, 2010 by iyoung – Be the first to comment

Finally had my wisdom tooth out, not had any dental work done before so was quite a shock hehe. Ah well it’s done now and I am chilling at home watching some classics starting with the original Italian job, probably then good ole great escape :D


Apache ReWrite proxy and spaces

Posted in Technical on March 16th, 2010 by iyoung – Be the first to comment

Passing the spaces in a URL through to another URL using a proxy style re-write in Apache can be a slight pain because as standard it basically cuts off the URL at the first space.

The answer is rather easy once you know how: -

[sourcecode language="bash"]
RewriteEngine ON
RewriteMap escape int:escape
RewriteRule ^/search/([^/]+)/?$       http://%{HTTP_HOST}/index.php?action=search&search_txt=${escape:$1} [P]
[/sourcecode]

In this example index.php should then receive whatever is after /search/ on the url until the next optional /


Gzip Compress Apache’s Output

Posted in Technical on March 9th, 2010 by iyoung – Be the first to comment

This has been described many times and in many ways by so many sites, but usually the descriptions are long and tedious. If you simply want to know how to get your website’s pages to be compressed if the browser supports it, or not if the browser doesn’t add the following lines to your Apache configuration file: -

[sourcecode language="bash"]
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
[/sourcecode]

Basically compress anything that can be compressed using the gzip algorithm ignore images because they are already compressed.

I put these directives within my Virtualhost but they could be just used in an .htaccess file I believe.

To test it is working, install the firefox web developers plugin, open your page, click the information drop down and select the option to view the page headers you should see something like: -

[sourcecode language="bash"]
Date: Tue, 09 Mar 2010 10:42:56 GMT
Server: Apache/2.2.x (SGI)
X-Powered-By: PHP/5.1.xx
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified: Tue, 09 Mar 2010 10:42:57 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip —– This being the item of interest
Content-Length: 12115
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from conway
Connection: keep-alive
200 OK

[/sourcecode]


Blogger to wordpress re-write

Posted in Films on March 1st, 2010 by iyoung – Be the first to comment

This may not be the best way to achieve this, but if you have set up some nice permalinks on your wordpress blog and have previously imported your blog from Blogger and want to maintain your links.

I set my permalinks to match my old blogger links i.e year month and blog title first, then I set my apache directory re-write rules as I have described before. Finally I added the following to the re-write

[sourcecode]

RewriteRule (.*).html[/]?$ http://%{HTTP_HOST}/$1/ [P]

[/sourcecode]

Just above the Rewrite conditions and re-write rule generated by word press. It just means that requests to the old flat HTML postings are properly re-directed to the new permalink postings.