<?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>Brettic.us &#187; General</title>
	<atom:link href="http://brettic.us/category/bretticus/gen/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettic.us</link>
	<description>Web devlopment and life in general</description>
	<lastBuildDate>Tue, 13 Dec 2011 02:59:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP 5.2 and 5.3 side-by-side on Apache and Ubuntu 10.10</title>
		<link>http://brettic.us/2010/10/31/php-5-2-and-5-3-on-apache/</link>
		<comments>http://brettic.us/2010/10/31/php-5-2-and-5-3-on-apache/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 07:14:37 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://brettic.us/?p=510</guid>
		<description><![CDATA[<br/>Painlessly run version 5.2.x and 5.3.x on the same apache port simultaneously. Several persons have indicated that they could not get this working per my instructions below. For a more thorough explanation, see Chris Breidert&#8217; s follow-up blog post. One of these days, when I get more time, I&#8217;ll go through a vanilla installation and add any additional [...]]]></description>
			<content:encoded><![CDATA[<br/><h4>Painlessly run version 5.2.x and 5.3.x on the same apache port simultaneously.</h4>
<blockquote><p>Several persons have indicated that they could not get this working per my instructions below. For a more thorough explanation, see <a href="http://blog.breidert.net/php-5-2-and-php-5-3-for-drupal-applications-under-apache-on-ubuntu-10-04-lts/" target="_blank">Chris Breidert&#8217; s follow-up blog post</a>. One of these days, when I get more time, I&#8217;ll go through a vanilla installation and add any additional instructions, etc.</p></blockquote>
<p>I&#8217;d just upgraded to Ubuntu 10.10 on my PC. However, the default PHP package was version 5.3.x and I needed 5.2.x. Some projects needed the newest version, others would be crippled by it. While looking for a way to have two versions of PHP running simultaneously on Ubuntu 10.10, I struck success.</p>
<p>In this post, I&#8217;ll explain step-by-step how you too can  build a development platform where you can work on PHP 5.2.x and 5.3.x projects simultaneously&#8211;without <em>ever</em> having to restart Apache.<span id="more-510"></span></p>
<h2>Why?</h2>
<p>My primary development computer is a Macbook Pro, but sometimes I like to change things up and work from my PC installed with the latest version of Ubuntu (10.10 at the time of writing.) Ubuntu 10.10 (A.K.A Maverick Meerkat) comes with PHP 5.3.x (currently 5.3.3.)</p>
<p>While using version 5.3.x, I noticed that some of my development projects were broken (like my website that needs curl!) On the other hand, I have another development project that is &#8220;cutting-edge&#8221; and must run PHP 5.3.x. I couldn&#8217;t just downgrade to PHP 5.2.x (which seemed to be the bulk of solutions offered for my predicament.)</p>
<p>Switching versions is easy on my Mac, thanks to MAMP. I just swap versions through the MAMP control panel. However, I really wanted the same flexibility on Ubuntu. Not only did I find a solution, I found one that I prefer to MAMP because I can run either version <strong>simultaneously</strong>. Here&#8217;s how I did it.</p>
<h2>Step 1: Get PHP source code.</h2>
<p>Download the most current version of PHP 5.2.x (5.2.14 at the time of writing.)</p>
<p><a href="http://us3.php.net/downloads.php" target="_blank">http://us.php.net/downloads.php</a></p>
<p>You can download this to anywhere like ~/src or wherever. Extract it with tar xzvf php-file (for .tar.gz variant) or tar xjvf php-file  (for .tar.bz variant) depending on which version you downloaded. Change directories into the folder you just extracted.</p>
<h2>Step 2: Install PHP development libraries.</h2>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">sudo</span> <span class="kw2">apt-get</span> <span class="kw2">install</span> libxml2-dev libmysqlclient-dev libcurl4-gnutls-dev libcurl4-openssl-dev libpng12-dev libjpeg62-dev</pre></div></div>
<p>Credit to <a href="http://webpagedeveloper.me/blog/ubuntu-1004-lucid-lamp-server-running-php-52-and-53" target="_blank">Dave Parrish</a> for the dev packages and configure options, plus most of the other information here.</p>
<h2>Step 3: Configure and make.</h2>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash">.<span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>php5.2 \
<span class="re5">--with-config-file-path</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>php5.2 \
<span class="re5">--with-mysqli</span> \
<span class="re5">--with-mysql</span> \
<span class="re5">--with-curl</span> \
<span class="re5">--with-gd</span> \
<span class="re5">--with-jpeg</span> \
<span class="re5">--with-jpeg-dir</span> \
<span class="re5">--enable-cli</span> \
<span class="re5">--enable-fastcgi</span> \
<span class="re5">--enable-discard-path</span> \
<span class="re5">--enable-force-cgi-redirect</span></pre></div></div>
<div>If everything works, go ahead and make the file.</div>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">make</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></pre></div></div>
<div>You should end up with php files in /opt/php5.2 if everything went without errors.</div>
<h2>Step 4: Setup fast-cgi.</h2>
<p>Just install the Debian package.</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">sudo</span> <span class="kw2">apt-get</span> <span class="kw2">install</span> libapache2-mod-fastcgi</pre></div></div>
<p>To enable the module, run:</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">sudo</span> a2enmod fastcgi</pre></div></div>
<p>Restart Apache.</p>
<p><strong> </strong></p>
<h2>Step 5: Enable mod_actions.</h2>
<p>mod_actions was already available for me to use. I simply had to enable it:</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">sudo</span> a2enmod actions</pre></div></div>
<p>Restart Apache.</p>
<h2>Step 6: Setup php5-cgi wrapper.</h2>
<p>Create a /usr/lib/cgi-bin/php5-cgi file:</p>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="co0">#!/bin/sh</span>
<span class="re2">PHP_FCGI_CHILDREN</span>=<span class="nu0">1</span>
<span class="kw3">export</span> PHP_FCGI_CHILDREN
<span class="re2">PHP_FCGI_MAX_REQUESTS</span>=<span class="nu0">5000</span>
<span class="kw3">export</span> PHP_FCGI_MAX_REQUESTS
<span class="kw3">exec</span> <span class="sy0">/</span>opt<span class="sy0">/</span>php5.2<span class="sy0">/</span>bin<span class="sy0">/</span>php-cgi</pre></div></div>
<p>Also ripped off from <a href="http://webpagedeveloper.me/blog/ubuntu-1004-lucid-lamp-server-running-php-52-and-53" target="_blank">Dave Parrish</a>.</p>
<p>Make your wrapper executable:</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="kw2">sudo</span> <span class="kw2">chmod</span> +x <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>cgi-bin<span class="sy0">/</span>php5-cgi</pre></div></div>
<h2>Step 7: Make an Include file for VirtualHosts.</h2>
<p>I made a simple include file under /etc/apache2/ called php52.conf:</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="bash"><span class="co0">#include for sites that still need to run at php 5.2.x</span>
&nbsp;
ScriptAlias <span class="sy0">/</span>php5-cgi <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>cgi-bin<span class="sy0">/</span>php5-cgi
&nbsp;
Action application<span class="sy0">/</span>x-httpd-php5 <span class="sy0">/</span>php5-cgi
AddHandler application<span class="sy0">/</span>x-httpd-php5 .php .php5 .php4 .php3 .phtml</pre></div></div>
<p>Credit to <a href="http://ubuntuforums.org/showthread.php?t=159301&amp;page=2#td_post_2625095" target="_blank">jameso</a> for this pearl.</p>
<h2>Step 8: Include php52.conf in all VirtualHosts where PHP 5.2.x is needed.</h2>
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://brettic.us/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://brettic.us/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="apache">&lt;<span class="kw3">VirtualHost</span> *.80&gt;
&nbsp;
<span class="co1"># ...</span>
&nbsp;
<span class="co1">#needs to run version 5.2.x of PHP</span>
<span class="kw1">Include</span> php52.conf
&nbsp;
&lt;/<span class="kw3">VirtualHost</span>&gt;</pre></div></div>
<p>That&#8217;s it! Now I can simply insert my Include directive for any websites that I&#8217;m developing that are not ready for PHP 5.3.</p>
<blockquote><p><strong>Important</strong>. I am using VirtualHost configurations. This allows me to leave PHP 5.3.x enabled globally via the Apache module and turn on PHP 5.2.x specifically for each vhost. If you develop in the typical way of accessing a website via http://localhost/someproject, consider using the Apache Directory directive instead. It should work, but I haven&#8217;t tested.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://brettic.us/2010/10/31/php-5-2-and-5-3-on-apache/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 18/31 queries in 0.024 seconds using memcached

Served from: brettic.us @ 2012-02-05 05:23:18 -->
