<?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>laneolson.ca &#187; PHP</title>
	<atom:link href="http://www.laneolson.ca/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.laneolson.ca</link>
	<description></description>
	<lastBuildDate>Fri, 07 Jan 2011 23:06:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compiling PHP 5.3 on Ubuntu 9.10</title>
		<link>http://www.laneolson.ca/2010/02/19/compiling-php-5-3-on-ubuntu-9-10/</link>
		<comments>http://www.laneolson.ca/2010/02/19/compiling-php-5-3-on-ubuntu-9-10/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 21:11:03 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.laneolson.ca/?p=177</guid>
		<description><![CDATA[<p>This guide will outline how to compile PHP 5.3 from source for use with Apache.  The instructions in this guide have been tested with Ubuntu 9.10 and should work on other debian based distros.  This guide is a slight modification of the <a href="http://vimeo.com/8005503" target="_blank">video guide on setting up Apache, PHP 5.3 with xdebug, MongoDB, and Lithium</a> created by Jon Adams. Before proceeding with the instructions below you will need Apache installed on your computer.  If you do not yet have apache you can follow my <a href="http://www.laneolson.ca/2010/02/11/installing-and-configuring-apache-for-multiple-sites-on-ubuntu/">guide for setting up Apache on Ubuntu 9.10</a>.</p>
<p>The first step for installing PHP 5.3 is to get the prerequisites.  For this guide you will need the following libraries in order to compile php with the options that I use.  If you have some custom libraries/extensions that you want included in your build of PHP, now is the time to install them if you haven&#8217;t already.</p>
<p>The following command will install the libraries that I will need:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libmcrypt-dev libxml2 libxml2-dev libbz2-dev libcurl4-gnutls-dev libjpeg62-dbg libpng12-dev libxslt1-dev libbz2-dev</pre></div></div>

<p>Once our required libraries have been installed we can go to http://www.php.net/downloads.php and choose to download the latest 5.3.x build in tar.gz format.  I chose to copy the download link and use wget to download it to the tmp directory, but you can do whatever you like.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp

<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>ca2.php.net<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>php-5.3.1.tar.gz<span style="color: #000000; font-weight: bold;">/</span>from<span style="color: #000000; font-weight: bold;">/</span>this<span style="color: #000000; font-weight: bold;">/</span>mirror</pre></div></div>

<p>now untar the file and go into the directory</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> php-5.3.1.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> php-5.3.1</pre></div></div>

<p>Now comes the fun part.  Here we will run the configure script that says what kind of extensions we want php built with...</p>]]></description>
			<content:encoded><![CDATA[<p>This guide will outline how to compile PHP 5.3 from source for use with Apache.  The instructions in this guide have been tested with Ubuntu 9.10 and should work on other debian based distros.  This guide is a slight modification of the <a href="http://vimeo.com/8005503" target="_blank">video guide on setting up Apache, PHP 5.3 with xdebug, MongoDB, and Lithium</a> created by Jon Adams. Before proceeding with the instructions below you will need Apache installed on your computer.  If you do not yet have apache you can follow my <a href="http://www.laneolson.ca/2010/02/11/installing-and-configuring-apache-for-multiple-sites-on-ubuntu/">guide for setting up Apache on Ubuntu 9.10</a>.</p>
<p>The first step for installing PHP 5.3 is to get the prerequisites.  For this guide you will need the following libraries in order to compile php with the options that I use.  If you have some custom libraries/extensions that you want included in your build of PHP, now is the time to install them if you haven&#8217;t already.</p>
<p>The following command will install the libraries that I will need:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libmcrypt-dev libxml2 libxml2-dev libbz2-dev libcurl4-gnutls-dev libjpeg62-dbg libpng12-dev libxslt1-dev libbz2-dev</pre></div></div>

<p>Once our required libraries have been installed we can go to http://www.php.net/downloads.php and choose to download the latest 5.3.x build in tar.gz format.  I chose to copy the download link and use wget to download it to the tmp directory, but you can do whatever you like.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>ca2.php.net<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>php-5.3.1.tar.gz<span style="color: #000000; font-weight: bold;">/</span>from<span style="color: #000000; font-weight: bold;">/</span>this<span style="color: #000000; font-weight: bold;">/</span>mirror</pre></div></div>

<p>now untar the file and go into the directory</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> php-5.3.1.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> php-5.3.1</pre></div></div>

<p>Now comes the fun part.  Here we will run the configure script that says what kind of extensions we want php built with.  At the beginning of the tutorial we installed a bunch of libraries (for example libbz2) and because of that we are able to build PHP with support for these libraries by specifying the &#8211;with-%library% flag.  To see the options available for configuring php type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--help</span></pre></div></div>

<p>You should be fine using what I used below, but feel free to make adjustments as you see fit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-config-file-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-config-file-scan-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-apxs2</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apxs2 <span style="color: #660033;">--with-bz2</span> <span style="color: #660033;">--with-curl</span> <span style="color: #660033;">--with-gd</span> <span style="color: #660033;">--with-iconv</span> <span style="color: #660033;">--with-mcrypt</span> <span style="color: #660033;">--with-mysql</span> <span style="color: #660033;">--with-mysqli</span> <span style="color: #660033;">--with-openssl</span> <span style="color: #660033;">--with-pcre-regex</span> <span style="color: #660033;">--with-pdo-mysql</span> <span style="color: #660033;">--with-pear</span> <span style="color: #660033;">--with-xmlrpc</span> <span style="color: #660033;">--with-xsl</span> <span style="color: #660033;">--with-zlib</span> <span style="color: #660033;">--enable-ftp</span> <span style="color: #660033;">--enable-mbstring</span> <span style="color: #660033;">--enable-soap</span> <span style="color: #660033;">--enable-sockets</span></pre></div></div>

<p>If all goes well with the configure script you can continue to run the make file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-i</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Once the make script is finished running we have to manually create the modules for Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>mods-available
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> php5.load</pre></div></div>

<p>The contents of this file should be:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LoadModule php5_module <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>libphp5.so</pre></div></div>

<p>Now create the configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> php5.conf</pre></div></div>

<p>with the contents: </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_php5.c<span style="color: #000000; font-weight: bold;">&gt;</span>
	AddType application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php .php .phtml .php3
	AddType application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php-source .phps
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Once those two files have been created we can enable the php5 module for Apache, then restart Apache for the new module to load.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod php5
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>Now go into your web directory (if you followed my apache guide earlier go to ~/www/sandbox.loc/httpdocs) and create a file called test.php</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.loc<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/</span>test.php</pre></div></div>

<p>with the following contents:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now point your web browser to the new file you created.  Which should be at http://sandbox.loc/test.php, you should get a phpinfo page if all went according to plan.</p>
<p>You have now successfully installed php 5.3.  On the phpinfo page if you scroll down to the date section you will probably see an error saying you have to set your timezone.  You can do this with the php.ini file.  To ceate the php in file first create the /etc/php5 directory and copy the php.ini-production file included in the php-5.3.1 tar file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>php-5.3.1<span style="color: #000000; font-weight: bold;">/</span>php.ini-production <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>Now edit the php.ini file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>and find the line beginning with &#8220;;date.timezone&#8221;, remove the semi-colon and set the value to your desired time zone.  There is a <a href="http://ca.php.net/manual/en/timezones.php">list of supported timezones</a> in the PHP manual.  For example, I changed mine to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">date.timezone = <span style="color: #ff0000;">&quot;America/Edmonton&quot;</span></pre></div></div>

<p>You should now be set to start using PHP 5.3 with Apache!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2010/02/19/compiling-php-5-3-on-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Page Not Found When Posting or Editing WordPress Posts</title>
		<link>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/</link>
		<comments>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/#comments</comments>
		<pubDate>Fri, 22 May 2009 19:15:10 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://laneolson.ca/?p=47</guid>
		<description><![CDATA[Today I was copying over some old posts I had on another WordPress install and for some reason when I went to edit one of the posts I was redirected to a 404 error.  I thought this was odd, so I tried to repost the item as a new post.  I still received the 404 error!  After some Googling I found this blog post which outlined some solutions to this problem.  It appears that some people have had some luck using those solutions.  However, none of them worked for me&#8230; even encoding the whole post into HTML entities!  
It is indeed a problem with a security module in Apache.  If you are as unlucky as I was to still have the problem after trying out the solutions in the blog post above, then you have the joy of tracking down the specific word that appears to be the problem.  In my case, I was posting a code snippet from my post on Caching Data with CakePHP.  For some reason mod_security was flagging my use of the word &#8220;settings&#8221;.  Once I changed the variable names in the post it worked flawlessly.
]]></description>
			<content:encoded><![CDATA[<p>Today I was copying over some old posts I had on another WordPress install and for some reason when I went to edit one of the posts I was redirected to a 404 error.  I thought this was odd, so I tried to repost the item as a new post.  I still received the 404 error!  After some Googling I found <a href="http://abing.gotdns.com/posts/2006/wordpress-error-404-when-publishing-or-saving-post/" target="blank">this blog post</a> which outlined some solutions to this problem.  It appears that some people have had some luck using those solutions.  However, none of them worked for me&#8230; even encoding the whole post into HTML entities!  </p>
<p>It is indeed a problem with a security module in Apache.  If you are as unlucky as I was to still have the problem after trying out the solutions in the blog post above, then you have the joy of tracking down the specific word that appears to be the problem.  In my case, I was posting a code snippet from my post on Caching Data with CakePHP.  For some reason mod_security was flagging my use of the word &#8220;settings&#8221;.  Once I changed the variable names in the post it worked flawlessly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

