<?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>le blog &#187; PHP</title>
	<atom:link href="http://www.normyee.net/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.normyee.net/blog</link>
	<description></description>
	<lastBuildDate>Wed, 09 Dec 2009 23:23:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Updating WordPress via SSH instead of FTP</title>
		<link>http://www.normyee.net/blog/2009/12/01/updating-wordpress-via-ssh-instead-of-ftp/</link>
		<comments>http://www.normyee.net/blog/2009/12/01/updating-wordpress-via-ssh-instead-of-ftp/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 19:09:54 +0000</pubDate>
		<dc:creator>norm</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.normyee.net/blog/?p=120</guid>
		<description><![CDATA[I&#8217;ve shut off FTP access to my server a while back, since FTP passwords are passed in plaintext over the net which is A Bad Thing™. For the occasions that I would need to update WordPress via its web interface, I would start up the FTP daemon so that I could use WordPress&#8217; auto-update feature,]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve shut off FTP access to my server a while back, since FTP passwords are <a href="http://en.wikipedia.org/wiki/Ftp#Security_problems" target="_blank">passed in plaintext over the net</a> which is A Bad Thing™. For the occasions that I would need to update WordPress via its web interface, I would start up the FTP <a href="http://en.wikipedia.org/wiki/Daemon_%28computer_software%29" target="_blank">daemon</a> so that I could use WordPress&#8217; auto-update feature, and then shut it back down after I was done. Not that big of a hassle, but it required me to login into my server before doing anything from the web interface which was one step too many.</p>
<p>I discovered that WordPress has built-in support for <a href="http://codex.wordpress.org/Editing_wp-config.php#FTP.2FSSH_Constants" target="_blank">updating via SSH2</a> if PHP has the <a href="http://en.wikipedia.org/wiki/PHP_Extension_Community_Library#PECL" target="_blank">PECL</a> <a href="http://pecl.php.net/package/ssh2" target="_blank">SSH2 library</a> installed. Following is a quick summary of how to get it running.</p>
<p>The PECL ssh2 library requires <a href="http://www.sourceforge.net/projects/libssh2" target="_blank">libssh2</a> which I downloaded and then compiled painlessly with a</p>
<pre class="brush: bash; gutter: true; toolbar: false;">$ ./configure
$ make
$ make install</pre>
<p>Once libssh2 was compiled and installed, I installed the PECL ssh2 library via</p>
<pre class="brush: bash; gutter: true; toolbar: false;">$ pecl install -f ssh2</pre>
<p>The -f flag is to force the install since ssh2 is still in beta &amp; you&#8217;d otherwise get a warning like</p>
<pre class="brush: plain; auto-links: false; light: true;">Failed to download pecl/ssh2 within preferred state &quot;stable&quot;, latest release is version 0.11.0, stability &quot;beta&quot;, use &quot;channel://pecl.php.net/ssh2-0.11.0&quot; to install</pre>
<p>After installing ssh2 via pecl, i edited the php.ini file (located at /etc/php.ini for me) to tell PHP to load this extension</p>
<pre class="brush: bash; gutter: true; toolbar: false;">extension=ssh2.so</pre>
<p>and then restart apache afterwards (via <code>apachctl</code>, <code>service httpd restart</code>, or whatever is appropriate for your system) so that the library would be available to PHP.</p>
<p>After apache comes back up, you should see a new option (SSH) in the wordpress upgrade page (which applies to plugins as well).</p>
<p>BTW, if you&#8217;re on a Red Hat Fedora system and/or use <a href="http://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified" target="_blank">yum</a>, you might be able to just pull the libssh2 rpm from yum instead of compiling it:</p>
<pre class="brush: bash; gutter: true; toolbar: false;">$ yum install libssh2
$ yum install libssh2-devel
$ yum install libssh2-docs</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.normyee.net/blog/2009/12/01/updating-wordpress-via-ssh-instead-of-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZendCon 2007 Day 1</title>
		<link>http://www.normyee.net/blog/2007/10/10/zendcon-2007-day-1/</link>
		<comments>http://www.normyee.net/blog/2007/10/10/zendcon-2007-day-1/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 07:39:47 +0000</pubDate>
		<dc:creator>norm</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.normyee.net/blog/2007/10/10/zendcon-2007-day-1/</guid>
		<description><![CDATA[was not too bad. I went to 5 sessions and found at least 2 of them moderately helpful, namely Ben Ramsey&#8217;s session on memcached and Eli White&#8217;s PHP &#38; MySQL scaling techniques. I might put up a short list of take aways in a few days. View from the back]]></description>
			<content:encoded><![CDATA[<p>was not too bad. I went to 5 sessions and found at least 2 of them moderately helpful, namely Ben Ramsey&#8217;s session on <a href="http://danga.com/memcached/" target="_blank">memcached</a> and Eli White&#8217;s PHP &amp; MySQL scaling techniques. I might put up a short list of take aways in a few days.</p>
<p><a href="http://www.normyee.net/blog/?attachment_id=49" rel="attachment wp-att-49" title="View from the back">View from the back</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.normyee.net/blog/2007/10/10/zendcon-2007-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP&#8217;s curl_multi to the rescue</title>
		<link>http://www.normyee.net/blog/2007/09/11/curl_multi-to-the-rescue/</link>
		<comments>http://www.normyee.net/blog/2007/09/11/curl_multi-to-the-rescue/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 23:48:18 +0000</pubDate>
		<dc:creator>norm</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.normyee.net/blog/2007/09/11/curl_multi-to-the-rescue/</guid>
		<description><![CDATA[One of my Facebook apps hits Amazon&#8217;s Ecommerce Service (ECS) for item information via REST queries. I needed to process 19 separate queries searching for a title (basically searching 1 of 19 &#8220;browse nodes&#8221;), and return that data onto the Facebook canvas. Simple enough, I could just do a foreach loop to make each REST]]></description>
			<content:encoded><![CDATA[<p>One of my <a href="http://apps.facebook.com/gamersnetwork/" target="_blank">Facebook apps</a> hits <a href="http://www.amazon.com/E-Commerce-Service-AWS-home-page/b/ref=sc_fe_l_2/104-9762278-8592743?ie=UTF8&amp;node=12738641&amp;no=342430011&amp;me=A36L942TSJ2AJA" target="_blank">Amazon&#8217;s Ecommerce Service (ECS)</a> for item information via <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank">REST</a> queries. I needed to process 19 separate queries searching for a title (basically searching 1 of 19 &#8220;browse nodes&#8221;), and return that data onto the Facebook canvas.</p>
<p>Simple enough, I could just do a foreach loop to make each REST request. Only problem was, say, each loop took 500 milliseconds total. That&#8217;s not hard when you consider all the steps: DNS, performing the REST query, waiting for the response, receiving the response, and then parsing the XML (in this case, using the <a href="http://us.php.net/simplexml" target="_blank">SimpleXML extension</a>). At 19 requests that&#8217;s 9.5 seconds which is way too slow, not to mention Facebook times out the request as well and returns a lovely error page.</p>
<p>For the test REST query I was benchmarking, it was averaging 9.65 seconds for the entire PHP script to complete (performing all 19 REST queries and then formatting the output). Simply switching from <a href="http://us.php.net/file_get_contents" target="_blank">file_get_contents()</a> to PHP&#8217;s <a href="http://us.php.net/curl" target="_blank">cURL functions</a> dropped the average to 7.32 seconds, a roughly 24% improvement. That was a great improvement, but still too slow and Facebook was still timing out the pages.</p>
<p>The root of the problem was that the 19 REST queries were <strong>sequential</strong> and as a result too slow. I needed to make those requests <strong>concurrently</strong>. Fortunately, PHP supported multi curl (basically making multiple cURL requests concurrently) via curl_multi_* functions.</p>
<p>BAM.  Using curl_multi dropped the page generation time down to 1.6 seconds &#8212; much more reasonable and a 83.4% improvement. w00t.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.normyee.net/blog/2007/09/11/curl_multi-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
