<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Beyond the bits</title>
	<atom:link href="http://byte-consult.be/feed/" rel="self" type="application/rss+xml" />
	<link>http://byte-consult.be</link>
	<description>Crafting technology</description>
	<lastBuildDate>Wed, 09 May 2012 08:09:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Linode tproxy support missing</title>
		<link>http://byte-consult.be/2012/05/04/linode-tproxy-support-missing/</link>
		<comments>http://byte-consult.be/2012/05/04/linode-tproxy-support-missing/#comments</comments>
		<pubDate>Fri, 04 May 2012 20:42:57 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[linode haproxy]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=580</guid>
		<description><![CDATA[<p>In case you are getting this sort of error when setting up your box with iptable rules to support tproxy:</p> 12root@cartman:~# iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT iptables: No chain/target/match by that name. <p>That error is refering to the '-m socket' match. </p> <p>It seems that on certain kernels (linode [...]]]></description>
			<content:encoded><![CDATA[<p>In case you are getting this sort of error when setting up your box with iptable rules to support tproxy:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cartman:~<span style="color: #808080; font-style: italic;"># iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT</span><br />
iptables: No chain/target/match by that name.</div></td></tr></tbody></table></div>
<p>That error is refering to the '-m socket' match. </p>
<p>It seems that on certain kernels (linode kernels have no modules)  that <a href="http://linode.com">Linode</a> used to offer there is 1 small config parameter that they left unset.  Pretty weird since about everthing is on, I guess someone tried to prevent you from running your own <a href="http://haproxy.1wt.eu/">haproxy</a> install at one point.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cartman:~<span style="color: #808080; font-style: italic;"># <span style="color: #c20cb9; font-weight: bold;">zcat</span> /proc/config.gz | <span style="color: #c20cb9; font-weight: bold;">grep</span> </span><span style="color: #ff0000;">&quot;CONFIG_NETFILTER_TPROXY&quot;</span><br />
<span style="color: #808080; font-style: italic;"># CONFIG_NETFILTER_TPROXY is not set</span></div></td></tr></tbody></table></div>
<p>Apparently, the kernel I use isn't compiled with it, I really could have used it to solve a problem with ha-proxy (only used as a transparent tcp proxy, not as a true HA loadbalancer.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cartman:~<span style="color: #808080; font-style: italic;"># <span style="color: #c20cb9; font-weight: bold;">cat</span> /etc/lsb-release </span><br />
<span style="color: #007800;">DISTRIB_ID=</span>Ubuntu<br />
<span style="color: #007800;">DISTRIB_RELEASE=</span><span style="color: #000000;">10.04</span><br />
<span style="color: #007800;">DISTRIB_CODENAME=</span>lucid<br />
<span style="color: #007800;">DISTRIB_DESCRIPTION=</span><span style="color: #ff0000;">&quot;Ubuntu 10.04.4 LTS&quot;</span></div></td></tr></tbody></table></div>
<p>I guess this install is affected, I read about the fact that their latest kernels suppose have it but I'm reluctant to upgrade this very busy box and stop all the services.  Bummer but it will be without source ip's now .. Now I'm going to have to find out how to distinguish the loadbalancer backend checks from true proxied traffic.</p>
<p>Glenn</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2012/05/04/linode-tproxy-support-missing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Github and Bitbucket</title>
		<link>http://byte-consult.be/2012/04/26/github-vs-bitbucket/</link>
		<comments>http://byte-consult.be/2012/04/26/github-vs-bitbucket/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 09:45:34 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[bitbucket]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=531</guid>
		<description><![CDATA[<p></p> <p>If you found your way here Googling Github vs. Bitbucket instead of Bitbucket vs. Github, I forgive you. It was my natural instinct to type it up like that as well. Maybe I had some SEO tactics in my mind as well when I came up with this title. Anyway, if you came here [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://byte-consult.be/wp-content/uploads/2012/04/tempx1_western_showdown_g.jpg"><img class="alignleft size-thumbnail wp-image-533" title="Duel" src="http://byte-consult.be/wp-content/uploads/2012/04/tempx1_western_showdown_g-150x150.jpg" alt="cowboy's about to draw in a duel" width="150" height="150" /></a></p>
<p>If you found your way here Googling <strong><a href="https://github.com">Github</a> vs. <a href="https://bitbucket.org/">Bitbucket</a></strong> instead of <strong><a href="https://bitbucket.org/">Bitbucket</a> vs. <a href="https://github.com">Github</a></strong>, I forgive you.  It was my natural instinct to type it up like that as well.  Maybe I had some SEO tactics in my mind as well when I came up with this title.   Anyway, if you came here to find out about <a href="https://www.google.com/#hl=en&amp;safe=off&amp;output=search&amp;q=github+vs+bitbucket&amp;oq=github+vs+bitbucket&amp;fp=1">yet another</a> comparison between both services, you are at the wrong place.  <a href="http://www.pocoo.org/~blackbird/github-vs-bitbucket/bitbucket.html">Some people have very strong opinions</a> about this.  Most points are moot I think, encounting the fact that <a href="https://github.com">Github</a> itself releases their code to the people, and I have a good guess they don't just to that so you can admire their indenting styles.   I have to warn you in advance, i copied a lot of titles from <a href="http://37signals.com/rework/">R E W O R K</a>, on purpose.</p>
<p>Everyone copies everyone(<em>ssssshht, I myself nicked the cowboys image there</em>).  Sharing knowledge depends on that.  I'm just here to say I like <a href="https://bitbucket.org/">BitBucket</a> a lot.  This is a totally biased post, in fact I still use them both but as so many people are saying, I put my own private code at <a href="https://bitbucket.org/">Bitbucket</a>, since I get free private repos there.  I'm not earning a single Euro with that work, and I want to keep it offsite somewhere private and safe.</p>
<h3>Underdo your competition</h3>
<p>I don't believe they are fishing in the same pond either, <a href="https://bitbucket.org/">Bitbucket</a> looks more commercial, which is fine with me.  <a href="https://github.com">Github</a> is more social, that's a fact.  But nothing keeps <a href="https://bitbucket.org/">Bitbucket</a> from becoming more social.   They have a very nice product line.   They seem to realize that small companies who don't want to shell out -yet another- small amount for another single service somewhere have a tight budget.  This gives space to grow, becoming larger and establishing a long term relationship with them.  If that is the whole idea behind it, I'm all for it.</p>
<p>To illustrate, an average software company who's into outsourcing instead of putting up their own servers would need:</p>
<ol>
<li> A support portal (e.g.<a href="http://www.fogcreek.com/fogbugz/">FogBugz</a>)</li>
<li> Project tools (e.g. a <a href="http://trac.edgewall.org/">Trac</a> alike service somewhere)</li>
<li> A CRM (e.g. <a href="www.sugarcrm.com">Sugar CRM</a>)</li>
<li> File service (Google drive)</li>
<li> Source code repository (<a href="https://github.com">Github</a>, <a href="https://bitbucket.org/">Bitbucket</a>)</li>
<li> Your own website</li>
<li> Your Email</li>
<li> .... and so on</li>
</ol>
<p>I could just go on and on mentioning every service we all know we use everyday,  the point is that if you need to shell out just a few euro/dollars per month on each service,  you eventually spend much more than the most basic <a href="http://www.linode.com/">Linode VPS</a> who will do this all if you aren't too big and choose the correct software.  All it takes is someone to configure/set it up once.   You select a backup plan for 'a few dollars', ironically <img src='http://byte-consult.be/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Now you have piece of mind.  Either that or put it all on Google Apps.  Which would turn my stomach around thinking I would have to hand it all over to them...</p>
<h2>Who cares what they're doing?</h2>
<p>So why is this relevant, I think someone at <a href="https://bitbucket.org/">Bitbucket</a> must have thought about this and realised, even if it's a small price, it is yet another cost per month.  They stack up.  I'm not claiming that a VPS is better or that you should do what I explained here above.  It's just a matter of doing the PRO/CONTRA thing.</p>
<p>As I said, this is just an opinion.  My personal feelings on both services is that I actually really like <a href="https://bitbucket.org/">Bitbucket</a>, they still need to document more, <a href="https://github.com">Github</a> has a lot of docs about using their service.   Some suggested git commands didn't work right away, which can be confusing for beginners.    One big difference between them is that <a href="https://github.com">Github</a> only does Git.  I moved 2 repos to <a href="https://bitbucket.org/">Bitbucket</a>, and they work well.  I expect nothing more.</p>
<p>I have a few problems with <a href="https://github.com">GitHub</a>.  When free users and all those useless forks out there grind the service to a halt, paying users get their share of the outage.  (Try forking <a href="https://github.com/twain47/Nominatim">Nominatim</a>, that thing is huge, I forked it, just to analyse their updated code since 2 years against my own local patches, send back a fix or 2).  Countless of people are saying this, just Google it, don't believe me like that.</p>
<h2>Decommoditize your product</h2>
<p>Another problem I have is the whole, <em><strong>you copied me, evil you</strong></em> attitude.  It sounds soooo evil when not being used in the same sentence along with <strong>open source</strong>. Go read <a href="http://37signals.com/rework/">REWORK</a> and stop feeling bad, learn how to train yourself to not look at the competition and keep doing what you do best.   I really doesn't bother me.  I find both a basic site, and <a href="https://github.com">Github</a> has a relatively nice interface, why would <a href="https://bitbucket.org/">Bitbucket</a> make something entirely different?  To hassle their users ?  Why does almost every webmail client look basically the same with some juicy CSS mojo?   Because they are built around the same service AND people expect them to be function more or less in the same manner.</p>
<h2>Take a deep breath</h2>
<p>Now in general I noticed the following strategy coming up from users:</p>
<p><em><strong>"I use <a href="http://github.com">Github</a> for my public repos, and <a href="https://bitbucket.org/">Bitbucket</a> for my own small private projects"</strong></em>.  I think that is a clear signal.  That I read almost everywhere in the comments sections of a <a href="https://www.google.com/#hl=en&amp;safe=off&amp;output=search&amp;q=github+vs+bitbucket&amp;oq=github+vs+bitbucket&amp;fp=1">Github VS. Bitbucket</a> post.</p>
<p>But the biggest thing I hate about <a href="https://github.com">Github</a> is that their search functionality sucks like hell.  I can find a single variable in some source code line but I cannot find my own repos back using their search.  It's probably at page 2967 in the results set.  Well that's because you give result priority to what's in the code, rather than whats in the README.* file(s).</p>
<p>Try finding my repo using "reverse geocoding" knowing it's written in PHP.  It will be 'everything' or 'repositories' and I cannot find it within 15 minutes.   Those are the <strong>first 2 words</strong> in my <strong>README.md</strong> file.   So yea, I think their search engine sucks.  To be fair, I can't find it back at <a href="https://bitbucket.org/">Bitbucket</a> either but I only checked it in for an hour when I tried it, maybe an indexer needs to roll over it first.  I'll try again though.</p>
<p>Another bad idea is to show popular repos first.  Now let me fill you in on a secret: nobody goes to look for a popular repo on github.  They already know it's there and it's probably hyperlinked thousands of times on the web.   You find that back with a search engine.  The reason I want a decent search functionality, is for the unpopular little tool I won't have to write myself later on, but given a fork I can build upon work of others.   I do NOT want to know what's popular, I want to know what repo matches my keywords the closest.   If I can't find it in the first place, there is not much community left out there.</p>
<h2>Out-teach your competition</h2>
<p>Remember the days that when you wanted some small piece of software, you either went to <a href="freshmeat.net">freshmeat.net</a> or <a href="http://sourceforge.net/">sourceforge.net</a> ?  You just slammed in your Nokia type number and you discovered how many packages could be used for a potential SMS daemon.  Just an example to say, a good search function is essential to a good service like this.   <a href="https://github.com">Github</a> is a search mess.</p>
<p>And still, I'm a fan of both.  They live next to each other, on the first 2 screens that pop open when I start Chrome.  It's truly Ironic that the ones claiming to be open source minded have a <em>.com</em> domain and the ones that are more commercial use the <em>.org</em> one.  Nothing seems to beat free.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2012/04/26/github-vs-bitbucket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dell Vostro 1700 &#8211; Disable Touchpad on fail</title>
		<link>http://byte-consult.be/2012/01/08/dell-vostro-1700-disable-touchpad-on-fail/</link>
		<comments>http://byte-consult.be/2012/01/08/dell-vostro-1700-disable-touchpad-on-fail/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:53:15 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[ALPS Touchpad]]></category>
		<category><![CDATA[Vostro]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=506</guid>
		<description><![CDATA[<p>Today I was typing up a mail, the second I hit send in my mail client, my mouse pointer starts to shake and jump slowly but annoyingly enough to make it unworkable, I suspected that my 10 year old IntellyEye mouse went on life-support but when I unplugged it, it was still happening, also when [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was typing up a mail, the second I hit <em>send</em> in my mail client, my mouse pointer starts to shake and jump slowly but annoyingly enough to make it unworkable,   I suspected that my 10 year old IntellyEye mouse went on life-support but when I unplugged it, it was still happening, also when I moved to another USB port. (I have 5 of them to try).</p>
<p>Somehow my touchpad caused all this.  So I had to disable it entirely in Ubuntu.  It's really easy to do so:</p>
<div class="codecolorer-container ini default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@crashy:~# xinput list<br />
⎡ Virtual core pointer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">2</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>master pointer &nbsp;<span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
⎜ &nbsp; ↳ Virtual core XTEST pointer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">4</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;pointer &nbsp;<span style="">&#40;</span><span style="">2</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
⎜ &nbsp; ↳ Microsoft Microsoft <span style="">5</span>-Button Mouse with IntelliEye<span style="">&#40;</span>TM<span style="">&#41;</span> &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">9</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;pointer &nbsp;<span style="">&#40;</span><span style="">2</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
⎜ &nbsp; ↳ PS/<span style="">2</span> Mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">12</span> &nbsp; <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;pointer &nbsp;<span style="">&#40;</span><span style="">2</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
⎜ &nbsp; ↳ AlpsPS/<span style="">2</span> ALPS GlidePoint &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">13</span> &nbsp; <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;pointer &nbsp;<span style="">&#40;</span><span style="">2</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
⎣ Virtual core keyboard &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">3</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>master keyboard <span style="">&#40;</span><span style="">2</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Virtual core XTEST keyboard &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">5</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Video Bus &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">6</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Power Button &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">7</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Sleep Button &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">8</span> &nbsp; &nbsp;<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Laptop Integrated Webcam &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">10</span> &nbsp; <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ AT Translated Set <span style="">2</span> keyboard &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">11</span> &nbsp; <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span><br />
&nbsp; &nbsp; ↳ Dell WMI hotkeys &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000099;">id</span>=<span style="color: #660066;"><span style="">14</span> &nbsp; <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>slave &nbsp;keyboard <span style="">&#40;</span><span style="">3</span><span style="">&#41;</span><span style="">&#93;</span></span></span></div></td></tr></tbody></table></div>
<p>If one of the lines mentions a touchpad or glidepoint (perhaps also "Synaptics" or "ALPS"), your touchpad has been detected.  For me that is ID 13. On the command line, as the user who's logged into X-windows you do:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;"># xinput set-prop <span style="color: #000000;">13</span> </span><span style="color: #ff0000;">&quot;Device Enabled&quot;</span> <span style="color: #000000;">0</span></div></td></tr></tbody></table></div>
<p>And the touchpad is disabled, this works right away.  My problem was gone, and my TouchPad too, I don't used it anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2012/01/08/dell-vostro-1700-disable-touchpad-on-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading multiple files using PHP Curl</title>
		<link>http://byte-consult.be/2011/11/14/uploading-multiple-files-using-php-curl/</link>
		<comments>http://byte-consult.be/2011/11/14/uploading-multiple-files-using-php-curl/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 01:50:52 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=455</guid>
		<description><![CDATA[<p>Only yesterday I was debating post title's with Niki Van Cleemput claiming to him that I believed all sort and makes of people should fully comprehend what the post is all about by reading the title. He rebutted that a bit by saying he's not targeting an audience like that but instead he's focused on [...]]]></description>
			<content:encoded><![CDATA[<p>Only yesterday I was debating post title's with <a href="http://nikivancleemput.com">Niki Van Cleemput</a> claiming to him that I believed all sort and makes of people should fully comprehend what the post is all about by reading the title.  He rebutted that a bit by saying he's not targeting an audience like that but instead he's focused on people who are already down into the subject.   Both are true I guess and do not mutually exclude each other.  I kinda target an audience that needs a push here and there, so rudely spoken, know less than I do at the moment.  I just want to return the favour after 26 six years into computers getting help from others taking the time to figure stuff out with me.</p>
<p>This article is a prequel to another one, which will be storing those uploaded binary files into <a href="http://couchdb.org">CouchDB</a> backend. These files reside on remote machines and will be uploaded to the target server which will stock, create a CRC code and use that to store them in uniquely in a CouchDB database. I was about to post one big article when I realised that finding how to upload files with a PHP Curl client program isn't really easy to find and deserves it's own post.</p>
<h3>Enable file uploads for PHP</h3>
<p>I'm using <a href="http://nginx.org">nginx</a> (of course), so this means I have <a href="http://php-fpm.org/">php-fpm</a> running.  Hence any change that I have to make to PHP will NOT be in the <strong>cli</strong> nor the <strong>apache2</strong> subdirectories on the Debian family of supreme operating systems.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">drwxr-xr-x &nbsp;<span style="color: #000000;">7</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">16</span>:<span style="color: #000000;">44</span> ./<br />
drwxr-xr-x <span style="color: #000000;">82</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-11</span> <span style="color: #000000;">14</span>:<span style="color: #000000;">02</span> ../<br />
drwxr-xr-x &nbsp;<span style="color: #000000;">2</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">17</span> apache2/<br />
drwxr-xr-x &nbsp;<span style="color: #000000;">2</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">17</span>:<span style="color: #000000;">16</span> cgi/<br />
drwxr-xr-x &nbsp;<span style="color: #000000;">2</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">17</span>:<span style="color: #000000;">19</span> cli/<br />
drwxr-xr-x &nbsp;<span style="color: #000000;">2</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">18</span> conf.d/<br />
drwxr-xr-x &nbsp;<span style="color: #000000;">2</span> root root <span style="color: #000000;">4096</span> <span style="color: #000000;">2011</span><span style="color: #000000;">-11</span><span style="color: #000000;">-08</span> <span style="color: #000000;">17</span>:<span style="color: #000000;">17</span> fpm/<br />
root@cartman:/etc/php5<span style="color: #808080; font-style: italic;">#</span></div></td></tr></tbody></table></div>
<p>As you can see: it's in the <strong>fpm</strong> subdirectory.  How handy is that!   If that doesn't work for you for some weird reason you should try the <strong>cgi</strong> one next.  Search for a section called <em>File Uploads</em> in the php.ini file in that subdir.  Check if the parameters allow you to upload a file of the size you will be trying AND check if the target temp directory exists, is writable by the nginx user (www-data) and is filled out in the config.  Glance over the other settings too.</p>
<div class="codecolorer-container ini default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">;;;;;;;;;;;;;;;;</span><br />
<span style="color: #666666; font-style: italic;">; File Uploads ;</span><br />
<span style="color: #666666; font-style: italic;">;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #666666; font-style: italic;">; Whether to allow HTTP file uploads.</span><br />
<span style="color: #666666; font-style: italic;">; http://php.net/file-uploads</span><br />
<span style="color: #000099;">file_uploads </span>=<span style="color: #660066;"> On</span><br />
<br />
<span style="color: #666666; font-style: italic;">; Temporary directory for HTTP uploaded files (will use system default if not</span><br />
<span style="color: #666666; font-style: italic;">; specified).</span><br />
<span style="color: #666666; font-style: italic;">; http://php.net/upload-tmp-dir</span><br />
<span style="color: #000099;">upload_tmp_dir </span>=<span style="color: #660066;"> /var/www/nginx-default/uploads</span><br />
<br />
<span style="color: #666666; font-style: italic;">; Maximum allowed size for uploaded files.</span><br />
<span style="color: #666666; font-style: italic;">; http://php.net/upload-max-filesize</span><br />
<span style="color: #000099;">upload_max_filesize </span>=<span style="color: #660066;"> 2M</span><br />
<br />
<span style="color: #666666; font-style: italic;">; Maximum number of files that can be uploaded via a single request</span><br />
<span style="color: #000099;">max_file_uploads </span>=<span style="color: #660066;"> <span style="">20</span></span></div></td></tr></tbody></table></div>
<p>You will also want to protect that directory a bit since it is under the webroot, depending on your level of protections, you can set these in nginx.conf inside a <em><strong>server</strong></em> section :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;"># Just deny directory listing <span style="color: #7a0874; font-weight: bold;">&#40;</span>usually the default is no and you need to allow it explicitly<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
&nbsp; &nbsp; &nbsp; location /var/www/nginx-default/incoming <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;autoindex off;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># or you can totaly deny this <span style="color: #7a0874; font-weight: bold;">&#40;</span>and I suggest to <span style="color: #000000; font-weight: bold;">do</span> so<span style="color: #7a0874; font-weight: bold;">&#41;</span> access to the client</span><br />
&nbsp; &nbsp; &nbsp; location /var/www/nginx-default/incoming <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deny all;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;access_log off; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;log_not_found off;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>If that is all ok , restart <em>php-fpm</em> and now you are ready to create a script that will accept those files.  When I test stuff I always try to not customize too much with subdirs and other things that might screw my work up forcing me to focus on tangent instead of my actual goal.  Later on, I think about deploying it decently.  Good code is easy to throw around.</p>
<p>So, just navigate to the nginx-default webroot and create the scripts we use here and directories in there (incoming / uploaded ) etc.:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;"># <span style="color: #7a0874; font-weight: bold;">cd</span> /var/www/nginx-default</span><br />
<span style="color: #808080; font-style: italic;"># <span style="color: #c20cb9; font-weight: bold;">mkdir</span> incoming</span><br />
<span style="color: #808080; font-style: italic;"># <span style="color: #c20cb9; font-weight: bold;">mkdir</span> uploaded</span></div></td></tr></tbody></table></div>
<p>Pay attention for file permissions too.</p>
<h3>Create php code to accept the files</h3>
<p>I want to make one thing clear first, I do <strong>NOT</strong> support putting make-up into code at all.  In fact what we are doing here is create an API between couchDB and a client.  The API here will be in PHP,  the client too since I will be using PHP Curl.  This is not needed, most people should know that the client can be anything.   I'm just working on some things that require this, so this approach will be used in real life although with more detailed proper coding.</p>
<p>The reason there's HTML inside my PHP file this time is for reasons of debugging.  The upload mechanism inside PHP is kinda strange to comprehend for a newbee.   But even an experienced programmer that never focussed on this before will probably raise some eyebrow figuring out where in the hell that uploaded file went.  Also, if you haven't actually written that curl client, you can't test with it yet.  So at first, we will be using our browser to create the backend script first, once we know that works, we will dig into the client.  And in the last phase once the files are able to arrive at the destination we will introduce these into couchDB.  That sure sounds like a plan, perhaps not how others would to it, but having a plan is a good thing.  If you fail to plan, your plan will fail.</p>
<p>So let's create this backend.   We will call it <strong>upload.php</strong> since we feel so inspired today.  Since this is no pre-school class, I'm not going to explain this line per line but I will point out later where you need to pay attention to.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<br />
<span style="color: #000066;">error_reporting</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">E_ALL</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000066;">ini_set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'memory_limit'</span>, <span style="color: #ff0000;">'20M'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000066;">ini_set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;upload_max_filesize&quot;</span>, <span style="color: #ff0000;">&quot;1M&quot;</span><span style="color: #66cc66;">&#41;</span>; &nbsp;<span style="color: #808080; font-style: italic;">// This is per file apparantly</span><br />
<span style="color: #000066;">ini_set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;post_max_size&quot;</span>, <span style="color: #ff0000;">&quot;2M&quot;</span><span style="color: #66cc66;">&#41;</span>; <br />
<br />
<span style="color: #0000ff;">$allowed_extensions</span> = <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;txt&quot;</span>,<span style="color: #ff0000;">&quot;csv&quot;</span>,<span style="color: #ff0000;">&quot;htm&quot;</span>,<span style="color: #ff0000;">&quot;html&quot;</span>,<span style="color: #ff0000;">&quot;xml&quot;</span>, <span style="color: #ff0000;">&quot;css&quot;</span>,<span style="color: #ff0000;">&quot;doc&quot;</span>,<span style="color: #ff0000;">&quot;xls&quot;</span>,<span style="color: #ff0000;">&quot;rtf&quot;</span>,<span style="color: #ff0000;">&quot;ppt&quot;</span>,<span style="color: #ff0000;">&quot;pdf&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;swf&quot;</span>,<span style="color: #ff0000;">&quot;flv&quot;</span>,<span style="color: #ff0000;">&quot;avi&quot;</span>, <span style="color: #ff0000;">&quot;wmv&quot;</span>,<span style="color: #ff0000;">&quot;mov&quot;</span>,<span style="color: #ff0000;">&quot;jpg&quot;</span>,<span style="color: #ff0000;">&quot;jpeg&quot;</span>,<span style="color: #ff0000;">&quot;gif&quot;</span>,<span style="color: #ff0000;">&quot;png&quot;</span><span style="color: #66cc66;">&#41;</span>; <br />
<span style="color: #0000ff;">$target_dir</span> = <span style="color: #ff0000;">&quot;incoming&quot;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">// so we don't have to apply makeup</span><br />
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;&lt;pre&gt;&quot;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">// Just fix that silly $_FILES layout and never look back</span><br />
fix_files_superglobal<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<br />
<span style="color: #808080; font-style: italic;">/* I will not be handing out too much information to the end user about the upload progress, if it fails I want <br />
&nbsp; &nbsp;that to happen silently, which is why we can nest these checks like below without else's<br />
&nbsp;*/</span><br />
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_FILES</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_FILES</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// always double check web input </span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">strlen</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'tmp_name'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0</span> and <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'error'</span><span style="color: #66cc66;">&#93;</span> === UPLOAD_ERR_OK<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// I just like shorter notations</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$source_file</span> = <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;tmp_name&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$target_file</span> = <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$file_size</span> = <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;size&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Uploaded file '%s' accepted<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #0000ff;">$target_file</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;Size was: &quot;</span> . display_filesize<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file_size</span> / <span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Extra security step, see the PHP manual for these functions!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">is_uploaded_file</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$source_file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;File comes from a POST operation, that is ok<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Find the dot in the name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$dot_pos</span> = &nbsp;strripos<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$target_file</span>, <span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// strip extention, one could alternatively use preg_split here instead or even path_info</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$file_basename</span> = <span style="color: #000066;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$target_file</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #0000ff;">$dot_pos</span><span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$file_ext</span> &nbsp; &nbsp; &nbsp;= <span style="color: #000066;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$target_file</span>, <span style="color: #0000ff;">$dot_pos</span><span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Alternatives:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// $file_ext = pathinfo($target_file, PATHINFO_EXTENSION); </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// $file_ext = strrchr($target_file, '.'); &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Do not use explode, it doesn't handle filenames like foobar-1.1.1.tar gracefully</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// You definitely don't want to use split(), this function has been DEPRECATED as of PHP 5.3.0</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Is there an extension at all since we require one! </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file_ext</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Accepted extensions are: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #000066;">implode</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$allowed_extensions</span>,<span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// See if this type of file is allowed according to our list above</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">in_array</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file_ext</span>, <span style="color: #0000ff;">$allowed_extensions</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Extension accepted : %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #0000ff;">$file_ext</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Ok, now we are pretty much sure that about everything is in order. </span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Prepend a path to the cleaned target file name </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$save_file</span>=<span style="color: #0000ff;">$target_dir</span> . DIRECTORY_SEPARATOR . clean_name<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$target_file</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// if you don't call this function it will not be saved at all</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">file_exists</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$save_file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Saving to filename : %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #0000ff;">$save_file</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">move_uploaded_file</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$source_file</span>, <span style="color: #0000ff;">$save_file</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">echo</span> <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Not overwriting existing filename : %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<span style="color: #0000ff;">$save_file</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <br />
<span style="color: #66cc66;">&#125;</span> <br />
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;&lt;/pre&gt;&quot;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">/* Fixes the messed up array doing multiple file uploads using a single array post var like : file[1], file[2] */</span><br />
<span style="color: #000000; font-weight: bold;">function</span> fix_files_superglobal<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #0000ff;">$new_files</span> = <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp;<span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_FILES</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$key</span> =&gt; <span style="color: #0000ff;">$attributes</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// echo sprintf(&quot;%s =&gt; %s&quot;, $key , $attributes);</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$attributes</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$tagname</span> =&gt; <span style="color: #0000ff;">$tags</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// echo sprintf(&quot;%s =&gt; %s\n&quot;, $tagname , $val);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">is_array</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$tags</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$file_key</span> =&gt; <span style="color: #0000ff;">$value</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$new_files</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$file_key</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$tagname</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$value</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* Only copy this back if we have content, when we don't we are dealing with<br />
&nbsp; &nbsp; &nbsp; a single file or form fields not like file[f1], file [f2], but just plain 'file' */</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #000066;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$new_files</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$_FILES</span> = <span style="color: #0000ff;">$new_files</span>;<br />
&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> display_filesize<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filesize</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">is_numeric</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filesize</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$decr</span> = <span style="color: #cc66cc;">1024</span>; <span style="color: #0000ff;">$step</span> = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$prefix</span> = <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Byte'</span>,<span style="color: #ff0000;">'KB'</span>,<span style="color: #ff0000;">'MB'</span>,<span style="color: #ff0000;">'GB'</span>,<span style="color: #ff0000;">'TB'</span>,<span style="color: #ff0000;">'PB'</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filesize</span> / <span style="color: #0000ff;">$decr</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0.9</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$filesize</span> = <span style="color: #0000ff;">$filesize</span> / <span style="color: #0000ff;">$decr</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$step</span>++;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000066;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filesize</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">' '</span>.<span style="color: #0000ff;">$prefix</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$step</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">'NaN'</span>;<br />
&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> clean_name <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #808080; font-style: italic;">/* - remove extra spaces/convert to _,<br />
&nbsp; &nbsp;- remove non 0-9a-Z._- characters,<br />
&nbsp; &nbsp;- remove leading/trailing spaces */</span><br />
&nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$safe_filename</span> = <span style="color: #000066;">preg_replace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/<span style="color: #000099; font-weight: bold;">\s</span>+/&quot;</span>, <span style="color: #ff0000;">&quot;/[^-<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\w</span>]+/&quot;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;_&quot;</span>, <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000ff;">$name</span><span style="color: #66cc66;">&#41;</span>; <br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;html&gt;<br />
&nbsp; &nbsp;&lt;title&gt;Testing multiple <span style="color: #000066;">file</span> upload functions&lt;/title&gt;<br />
&nbsp; &nbsp;&lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;form action=<span style="color: #ff0000;">&quot;upload.php&quot;</span> method=<span style="color: #ff0000;">&quot;post&quot;</span> enctype=<span style="color: #ff0000;">&quot;multipart/form-data&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;label <span style="color: #b1b100;">for</span>=<span style="color: #ff0000;">&quot;file&quot;</span>&gt;Filename:&lt;/label&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=<span style="color: #ff0000;">&quot;file&quot;</span> name=<span style="color: #ff0000;">&quot;file1&quot;</span> id=<span style="color: #ff0000;">&quot;file1&quot;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=<span style="color: #ff0000;">&quot;file&quot;</span> name=<span style="color: #ff0000;">&quot;file2&quot;</span> id=<span style="color: #ff0000;">&quot;file2&quot;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=<span style="color: #ff0000;">&quot;submit&quot;</span> name=<span style="color: #ff0000;">&quot;submit&quot;</span> value=<span style="color: #ff0000;">&quot;Submit&quot;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />
&nbsp; &nbsp;&lt;/body&gt;<br />
&lt;/html&gt;</div></td></tr></tbody></table></div>
<p>If you happen to see an error like this you have a permission problem or you are trying to move a file from outside the webserver, make sure you keep the directories involved in the document root and not below.  This is very hard to figure out if you don't.  Ownership of the directories should be the same as the one running nginx, by default <strong>www-data.</strong></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> <span style="color: #7a0874; font-weight: bold;">&#91;</span>error<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">32194</span><span style="color: #808080; font-style: italic;">#<span style="color: #000000;">0</span>: *<span style="color: #000000;">7</span> FastCGI sent <span style="color: #000000; font-weight: bold;">in</span> stderr: </span><span style="color: #ff0000;">&quot;PHP Warning: &nbsp;move_uploaded_file(file1.ext): <br />
failed to open stream: Permission denied in ....</span></div></td></tr></tbody></table></div>
<p>Once that is all set up the backend should work and we can start creating the curl client. This one is actually really easy.  Notice the @ before the filename, that one is golden as that will make it send the file content.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #808080; font-style: italic;">// same as &lt;input type=&quot;file&quot; name=&quot;file[one]&quot;&gt; in the frontend</span><br />
<span style="color: #0000ff;">$post</span> = <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;file[one]&quot;</span>=&gt;<span style="color: #ff0000;">&quot;@file1.ext&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;file[two]&quot;</span>=&gt;<span style="color: #ff0000;">&quot;@file2.ext&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #0000ff;">$url</span>=<span style="color: #ff0000;">&quot;http://cartman/upload.php&quot;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">/* Do it with curl */</span><br />
<span style="color: #0000ff;">$ch</span> = curl_init<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_HEADER, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_VERBOSE, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_RETURNTRANSFER, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_USERAGENT, <span style="color: #ff0000;">&quot;Mozilla/4.0 (compatible;)&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_POST, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span>, CURLOPT_POSTFIELDS, <span style="color: #0000ff;">$post</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">// Now exec it</span><br />
<span style="color: #0000ff;">$server_output</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$curlinfo</span> = curl_getinfo<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">// This is great for debugging, like this you can see everyting the backend script pumps out</span><br />
<span style="color: #000066;">print_r</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$server_output</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">// Check this if you want info concerning the transfer</span><br />
<span style="color: #000066;">print_r</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$curlinfo</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ch</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>By now this should already work now, send it 2 files to test this.  My uploads are working at this point.</p>
<h3>$_FILES is flawed</h3>
<p>Another thing you need to be aware of, when using square brackets in your input name form attributes to group the properties of your object you are screwed.  $_FILES then creates an array where the properties of your uploaded files become properties of your named object and the properties you were expecting become properties of the uploaded file properties.</p>
<p>Like this:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">file<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3366CC;">&quot;file1.ext&quot;</span><br />
file<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #3366CC;">&quot;file2.ext&quot;</span></div></td></tr></tbody></table></div>
<p>will create a $_FILES array in the receiving php script as</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Array<br />
<span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>file<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000066;">name</span><span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> =&gt; file1.<span style="color: #006600;">ext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> =&gt; file2.<span style="color: #006600;">ext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>type<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> =&gt; application/octet-stream<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> =&gt; application/octet-stream<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>tmp_name<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #0066FF;">/<span style="color: #003366; font-weight: bold;">var</span>/www/nginx-<span style="color: #003366; font-weight: bold;">default</span>/uploads/</span>phpZSKUdw<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #0066FF;">/<span style="color: #003366; font-weight: bold;">var</span>/www/nginx-<span style="color: #003366; font-weight: bold;">default</span>/uploads/</span>phpbbE4j9<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>error<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>size<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">374</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">374</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span></div></td></tr></tbody></table></div>
<p>It doesn't take a genius to figure out that this is screwed and totally non-logical to do so.   We would rather have:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Array<br />
<span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>file1<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000066;">name</span><span style="color: #66cc66;">&#93;</span> =&gt; file1.<span style="color: #006600;">ext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>type<span style="color: #66cc66;">&#93;</span> =&gt; application/octet-stream<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>tmp_name<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #0066FF;">/<span style="color: #003366; font-weight: bold;">var</span>/www/nginx-<span style="color: #003366; font-weight: bold;">default</span>/uploads/</span>phpeGWPpg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>error<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>size<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">374</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>file2<span style="color: #66cc66;">&#93;</span> =&gt; Array<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000066;">name</span><span style="color: #66cc66;">&#93;</span> =&gt; file2.<span style="color: #006600;">ext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>type<span style="color: #66cc66;">&#93;</span> =&gt; application/octet-stream<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>tmp_name<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #0066FF;">/<span style="color: #003366; font-weight: bold;">var</span>/www/nginx-<span style="color: #003366; font-weight: bold;">default</span>/uploads/</span>phpeGWPpg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>error<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>size<span style="color: #66cc66;">&#93;</span> =&gt; <span style="color: #CC0000;">374</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span></div></td></tr></tbody></table></div>
<p>The function<em> fix_files_superglobal()</em> is created for that, I've seen ton's of difficult approaches handling this conversion but my solution is more bullet-proof than most.  I wasn't satisfied with what I could use from others so I wrote this.</p>
<p>I hope this was helpful for someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/11/14/uploading-multiple-files-using-php-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tuning MariaDB 5.2 with Partitioned tables</title>
		<link>http://byte-consult.be/2011/11/07/tuning-mariadb-5-2-with-partitioned-tables/</link>
		<comments>http://byte-consult.be/2011/11/07/tuning-mariadb-5-2-with-partitioned-tables/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 22:09:38 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mariadb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=411</guid>
		<description><![CDATA[<p>If you want to set up a decent MariaDB machine with enough tables to seriously keep you awake at night thinking about backup/restore plans, you need to perform some additional setup to the stock MariaDB configuration file. I just started to load up a backup of a large database and once it had to create [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to set up a decent <a href="http://mariadb.org">MariaDB</a> machine with enough tables to seriously keep you awake at night thinking about backup/restore plans, you need to perform some additional setup to the stock MariaDB configuration file.  I just started to load up a backup of a large database and once it had to create partitioned tables I was met with a mysqld crash.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ERROR <span style="color: #cc66cc;">1005</span> <span style="color: #66cc66;">&#40;</span>HY000<span style="color: #66cc66;">&#41;</span> at line <span style="color: #cc66cc;">19</span> <span style="color: #993333; font-weight: bold;">IN</span> file: <span style="color: #ff0000;">'Mobility_dakendeur_schema.sql'</span>: Can<span style="color: #ff0000;">'t create table '</span>Mobility.dakendeur<span style="color: #ff0000;">' (errno: 1)<br />
Query OK, 0 rows affected (0.00 sec)<br />
MariaDB [Mobility]&gt; show errors;<br />
+-------+------+------------------------------------------------------------+<br />
| Level | Code | Message &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
+-------+------+------------------------------------------------------------+<br />
| Error | 1005 | Can'</span>t <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'Mobility.dakendeur'</span> <span style="color: #66cc66;">&#40;</span>errno: <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; |<br />
| Error | &nbsp; &nbsp;<span style="color: #cc66cc;">6</span> | Error <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">DELETE</span> of <span style="color: #ff0000;">'./Mobility/dakendeur.par'</span> <span style="color: #66cc66;">&#40;</span>Errcode: <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> |<br />
+<span style="color: #808080; font-style: italic;">-------+------+------------------------------------------------------------+</span></div></td></tr></tbody></table></div>
<p>In order to get <a href="http://mariadb.org">MariaDB</a> 5.2 to work with restoring partitioned files you will need a whole lot of open files available.  When you see this in the logs:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Nov &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">57</span> localhost mysqld: <span style="color: #000000;">111105</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">57</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ERROR<span style="color: #7a0874; font-weight: bold;">&#93;</span> mysqld got signal <span style="color: #000000;">6</span> ;<br />
Nov &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">57</span> localhost mysqld: InnoDB: Error number <span style="color: #000000;">24</span> means <span style="color: #ff0000;">'Too many open files'</span>.<br />
Nov &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">55</span>:<span style="color: #000000;">20</span> localhost mysqld: <span style="color: #000000;">111105</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">55</span>:<span style="color: #000000;">20</span> &nbsp;InnoDB: Error creating <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'./Mobility/dakendeur#P#p1570.ibd'</span>.<br />
Nov &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">55</span>:<span style="color: #000000;">20</span> localhost mysqld: <span style="color: #000000;">111105</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">55</span>:<span style="color: #000000;">20</span> &nbsp;InnoDB: Operating system error number <span style="color: #000000;">24</span> <span style="color: #000000; font-weight: bold;">in</span> a <span style="color: #c20cb9; font-weight: bold;">file</span> operation.<br />
Nov &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">54</span>:<span style="color: #000000;">03</span> localhost mysqld: <span style="color: #000000;">111105</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">54</span>:<span style="color: #000000;">03</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Warning<span style="color: #7a0874; font-weight: bold;">&#93;</span> Aborted connection <span style="color: #000000;">70</span> to db: <span style="color: #ff0000;">'Mobility'</span> <br />
user: <span style="color: #ff0000;">'root'</span> host: <span style="color: #ff0000;">'localhost'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Got an error reading communication packets<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>If you have a quite some partitioned tables (with a few hundred per table ), you are going to need a lot of open files.  Mysqld crashes with a signal 6 if it hits the limit.   To bring order to chaos, you need to set some limits.  I've had success with these:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>mysqld<span style="color: #66cc66;">&#93;</span><br />
...<br />
innodb_file_per_table &nbsp; = <span style="color: #cc66cc;">1</span><br />
innodb_open_files &nbsp; &nbsp; &nbsp; = <span style="color: #cc66cc;">16000</span></div></td></tr></tbody></table></div>
<p>In fact, if you have that first option set, you're gonna need a whole lot of files.  You'll waste diskspace too but in my experience you gain quite some performance and avoid locks.  These work fine for me (with a 8GB <a href="http://linode.com">VPS</a>).</p>
<p>Also, set the general file limit high enough, for me at the moment, this is about 4 times the amount of open files with a loaded DB.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>mysqld<span style="color: #66cc66;">&#93;</span><br />
...<br />
open-files-<span style="color: #993333; font-weight: bold;">LIMIT</span> = <span style="color: #cc66cc;">65535</span></div></td></tr></tbody></table></div>
<p>I also switch off the following engines for memory and stability issues:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>mysqld<span style="color: #66cc66;">&#93;</span><br />
...<br />
skip-pbxt<br />
skip-archive<br />
skip-pbxt_statistics</div></td></tr></tbody></table></div>
<p>pbxt saves me a good chunk of memory, I found that using partitioned archive tables is really unstable so I switch them off for now (I do like archive being read-only but I cannot use those for now).</p>
<p>For finetuning my installation I do some tweaks, I'm on a VPS with write-back cache on the disks.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>mysqld<span style="color: #66cc66;">&#93;</span><br />
...<br />
innodb_flush_log_at_trx_commit = <span style="color: #cc66cc;">2</span><br />
innodb_flush_method &nbsp; &nbsp; = O_DIRECT</div></td></tr></tbody></table></div>
<p>and than specifically for <a href="http://www.percona.com/software/percona-xtradb/">XtraDB</a> (One more reason to take <a href="http://mariadb.org">MariaDB</a> over stock Mysql).</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>mysqld<span style="color: #66cc66;">&#93;</span><br />
...<br />
<span style="color: #808080; font-style: italic;"># XTRADB</span><br />
innodb_fast_recovery = <span style="color: #cc66cc;">1</span><br />
innodb_read_ahead=none<br />
innodb_ibuf_active_contract = <span style="color: #cc66cc;">1</span><br />
innodb_adaptive_flushing = <span style="color: #cc66cc;">0</span><br />
innodb_adaptive_checkpoint = estimate</div></td></tr></tbody></table></div>
<p>This about does it for me, I'm still playing with the memory sizes and the innodb buffer cache.  </p>
<p>im trying :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">innodb_buffer_pool_size = 6G<br />
innodb_additional_mem_pool_size = 64M</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/11/07/tuning-mariadb-5-2-with-partitioned-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MariaDB &#8211; ERROR 130 (HY000): Incorrect file format</title>
		<link>http://byte-consult.be/2011/09/23/mariadb-error-130-hy000-incorrect-file-format/</link>
		<comments>http://byte-consult.be/2011/09/23/mariadb-error-130-hy000-incorrect-file-format/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 12:18:09 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[mariadb]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=405</guid>
		<description><![CDATA[<p>We have had an issue the last 2 days with a table that apeared corrupt. Selecting from this table returns an error all the sudden. Since upgrading to MariaDB 5.2 a few weeks ago we had this twice. So far only moderated panic applies. I've never seen this since the start of this project which [...]]]></description>
			<content:encoded><![CDATA[<p>We have had an issue the last 2 days with a table that apeared corrupt.  Selecting from this table returns an error all the sudden.  Since upgrading to <a href="http://downloads.askmonty.org/mariadb/">MariaDB 5.2</a> a few weeks ago we had this twice.  So far only moderated panic applies.   I've never seen this since the start of this project which is almost 5 years now and only since this upgrade.  I couldn't find any Maria related bugs using google nor the bugtracker.  Could this one be new ?  We are planning an 64bit upgrade soon so I'm wondering if this would eliminate this from happening after that.  Hope is a better word.</p>
<h2>Moderately busy runtime table stopped working</h2>
<p> - Problem turned out to be a DB error.<br />
 - ERROR 130 (HY000): Incorrect file format<br />
 - Worked fine for weeks.  No reports of corruption in Error logs so far on these.</p>
<h3>Platform</h3>
<p> - running <a href="http://downloads.askmonty.org/mariadb/">5.2.8-MariaDB-mariadb102 </a>- debian-linux-gnu on i486<br />
 - 32bit (mem/64bit upgrade in process of waiting for hardware)<br />
 - Signal 11 problem we have since MySql 5.1. Coredumps not configured in kernel so we can only guess at this point.<br />
 - Not very busy (cpu use is very low on average)</p>
<h3>Symptoms of the problem</h3>
<p> - The tables seem to stop functioning all the sudden, repair doesn't work.<br />
 - show create doesn't work but truncate table does recreate it correctly(?)<br />
 - happened twice in 2 days (among a pack of ~ 150 similar tables in design and functionality)<br />
 - lots of updates<br />
 - few inserts<br />
 - about 40 records per table on average<br />
 - Problem only apeared after switching over to <a href="http://downloads.askmonty.org/mariadb/">MariaDB 5.2</a><br />
 - Last time the database came down with Signal 11 when hitting it hard with repairs.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MariaDB <span style="color: #66cc66;">&#91;</span>traceme<span style="color: #66cc66;">&#93;</span>&gt; <span style="color: #993333; font-weight: bold;">SHOW</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> LastSeen_h;<br />
ERROR <span style="color: #cc66cc;">130</span> <span style="color: #66cc66;">&#40;</span>HY000<span style="color: #66cc66;">&#41;</span>: Incorrect file format <span style="color: #ff0000;">'LastSeen_h'</span></div></td></tr></tbody></table></div>
<h3>Schema</hr>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`LastSeen_h`</span> <span style="color: #66cc66;">&#40;</span><br />
&nbsp; <span style="color: #ff0000;">`imei`</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastComms`</span> timestamp <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CURRENT_TIMESTAMP,<br />
&nbsp; <span style="color: #ff0000;">`eventDate`</span> timestamp <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00 00:00:00'</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventState`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventLon`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventLat`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventDelta`</span> time <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventRecordid`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventIO`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`eventSwitch`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastDate`</span> timestamp <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00 00:00:00'</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastState`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastLon`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastLat`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastRecordid`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastIO`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #ff0000;">`lastSwitch`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`imei`</span><span style="color: #66cc66;">&#41;</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`Index_date1`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`imei`</span>,<span style="color: #ff0000;">`lastComms`</span><span style="color: #66cc66;">&#41;</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`Index_date2`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`imei`</span>,<span style="color: #ff0000;">`eventDate`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE=Aria <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 PAGE_CHECKSUM=<span style="color: #cc66cc;">1</span></div></td></tr></tbody></table></div>
<h3>Solution (none so far)</h3>
<p> - We have no real solution so far but to drop/create the table.  We are lucky as this data is being cached in sqlite so we just reimport and the customers are back online.  We do not have this happen on tables that do a lot of inserts.  We have other aria tables that are very important to us with severely processed data (takes a lot of time to recreate those).<br />
 - truncate works too but I find this weird since 'show create table' doesn't.  I prefer to drop it first (which works too) and create it again.</p>
<h3>Anyone else have this since using <a href="http://downloads.askmonty.org/mariadb/">MariaDB 5.2</a>?</h3>
<p> - We only had this happen twice but my gut feeling is that something is up with Aria.  (I've upgraded this server from MariaDB 5.1).  This went fine at the time.  Since then we have restored this DB from backups except 'mysql' database which we ended up fixing and cleaning first but those are Isam so I don't think they matter.<br />
- I love to hear if anyone has the same experience. </p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/09/23/mariadb-error-130-hy000-incorrect-file-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenStreetMap and Bing</title>
		<link>http://byte-consult.be/2011/08/21/openstreetmap-aerial-coverage-bing/</link>
		<comments>http://byte-consult.be/2011/08/21/openstreetmap-aerial-coverage-bing/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 08:39:55 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[OpenStreetMaps]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=390</guid>
		<description><![CDATA[<p>Since a few months I dove into the mapping thing like a mad man. Having access to tons of geodata makes that really fun and rewarding. Playing with JOSM I've really wondered why they could use aerial imagery Bing data for OpenStreetMaps. So I went to search for what the licenses where all about.</p> <p>I [...]]]></description>
			<content:encoded><![CDATA[<p>Since a few months I dove into the mapping thing like a mad man.  Having access to tons of geodata makes that really fun and rewarding.  Playing with <a href="http://josm.openstreetmap.de/">JOSM</a> I've really wondered why they could use aerial imagery <a href="http://www.bing.com/maps/">Bing data</a> for <a href="http://www.openstreetmap.org/">OpenStreetMaps</a>.   So I went to search for what the licenses where all about.</p>
<p>I quote from the Wiki:</p>
<blockquote><p>
Bing have declared that we are allowed to trace from their aerial imagery for OpenStreetMap.<br />
You are not allowed to copy from Bing's streetmaps - only their aerial imagery (i.e. the overhead pictures taken from a plane or satellite). Streetnames and other names are not part of the aerial imagery, and may not be copied.
</p></blockquote>
<p>Turns out that Bing actually gave permission to be used for OSM entries.  NOT by copying the maps itself but using the aerial for vectorizing buildings - for instance - is perfectly Ok.</p>
<p>I think this needs a double thumbs up.  Being so Microsoft, I think that is way cool that they decided that.  I'm sure there are benefits for them as well (like when they use OSM vector data themselves).  But still, coming from the Microsoft gang...  that's an admirable quality <a href="http://nl.wikipedia.org/wiki/Tuvok">Tuvok</a> would say.</p>
<p>It's really helpful too.  Bing is also the one that has the least detailed and correct data, I noticed this when I wrote a <a href="http://byte-consult.be/code-corner/">reverse geocoding class</a> so I guess they've put 2 and 2 together by now and could very well be thinking about merging OSM data on a deeper level besides just offering <a href="http://www.bing.com/community/site_blogs/b/maps/archive/2010/08/02/bing-maps-adds-open-street-maps-layer.aspx">an OSM layer</a> and donating some vector data back to the OSM community.</p>
<p>Collaboration like this should be applauded upon, whatever the business reasons are behind it.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/08/21/openstreetmap-aerial-coverage-bing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL is cool</title>
		<link>http://byte-consult.be/2011/08/07/working-with-postgresql/</link>
		<comments>http://byte-consult.be/2011/08/07/working-with-postgresql/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 20:23:13 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[Cassandra]]></category>
		<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[Gazetteer]]></category>
		<category><![CDATA[OpenStreetMaps]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[mariadb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=384</guid>
		<description><![CDATA[Hellow Postgres <p>One of the things MySQL forced me into is looking for serious alternatives. Finding MariaDB was an amazing relief. But it's still not all cake and cookies yet. I experiment a lot with OpenStreetMaps lately, a great project everyone of all makes should look into seeing what it can do for you and [...]]]></description>
			<content:encoded><![CDATA[<h3>Hellow Postgres</h3>
<p>One of the things <a href="http://www.mysql.com/">MySQL</a> forced me into is looking for serious alternatives.  Finding <a href="http://mariadb.org">MariaDB</a> was an amazing relief.  But it's still not all cake and cookies yet.   I experiment a lot with <a href="http://www.openstreetmap.org/">OpenStreetMaps</a> lately, a great project everyone of all makes should look into seeing what it can do for you and vice versa.   This is where we step into the PostgreSQL realm. Almost all about <a href="http://www.openstreetmap.org/">OSM</a> is backed by <a href="http://www.postgresql.org/">PostgreSQL</a><br />
I've built <a href="http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification">Tile</a> and <a href="http://en.wikipedia.org/wiki/Gazetteer">Gazetteer</a> services to provide maps an geocoding features.  This put me in the spot I had to get to know <a href="http://www.postgresql.org/">PostgreSQL</a>.<br />
Like a lot of early hour <a href="http://www.mysql.com">MySQL</a> fans I kept far to the left side of <a href="http://www.postgresql.org/">PostgreSQL</a> for as long as I can remember.  I didn't need it, it was for strange, weird techies.  Even more than me.   As if admitting I L.O.V.E working with<a href="http://en.wikipedia.org/wiki/Vi"> vi(m) </a>is not enough.</p>
<p>But now we are probably all on an awesome inspiring path, ready to choose our next idol.  With the rising of new sort of mainstream technologies(=what lots of people can use instead of a few) that perform, it's exiting to see that <a href="http://www.postgresql.org/">PostgreSQL</a> is so stable and useful. Not only do we have stuff like <a href="http://cassandra.apache.org/">Cassandra</a>, <a href="http://couchdb.apache.org/">CouchDB</a> and <a href="http://nginx.org">Nginx</a> ready for production for some time.  There's a place for old school solid stuff. </p>
<p>Anyway, so after a few weeks I'm loving the damn thing.  I need to get used to it a bit more.  Specifically those shorthand commands.   But it's so fast if you do everything right.    I'm actually able to tune it now running fast with not-so-smart options set and I actually NOTICED the results of it for a change.</p>
<p>I had a power failure on one of the machine I was building a giant DB on and re-indexing gazetteer fails now,  so trying to repair <a href="http://www.postgresql.org/">postgresql DB</a> is just an awesome way into getting to know the inner workings.<br />
I'm very pleased with it, I will sure use it more.  The <a href="http://postgis.refractions.net/">PostGIS</a> stuff is kick-ass.   Even the crash was predicted by the manual and the fact that I have some nasty corruption preventing me from completing the <a href="http://en.wikipedia.org/wiki/Gazetteer">gazetteer</a> indexing.  I'm still trying to make the best from it, it's not THAT critical so I want to cease the opportunity to look at some of the nastiest error messages in <a href="http://www.postgresql.org/">postgreSQL</a> <img src='http://byte-consult.be/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3>So, here's a few things I learned along the way</h3>
<p> - Dig into <strong>VACUUM FULL VERBOSE ANALYSE</strong>.  It's a cornerstone of fixing/keeping the DB.<br />
 - <strong>REINDEX TABLE</strong>.  Same here, it's a lifesaver.<br />
 - Depending on YOUR version (do the google thing), set this:  <strong>zero_damaged_pages = true</strong>  , if it isn't set yet and you want to fix stuff you need this in your <em>postgresql.conf</em></p>
<h3>Doing it for all tables</h3>
<p>I really love this oneliner too:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">FOR</span> tbl <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #ff0000;">`psql -qAt -c &quot;select tablename from pg_tables where schemaname = 'public';&quot; gazetteer`</span> ; do psql -c <span style="color: #ff0000;">&quot;REINDEX TABLE $tbl&quot;</span> -d gazetteer; done</div></td></tr></tbody></table></div>
<p>Or</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">FOR</span> tbl <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #ff0000;">`psql -qAt -c &quot;select tablename from pg_tables where schemaname = 'public';&quot; gazetteer`</span> ; do psql -c <span style="color: #ff0000;">&quot;alter table $tbl owner to <span style="color: #000099; font-weight: bold;">\&quot;</span>www-data<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> gazetteer; done</div></td></tr></tbody></table></div>
<p>That last one comes from the <a href="http://en.wikipedia.org/wiki/Gazetteer">Gazetteer</a> install wiki page for ubuntu.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/08/07/working-with-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NGINX powered by NGINX</title>
		<link>http://byte-consult.be/2011/07/20/nginx-powered-by-nginx/</link>
		<comments>http://byte-consult.be/2011/07/20/nginx-powered-by-nginx/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 10:07:18 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=370</guid>
		<description><![CDATA[A company around NGINX is on the horizon. [...]]]></description>
			<content:encoded><![CDATA[<h1>Corporate support is there</h1>
<p>Very exiting times, head over to <a href="http://www.nginx.org/">nginx.org</a> for the heads-up.  I think this is a great move for the future of NGINX.   Corporate Doubters, now there's no more reason to not consider this elegant, fast webserver.</p>
<blockquote><p>
Our primary goals are improving support and communication for our users, streamlining the development process, revamping the documentation, integrating and speeding up pending bugfixes and patches, introducing long-requested functionality and more.
</p></blockquote>
<p>See the full statement at <a href="http://www.nginx.org/">nginx.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/07/20/nginx-powered-by-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>W3 Total Cache plugin</title>
		<link>http://byte-consult.be/2011/06/27/w3-total-cache-plugin/</link>
		<comments>http://byte-consult.be/2011/06/27/w3-total-cache-plugin/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 02:31:48 +0000</pubDate>
		<dc:creator>glenn</dc:creator>
				<category><![CDATA[G-WAN]]></category>
		<category><![CDATA[W3TC]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://byte-consult.be/?p=202</guid>
		<description><![CDATA[W3 Total Cache <p>This post describes my experiences with the W3 Total Cache (w3tc) plugin in relation to my nginx install. I have bumped against a few hiccups along the way that I want to share. It all started when I took up ab, the apache benchmark tool. I wanted to see how this nginx [...]]]></description>
			<content:encoded><![CDATA[<h1>W3 Total Cache</h1>
<p><a href="http://byte-consult.be/wp-content/uploads/2011/06/no_speed_limit_badge.png"><img class="alignleft size-thumbnail wp-image-256" title="no_speed_limit_badge" src="http://byte-consult.be/wp-content/uploads/2011/06/no_speed_limit_badge-150x150.png" alt="" width="150" height="150" /></a>This post describes my experiences with the <a href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">W3 Total Cache</a> (w3tc) plugin in relation to my <a href="http://nginx.org/" target="_blank">nginx</a> install.  I have bumped against a few hiccups along the way that I want to share.  It all started when I took up <a href="http://httpd.apache.org/docs/2.0/programs/ab.html"><em>ab</em></a>, the apache benchmark tool.  I wanted to see how this <a href="http://nginx.org/" target="_blank">nginx</a> powered website performed with the spawn-fci and <a href="http://mariadb.org" target="_blank">mariaDB</a> setup.  Along the way I wanted to exploit the amazing ability of <a href="http://nginx.org/" target="_blank">nginx</a> to deliver static files.  It's just really good at that so I wanted to start caching the thing after seeing very poor performance due to the regular load of php cgi,  I had a mission all the sudden.</p>
<h2>My slick nginx powered wordpress is slow</h2>
<p>Some simple benchmarks taken at various points, I tried 3 different cache plugins, <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3TC</a> as the third and it's still running now (although I reinstalled it once).   The first benchmark below, is the <em>'before cache'</em> one, no improvements yet done, besides running on <a href="http://mariadb.org" target="_blank">mariaDB</a> tables instead of innodb,  switching off revisions in wordpress and running on <a href="http://nginx.org/" target="_blank">nginx</a>.  Notice the number of failed ones...</p>
<h3>Before the makeover</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">glenn@crashy:~$ ab -c5 -n200 http://byte-consult.be/<br />
Finished <span style="color: #000000;">200</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">5</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">62.473</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">200</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">45</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">3.20</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1561.826</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">312.365</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">99.25</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<p>This is just plain insulting,<strong> 3.2/s</strong> is crap!  Admittedly  I'm on the <a href="http://linode.com" target="_blank"><strong>Linode 768</strong></a> plan but still, these guys are great at what they do so I believe I can do better here with their/my resources.</p>
<p>I tried <a href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank">SuperCache plugin</a> with static pages.  Configuring this for <a href="http://nginx.org/" target="_blank">nginx</a> proved to be a pain in the butt.  I took a benchmark with static file caching right before un-installing this.  I didn't like the way it worked for me. No nginx support.   Still, the performance was about the same as with <a href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">W3TC</a>.</p>
<h3>With SuperCache plugin</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Finished <span style="color: #000000;">200</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">5</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">6.438</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">200</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">31.07</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">160.946</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">32.189</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1242.66</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<p>I'm not going to mention the other cache plugin, it was total crap, let's not waste our time on it.  So time to move to <a href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">WT3C</a>.  After installation, switching the <em>page cache</em> with <em>disk advanced</em> mode to on.</p>
<h3>With wt3c plugin</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">glenn@crashy:~$ ab -c5 -n200 http://byte-consult.be/<br />
Finished <span style="color: #000000;">200</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">5</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">6.376</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">200</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">31.37</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">159.403</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">31.881</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1256.03</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<p>As you can see here, there is not too much difference between the two, but we aren't done yet.  When logging into the<em> WP Admin</em> page I see a <em>Performance</em> section at the left bottom under <em>Settings</em>.  That is new.  I like seeing everything belonging to a single goal in the same place.  I've had a big issue in getting this page to load by the way but that is food for later.  Once I put a workaround in place for this issue I could use it.</p>
<p>I see lot's of support for goodies I like.   For example <a href="http://memcached.org/" target="_blank">memcached</a> support.  For this small site using <a href="http://memcached.org/" target="_blank">memcached</a> seems like a done deal, I have memory left over I can put to use.  So I decided I want object/query caching done in <a href="http://memcached.org/" target="_blank">memcached</a>, I'll select that, put some bigger values in the caching (5 minutes=300sec) and <em>Deploy</em> it.  Let's pimp the tests up a bit ...</p>
<h3>With more threads</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">glenn@crashy:~$ ab -c50 -n1000 http://byte-consult.be/<br />
Finished <span style="color: #000000;">1000</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">50</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">20.244</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1000</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">49.40</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1012.204</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">20.244</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1977.86</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<h3>Caching on for objects/queries with memcached</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">glenn@crashy:~$ ab -c50 -n200 http://byte-consult.be/<br />
Benchmarking byte-consult.be <span style="color: #7a0874; font-weight: bold;">&#40;</span>be patient<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Finished <span style="color: #000000;">200</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">50</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">4.005</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">200</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">49.94</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">1001.295</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">20.026</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1923.44</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<p>Professionally, I have had issues with <a href="http://memcached.org/" target="_blank">memcached</a> with trying to store larger  values that what most typical uses would.  I've used it outside the web  context for years now but I've seen some issues with it along the way.  Still, I don't expect  any problems when using it here, for what it was intended for in the first place,  which is beefing up sites like they are <a href="http://www.dukenukem.com"><strong id="yui_3_3_0_1_1309125973981218">Duke Nukem's</strong></a> on steroids.  I'm at <strong>50/s</strong> now using Page + Object + Query caching.</p>
<h3>From a faster connection with tuning/bugfixes</h3>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">obosql003:~<span style="color: #808080; font-style: italic;"># ab -c50 -n200 http://byte-consult.be/</span><br />
Finished <span style="color: #000000;">200</span> requests<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">50</span><br />
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests: &nbsp; <span style="color: #000000;">1.982</span> seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;<span style="color: #000000;">200</span><br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span><br />
Requests per second: &nbsp; &nbsp;<span style="color: #000000;">100.90</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #808080; font-style: italic;">#/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span></span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">495.548</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Time per request: &nbsp; &nbsp; &nbsp; <span style="color: #000000;">9.911</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">3963.52</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes/sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received</div></td></tr></tbody></table></div>
<h3>Much better!</h3>
<p>That looks really good there, <strong>100/s</strong>!!!  Does everyone agree that this benchmark is totally not complete nor do I claim it is.  It's just that.... erm.   The difference is overwhelming.  It's a <strong>factor 50</strong> faster than before the makover....  Even the worst benchmarks get some of it right.</p>
<h3>Now about those bugs I fixed along the way</h3>
<h4>The timout problem</h4>
<p>A hanging <em>Performance</em> tab, <em>only on nginx</em>.  When I clicked anything in that new <em>Performance</em> tab, the whole thing would hang for a while and then time out.   I've investigated this at the <strong>mysql</strong> level,  at the <strong>php</strong>-cgi level and the <strong>nginx</strong> level.  With the latter two I have <a href="http://en.wikipedia.org/wiki/Strace" target="_blank"><em>strace</em></a> 'd those processes. If you have this issue after installing the plugin you need to put this workaround in the following file : <em>wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php</em></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">test_rewrite_pgcache</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
...<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Find this line (for me at line 1781), and change this to</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
...<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>You don't want to have it call <em>$this-&gt;test_rewrite_pgcache() .</em> It made things time-out and I don't know why.  What it do know is that it makes a special call to the nginx webserver that looks like this <strong>GET /w3tc_rewrite_test</strong>. It's a test.</p>
<p>In the nginx access log file I see :</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006666;">178.79</span><span style="color:#006666;">.156</span><span style="color:#006666;">.25</span> - <span style="color:#996600;">&quot;GET /w3tc_rewrite_test HTTP/1.1&quot;</span> <span style="color:#006666;">504</span> <span style="color:#006666;">183</span> <span style="color:#996600;">&quot;-&quot;</span> <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span><br />
<span style="color:#006666;">178.79</span><span style="color:#006666;">.156</span><span style="color:#006666;">.25</span> - <span style="color:#996600;">&quot;GET /w3tc_rewrite_test HTTP/1.0&quot;</span> <span style="color:#006666;">200</span> <span style="color:#006666;">2</span> <span style="color:#996600;">&quot;-&quot;</span> <span style="color:#996600;">&quot;Wget/1.12 (linux-gnu)&quot;</span></div></td></tr></tbody></table></div>
<p>This is where it get's interesting, I noticed that right after that call to nginx it goes south. (you  see the <strong>504</strong> there).  When I call this from my browser or with <a href="http://www.gnu.org/software/wget/" target="_blank"><em>wget</em></a>, it works perfectly(as per status <strong>200</strong>).  All it does is return '<strong>OK</strong>', which sounds really easy to handle.  But for some reason that whole thing doesn't get back.  So it just doesn't work when <a href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">W3TC</a> requests it coming from PHP, it does work on every other occasion, by hand this time.  As stated previously, it's just a test, a check to see if you have the <em>rewrite</em> rules in place on <a href="http://nginx.org/" target="_blank">nginx</a>.  The request matches the following rewrite rule from the <a href="http://nginx.org/" target="_blank">nginx</a> config:</p>
<div><a href="http://byte-consult.be/wp-content/uploads/code/nginx/nginx_wp.conf" style="float: right; margin-right: 5px;">Download</a>
<pre class="ruby">      <span style="color:#008000; font-style:italic;"># BEGIN W3TC Page Cache core</span>
      rewrite ^<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#9900CC;">*</span>\/<span style="color:#006600; font-weight:bold;">&#41;</span>?w3tc_rewrite_test$ $<span style="color:#006666;">1</span>?w3tc_rewrite_test=<span style="color:#006666;">1</span> last;
&nbsp;</pre>
</div>
<p>So now it knows you have that rule there.  What it concludes from there on is too much trouble to find out and boring too once I fixed this call anyway.   The panel loaded in a blink of an eye after that.  I have an <a href="http://byte-consult.be/wp-content/uploads/code/nginx/php_admin_strace.out">example php-cgi strace dump</a> here for the curious. Check out what happens after this line:</p>
<div><a href="http://byte-consult.be/wp-content/uploads/code/nginx/php_admin_strace.out" style="float: right; margin-right: 5px;">Download</a>
<pre class="perl"><a href="http://perldoc.perl.org/functions/send.html"><span style="color: #000066;">send</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">7</span>, <span style="color: #ff0000;">&quot;GET /w3tc_rewrite_test HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span>..., <span style="color: #cc66cc;">107</span>, MSG_NOSIGNAL<span style="color: #66cc66;">&#41;</span> = <span style="color: #cc66cc;">107</span>
&nbsp;</pre>
</div>
<p>Anyway, I managed to get the rules written to the config before that panel started locking up (you can run it once before you switch page caching on). But I'm pretty confident I have every needed rule in my <a href="http://byte-consult.be/wp-content/uploads/code/nginx/nginx_wp.conf" target="_blank">nginx.conf</a> already now.  I just  wanted that panel to work so I can configure the rest of the cache.  Thus,  I switched off  that test by changing those particular lines.</p>
<h4>Memcache md5 problem</h4>
<p>Another issue I noticed, and this one is I think a bug is the definition of the <a href="http://memcached.org/" target="_blank">memcached</a> instance key, basically to make your <em>key = value</em> pair unique.   Take a look at this code from <em>wp-content/plugins/w3-total-cache/lib/W3/Cache.php</em>. This is what happens when you implode a nested array.  Implode doesn't handle them as per <a href="http://php.net/manual/en/function.implode.php">php documentation</a>.  Now it becomes unpredictable, and it sure looks like it needs to be predictable.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">// this doesn't work on nested arrays</span><br />
<span style="color: #0000ff;">$instance_key</span> = <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'%s_%s'</span>, <span style="color: #0000ff;">$engine</span>, <span style="color: #000066;">md5</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">implode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>You get this error if you try:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Notice: Array to string conversion <span style="color: #000000; font-weight: bold;">in</span> <br />
/usr/share/wordpress/wp-content/plugins/w3-total-cache/lib/W3/Cache.php on line <span style="color: #000000;">52</span> Array <span style="color: #7a0874; font-weight: bold;">&#40;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>servers<span style="color: #7a0874; font-weight: bold;">&#93;</span> =&gt; Array <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =&gt; <span style="color: #000000;">127.0</span><span style="color: #000000;">.0</span><span style="color: #000000;">.1</span>:<span style="color: #000000;">11211</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>persistant<span style="color: #7a0874; font-weight: bold;">&#93;</span> =&gt; <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>So I replaced this with <em>json_encode</em> , perfectly designed to handle this kind of an <em>Array</em></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">$instance_key</span> = <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'%s_%s'</span>, <span style="color: #0000ff;">$engine</span>, <span style="color: #000066;">md5</span><span style="color: #66cc66;">&#40;</span>json_encode<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>I've tried to find if there is any other place in the code that would generate this and one other file popped up: <em>/usr/share/wordpress/wp-content/plugins/w3-total-cache/lib/W3/Cdn.php</em>. You should fix this issue in there too. Another warning message will be gone which <a href="http://byte-consult.be/2011/06/15/spawn-fcgi-troubles/" target="_blank">spawn-fcgi</a> doesn't like here.</p>
<h4>Other fixes</h4>
<p>I also fixed all calls to <em>deprecated</em> functions in lots of plugins I have running.  I've also fixed a bug in the <em>Raindrop</em> template I'm currently using as well that made my permalinks to "/tag/%s/"  URL locations to be wrongfully generated due to a wrong function call to an non-existing function.   And lastly I also fixed an issue in <a href="http://piwik.org/" target="_blank">PiWik</a>, the analytics software I'm using that threw a warning on every hit.  In the plugin <em>wp-content/plugins/piwik-analytics/piwikanalytics.php</em> line: 256</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">function_exists</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;get_option&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<span style="color: #808080; font-style: italic;">//if ($wp_siteid_takes_precedence)</span><br />
<span style="color: #0000ff;">$options</span>  = get_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'PiwikAnalyticsPP'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$siteid</span> = <span style="color: #0000ff;">$options</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'siteid'</span><span style="color: #66cc66;">&#93;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>Since <em>$wp_siteid_takes_precedence</em> is nowhere to be found in the code it arrives there uninitialised and throws a warning.  Finding from where that variable should come and why it's unknown at that point in the code is going to take me too much time so I commented it out, which looks like the right choice.  Bit off topic but while we are at it we might as well dump all.</p>
<p>Lots like these :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Notice: has_cap was called with an argument that is deprecated since version <span style="color: #000000;">2.0</span>! <br />
Usage of user levels by plugins and themes is deprecated. Use roles and capabilities <br />
instead. <span style="color: #000000; font-weight: bold;">in</span> /usr/share/wordpress/wp-includes/functions.php on line <span style="color: #000000;">3321</span></div></td></tr></tbody></table></div>
<p>and those</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Notice: attribute_escape is deprecated since version <span style="color: #000000;">2.8</span>! Use esc_attr<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> instead. <br />
<span style="color: #000000; font-weight: bold;">in</span> /usr/share/wordpress/wp-includes/functions.php on line <span style="color: #000000;">3237</span></div></td></tr></tbody></table></div>
<p>Although I don't think the last one is related to this plugin. It was part of a bunch of fixes.</p>
<h3>The rewrite rules for nginx</h3>
<h4>W3TC Page Cache</h4>
<div><a href="http://byte-consult.be/wp-content/uploads/code/nginx/nginx_wp.conf" style="float: right; margin-right: 5px;">Download</a>
<pre class="ruby">      <span style="color:#008000; font-style:italic;"># BEGIN W3TC Page Cache cache</span>
      location ~ /wp-content/w3tc/pgcache.<span style="color:#9900CC;">*html</span>$ <span style="color:#006600; font-weight:bold;">&#123;</span>
         add_header X-Powered-By <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span>;
         add_header Vary <span style="color:#996600;">&quot;Accept-Encoding, Cookie&quot;</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
      location ~ /wp-content/w3tc/pgcache.<span style="color:#9900CC;">*gzip</span>$ <span style="color:#006600; font-weight:bold;">&#123;</span>
         gzip off;
         types <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
         default_type text/html;
         add_header X-Powered-By <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span>;
         add_header Vary <span style="color:#996600;">&quot;Accept-Encoding, Cookie&quot;</span>;
         add_header Content-Encoding gzip;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#008000; font-style:italic;"># END W3TC Page Cache cache</span>
&nbsp;</pre>
</div>
<h4>W3TC Browser Cache</h4>
<div><a href="http://byte-consult.be/wp-content/uploads/code/nginx/nginx_wp.conf" style="float: right; margin-right: 5px;">Download</a>
<pre class="ruby">      <span style="color:#008000; font-style:italic;"># BEGIN W3TC Browser Cache</span>
      gzip on;
      gzip_types text/css application/x-javascript text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
      location ~ \.<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span>css</span>|js<span style="color:#006600; font-weight:bold;">&#41;</span>$ <span style="color:#006600; font-weight:bold;">&#123;</span>
            add_header X-Powered-By <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      location ~ \.<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span>html</span>|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml<span style="color:#006600; font-weight:bold;">&#41;</span>$ <span style="color:#006600; font-weight:bold;">&#123;</span>
            add_header X-Powered-By <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      location ~ \.<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span>asf</span>|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip<span style="color:#006600; font-weight:bold;">&#41;</span>$ <span style="color:#006600; font-weight:bold;">&#123;</span>
            add_header X-Powered-By <span style="color:#996600;">&quot;W3 Total Cache/0.9.2.3&quot;</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#008000; font-style:italic;"># END W3TC Browser Cache</span>
&nbsp;</pre>
</div>
<h4>W3TC Page Cache core</h4>
<div><a href="http://byte-consult.be/wp-content/uploads/code/nginx/nginx_wp.conf" style="float: right; margin-right: 5px;">Download</a>
<pre class="ruby">      <span style="color:#008000; font-style:italic;"># BEGIN W3TC Page Cache core</span>
      rewrite ^<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#9900CC;">*</span>\/<span style="color:#006600; font-weight:bold;">&#41;</span>?w3tc_rewrite_test$ $<span style="color:#006666;">1</span>?w3tc_rewrite_test=<span style="color:#006666;">1</span> last;
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">1</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$request_method = POST<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
            set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$query_string != <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
            set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite2</span> <span style="color:#006666;">1</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$request_uri !~ \/$<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
            set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite2</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$request_uri ~* <span style="color:#996600;">&quot;(sitemap<span style="color:#000099;">\.</span>xml(<span style="color:#000099;">\.</span>gz)?)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite2</span> <span style="color:#006666;">1</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$w3tc_rewrite2 != <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite3</span> <span style="color:#006666;">1</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$request_uri ~* <span style="color:#996600;">&quot;(<span style="color:#000099;">\/</span>wp-admin<span style="color:#000099;">\/</span>|<span style="color:#000099;">\/</span>xmlrpc.php|<span style="color:#000099;">\/</span>wp-(app|cron|login|register|mail)<span style="color:#000099;">\.</span>php|wp-.*<span style="color:#000099;">\.</span>php|index<span style="color:#000099;">\.</span>php)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite3</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$request_uri ~* <span style="color:#996600;">&quot;(wp<span style="color:#000099;">\-</span>comments<span style="color:#000099;">\-</span>popup<span style="color:#000099;">\.</span>php|wp<span style="color:#000099;">\-</span>links<span style="color:#000099;">\-</span>opml<span style="color:#000099;">\.</span>php|wp<span style="color:#000099;">\-</span>locations<span style="color:#000099;">\.</span>php)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite3</span> <span style="color:#006666;">1</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$w3tc_rewrite3 != <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_cookie ~* <span style="color:#996600;">&quot;(comment_author|wp<span style="color:#000099;">\-</span>postpass|wordpress_<span style="color:#000099;">\[</span>a<span style="color:#000099;">\-</span>f0<span style="color:#000099;">\-</span>9<span style="color:#000099;">\]</span><span style="color:#000099;">\+</span>|wordpress_logged_in)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_user_agent ~* <span style="color:#996600;">&quot;(W3<span style="color:#000099;">\ </span>Total<span style="color:#000099;">\ </span>Cache/0<span style="color:#000099;">\.</span>9<span style="color:#000099;">\.</span>2<span style="color:#000099;">\.</span>3)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_ua</span> <span style="color:#996600;">&quot;&quot;</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_user_agent ~* <span style="color:#996600;">&quot;(2<span style="color:#000099;">\.</span>0<span style="color:#000099;">\ </span>mmp|240x320|alcatel|amoi|asus|au<span style="color:#000099;">\-</span>mic|audiovox|avantgo|benq|bird|blackberry|blazer|cdm|cellphone|danger|ddipocket|docomo|dopod|elaine/3<span style="color:#000099;">\.</span>0|ericsson|eudoraweb|fly|haier|hiptop|hp<span style="color:#000099;">\.</span>ipaq|htc|huawei|i<span style="color:#000099;">\-</span>mobile|iemobile|j<span style="color:#000099;">\-</span>phone|kddi|konka|kwc|kyocera/wx310k|lenovo|lg|lg/u990|lge<span style="color:#000099;">\ </span>vx|midp|midp<span style="color:#000099;">\-</span>2<span style="color:#000099;">\.</span>0|mmef20|mmp|mobilephone|mot<span style="color:#000099;">\-</span>v|motorola|netfront|newgen|newt|nintendo<span style="color:#000099;">\ </span>ds|nintendo<span style="color:#000099;">\ </span>wii|nitro|nokia|novarra|o2|openweb|opera<span style="color:#000099;">\ </span>mobi|opera<span style="color:#000099;">\.</span>mobi|palm|panasonic|pantech|pdxgw|pg|philips|phone|playstation<span style="color:#000099;">\ </span>portable|portalmmm|<span style="color:#000099;">\b</span>ppc<span style="color:#000099;">\b</span>|proxinet|psp|qtek|sagem|samsung|sanyo|sch|sec|sendo|sgh|sharp|sharp<span style="color:#000099;">\-</span>tq<span style="color:#000099;">\-</span>gx10|small|smartphone|softbank|sonyericsson|sph|symbian|symbian<span style="color:#000099;">\ </span>os|symbianos|toshiba|treo|ts21i<span style="color:#000099;">\-</span>10|up<span style="color:#000099;">\.</span>browser|up<span style="color:#000099;">\.</span>link|uts|vertu|vodafone|wap|willcome|windows<span style="color:#000099;">\ </span>ce|windows<span style="color:#000099;">\.</span>ce|winwap|xda|zte)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_ua</span> _low;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_user_agent ~* <span style="color:#996600;">&quot;(acer<span style="color:#000099;">\ </span>s100|android|archos5|blackberry9500|blackberry9530|blackberry9550|blackberry<span style="color:#000099;">\ </span>9800|cupcake|docomo<span style="color:#000099;">\ </span>ht<span style="color:#000099;">\-</span>03a|dream|htc<span style="color:#000099;">\ </span>hero|htc<span style="color:#000099;">\ </span>magic|htc_dream|htc_magic|incognito|ipad|iphone|ipod|kindle|lg<span style="color:#000099;">\-</span>gw620|liquid<span style="color:#000099;">\ </span>build|maemo|mot<span style="color:#000099;">\-</span>mb200|mot<span style="color:#000099;">\-</span>mb300|nexus<span style="color:#000099;">\ </span>one|opera<span style="color:#000099;">\ </span>mini|samsung<span style="color:#000099;">\-</span>s8000|series60.*webkit|series60/5<span style="color:#000099;">\.</span>0|sonyericssone10|sonyericssonu20|sonyericssonx10|t<span style="color:#000099;">\-</span>mobile<span style="color:#000099;">\ </span>mytouch<span style="color:#000099;">\ </span>3g|t<span style="color:#000099;">\-</span>mobile<span style="color:#000099;">\ </span>opal|tattoo|webmate|webos)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_ua</span> _high;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_ref</span> <span style="color:#996600;">&quot;&quot;</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_cookie ~* <span style="color:#996600;">&quot;w3tc_referrer=.*(google<span style="color:#000099;">\.</span>com|yahoo<span style="color:#000099;">\.</span>com|bing<span style="color:#000099;">\.</span>com|ask<span style="color:#000099;">\.</span>com|msn<span style="color:#000099;">\.</span>com)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_ref</span> _search_engines;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_ssl</span> <span style="color:#996600;">&quot;&quot;</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$scheme = https<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_ssl</span> _ssl;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      set <span style="color:#ff6633; font-weight:bold;">$w3tc_enc</span> <span style="color:#996600;">&quot;&quot;</span>;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$http_accept_encoding ~ gzip<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_enc</span> .<span style="color:#9900CC;">gzip</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!-f <span style="color:#996600;">&quot;$document_root/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         set <span style="color:#ff6633; font-weight:bold;">$w3tc_rewrite</span> <span style="color:#006666;">0</span>;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$w3tc_rewrite = <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
         rewrite .<span style="color:#9900CC;">*</span> <span style="color:#996600;">&quot;/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc&quot;</span> last;
      <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#008000; font-style:italic;"># END W3TC Page Cache core</span>
&nbsp;</pre>
</div>
<h3>What it does well for me</h3>
<ul>
<li>Static page caching is really good.  I like the pre-zipped support, doing page caching is the main gain of every cache plugin,  this is why I chose it since it creates static files which nginx <a href="http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/" target="_blank">serves well in the webserver realm</a>.</li>
<li>Object + DB query caching using memcached.  Stats of memcached prove it's useful.</li>
</ul>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">stats<br />
STAT cmd_get <span style="color: #000000;">3202</span><br />
STAT cmd_set <span style="color: #000000;">3034</span><br />
STAT cmd_flush <span style="color: #000000;">543</span><br />
STAT get_hits <span style="color: #000000;">3202</span><br />
STAT get_misses <span style="color: #000000;">3155</span></div></td></tr></tbody></table></div>
<p>These don't really tell us anything on <em>cache efficiency</em> as with a 5 minute limit on the caching of subsequent data, it all depends on the expiration of those items from the cache.  What it <em>does</em> tell is is what would have gone to the backends in case it wasn't there at all.  You will want to balance site <em>dynamism</em> vs caching <em>efficiency</em>.</p>
<h3>What it doesn't do well for me</h3>
<ul>
<li>That<em> Preview/Deploy </em>thing, there is something about it that I find irritating.  It doesn't seem to notice that the deployed and the previewed config are the same so it keeps on displaying that you need to <em>Deploy</em>. Even after you have just deployed.  Aargh,  It's irritating, I don't really test-drive it either, I just apply and test the whole site.  I like the <em>Deploy</em> facility to apply all my changes at once though.  But I want to just activate and test the lot.</li>
<li>I have my issues with the Browser caching functionality, I create php applications for a living and I know for a fact that getting all those browsers to respect caching directives (Headers) is hard work.  I took a look under the hood using <a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/" target="_blank">Web developer</a> plugin to see what kind of expiration tricks they do and I saw some strange stuff going on that I switched this part off for now.  I haven't investigated this in depth yet.  Once I do I will make this more complete.  I can just say that if you want the browser to cache the pages, you cannot send a <strong>no-cache</strong> header.  that's the opposite of browser caching, more on it later I hope.</li>
</ul>
<h3>Conclusion of my experiences</h3>
<p><a href="http://nginx.org/" target="_blank">nginx</a> isn't hard to configure, with the aid and support of plugin developpers.  This plugin gets extra points for <a href="http://nginx.org/" target="_blank">nginx</a> support, translating these .<em>htaccess</em> rules/files from apache to <a href="http://nginx.org/" target="_blank">nginx</a> would be troublesome for most people, myself included, these are a lot  of rules as we have seen here.  I list them up per module as they are  written in the <a href="http://nginx.org/" target="_blank">nginx</a> config by this plugin, I didn't invent those.  These people understand that making it as low-entry as possible is good marketing.</p>
<p>As a PHP developer or even as a troubleshooter,  try to just use<strong> E_ALL </strong>for a change when running php code.  Switch every  error / trace / log warning in the <em>php.ini</em> file to <em>on</em> you can find,  you will be amazed on how much crap gets left behind.  I've noticed of small issues that are a nobrainer to fix in the code so I guess a lot of people turn their PHP warnings off .... even when creating nice wordpress plugin's.</p>
<h3>Future of nginx</h3>
<p>I've seen lots of people talking about speeding up their Apache driven wordpress blogs by using nginx in front of it.  Although nginx does that well too, I believe it's so wrong that setup.  Honestly.  Just get rid of Apache right now.  It's over, it earned it's place in history, that's where it belongs now.  Replace it with nginx.</p>
<p>I'm going to predict that if <a href="http://nginx.org">nginx</a> keeps up like it's doing now, it will replace Apache as a default web-server in some distributions just as <a href="http://mariadb.org" target="_blank">mariaDB</a> will be replacing mysql in the near future.  It's inevitable.  GPL is at work here.   Better stuff just survives.  Evolution works.</p>
<p>On the subject, make sure you check out the <a href="http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/">benchmarks mentioned before</a>, they are unreal if you glance at the <a href="http://gwan.ch/" target="_blank">G-WAN</a> ones.<br />
It confirms a few things for me, there's always a new kid on the block, <a href="http://gwan.ch/" target="_blank">G-WAN</a> is insane by the looks of it, I'm not sure I want to use it into production environments at this stage or if I can get it to work with php, in fact, it's new to me too.   This also confirms that Apache is on it's way out for sure.  More exciting things are about to come.</p>
<h3>Some sources I visited to feed my hunger</h3>
<p><a href="http://wp-performance.com/2010/10/nginx-reverse-proxy-cache-wordpress-apache/" target="_blank">http://wp-performance.com/2010/10/nginx-reverse-proxy-cache-wordpress-apache/</a><br />
<a href="http://tentblogger.com/w3-total-cache/" target="_blank">http://tentblogger.com/w3-total-cache/</a><br />
<a href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">http://wordpress.org/extend/plugins/w3-total-cache/</a><br />
<a href="http://nbonvin.wordpress.com/" target="_blank">http://nbonvin.wordpress.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://byte-consult.be/2011/06/27/w3-total-cache-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

