<?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>Unreal Expectations &#187; php</title>
	<atom:link href="http://unrealexpectations.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://unrealexpectations.com/blog</link>
	<description>That actually worked??!??</description>
	<lastBuildDate>Sun, 04 Dec 2011 09:02:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Install Your Own URL Shortener</title>
		<link>http://unrealexpectations.com/blog/2011/03/install-your-own-url-shortener/</link>
		<comments>http://unrealexpectations.com/blog/2011/03/install-your-own-url-shortener/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 06:26:36 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://unrealexpectations.com/blog/?p=175</guid>
		<description><![CDATA[<p>A while back I acquired domain, zod.im with intent of setting up my own shortened URL service.  While there is nothing wrong with the current offerings by bit.ly or TinyURL, I was academically intrigued by the notion of setting this up.  </p>
YOURLS
<p>I went with open source package YOURLS. It was pretty easy to [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I acquired domain, zod.im with intent of setting up my own shortened URL service.  While there is nothing wrong with the current offerings by <a href="http://bit.ly/">bit.ly</a> or <a href="http://tinyurl.com/">TinyURL</a>, I was academically intrigued by the notion of setting this up.  </p>
<h2>YOURLS</h2>
<p>I went with open source package <a href="http://yourls.org/">YOURLS</a>. It was pretty easy to setup and has a nice interface.  The documentation didn&#8217;t provide me everything I needed, but what it didn&#8217;t provide was easily discovered.  Examples: </p>
<ul>
<li>I don&#8217;t install MySQL databases on a daily, weekly, or monthly basis, so I had to go look that back up since the commands weren&#8217;t included directly in the setup documentation.
</li>
<li>I front nginx as the web server and chose to look up changes to nginx configuration as the yourls installer provides just content for .htaccess
</li>
<li>I use WordTwit for notifications of posts on this blog to send to Twitter.  The current version did not have yourls support, but looks like the next Pro version might have more pluggable solution.  So made updates to plugin to use this now.
</li>
</ul>
<h2> Installation </h2>
<h3> Pre-Requisites</h3>
<ul>
<li>This assumes the starting point of installation already has nginx installed with fastcgi able to interpret php.
</li>
<li>This also assumes MySQL is installed and operational.
</li>
</ul>
<h3> MySQL </h3>
<ol>
<li>Create the database </li>
<p><pre><code>
mysql&gt; CREATE DATABASE yourlsdb;
</code></pre></p>
<li>Create the user &#038; Grant </li>
<p><pre><code>
mysql&gt; CREATE USER &#039;yourlsdbuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;password&#039;;

mysql&gt; GRANT ALL PRIVILEGES ON yourlsdb.* TO yourlsdbuser@localhost;
</code></pre>
</ol>
<h3> Install YOURLS</h3>
<ol>
<li> Download the code </li>
<p>Check <a href="http://code.google.com/p/yourls/downloads/list">here</a> for the latest version.<br />
<pre><code>
$ wget http://code.google.com/p/yourls/downloads/detail?name=yourls-1.5.zip
</code></pre></p>
<li> Unzip the code in directory you want as root </li>
<p><pre><code>
$ sudo mkdir -p /var/www/zod.im/web
$ cd /var/www/zod.im/web/
$ unzip &lt;path to&gt;/yourls-1.5.zip
</code></pre></p>
<li> Update the configuration </li>
<p>The following is the minimum settings that need to be changed for the private linking to work.  Read through the configuration for other changes to consider.</p>
<ol>
<li> Copy the sample configuration </li>
<p><pre><code>
$ cp includes/config-sample.php user/config.php
</code></pre></p>
<li>Update the database settings </li>
<p>Use vi or whatever your favorite editor is to edit the new file and follow the information in the file.<br />
Change the database settings.<br />
<pre><code>
...
define( &#039;YOURLS_DB_USER&#039;, &#039;dbuser&#039; );

/** MySQL database password */
define( &#039;YOURLS_DB_PASS&#039;, &#039;dbpassword&#039; );

/** The name of the database for YOURLS */
define( &#039;YOURLS_DB_NAME&#039;, &#039;yourls&#039; );

/** MySQL hostname */
define( &#039;YOURLS_DB_HOST&#039;, &#039;localhost&#039; );
...
</code></pre></p>
<li> Update the base site URL </li>
<p><pre><code>
/** YOURLS installation URL, no trailing slash */
define( &#039;YOURLS_SITE&#039;, &#039;http://example.com&#039; );
</code></pre></p>
<li>Update the cookie hash</li>
<p>As the comment shows go <a href="http://yourls.org/cookie">here</a> to get a new random hash.<br />
<pre><code>
/** A random secret hash used to encrypt cookies. You don&#039;t have to remember it, make it long and complicated. Hint: copy from http://yourls.org/cookie **/
define( &#039;YOURLS_COOKIEKEY&#039;, &#039;qQ4KhL_pu|s@Zm7n#%:b^{A[vhm&#039; );
</code></pre></p>
<li> Update the username and password </li>
<p>The username and passwords are in the configuration file with password in clear text. Since this isn&#8217;t secure, I recommend not using a password that works anywhere else.<br />
<pre><code>
/**  Username(s) and password(s) allowed to access the site */
$yourls_user_passwords = array(
        &#039;username&#039; =&gt; &#039;password&#039;,
        &#039;username2&#039; =&gt; &#039;password2&#039;      // You can have one or more &#039;login&#039;=&gt;&#039;password&#039; lines
        );
</code></pre>
</ol>
</ol>
<h3> Setup Nginx for Rewrite</h3>
<p>Edit the nginx configuration for the domain.  The configuration of YOURLS provides an .htaccess file with rewrite rules which is fine for Apache, but not so well with nginx. </p>
<p><pre><code>

server {
  server_name www.zod.im www.zodim.com;
  rewrite ^(.*) http://zod.im$1 permanent;
}

server {
    listen   80;
    server_name zod.im;

    access_log /var/log/nginx/zod.im.access.log;
    error_log /var/log/nginx/zod.im.error.log;

    root   /var/www/zod.im/web/;
    index  index.php index.html;

    error_page    404    /404.php;

  location / {
    # If the file exists as a static file serve it directly without
    # running all the other rewite tests on it
    if (-f $request_filename) {
      expires max; 
      break; 
    }

    if (!-f $request_filename){
       set $rule_0 1$rule_0;
    }
    if (!-d $request_filename){
       set $rule_0 2$rule_0;
    }
    if ($rule_0 = &quot;21&quot;){
       rewrite ^/.* /yourls-loader.php last;
    }
  }
  location ~ .php$ {
    set  $script     $uri;
    set  $path_info  &quot;&quot;;

    if ($uri ~ &quot;^(.+\.php)(/.+)&quot;) {
      set  $script     $1;
      set  $path_info  $2;
    }

    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:5555;
    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /var/www/zod.im/web$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $path_info;
    fastcgi_intercept_errors on;

    root /var/www/zod.im/web;
  }
</code></pre></p>
<p>Restart nginx</p>
<h3> Go through setup </h3>
<p>Open browser and go to the admin page, login and go through initial setup process.</p>
<p>http://example.com/admin/</p>
<p>You get two screens to see.  First is initial welcome with button to install.  Click this and get the second telling you it has created the database tables.</p>

<a href='http://unrealexpectations.com/blog/2011/03/install-your-own-url-shortener/screen-shot-2011-03-04-at-10-17-54-pm/' title='YOURLS Install Screen 1'><img width="150" height="150" src="http://unrealexpectations.com/blog/wp-content/uploads/2011/03/Screen-shot-2011-03-04-at-10.17.54-PM-150x150.png" class="attachment-thumbnail" alt="YOURLS Install Screen 1" title="YOURLS Install Screen 1" /></a>
<a href='http://unrealexpectations.com/blog/2011/03/install-your-own-url-shortener/screen-shot-2011-03-04-at-10-18-28-pm/' title='YOURLS Install Screen Shot 2'><img width="150" height="150" src="http://unrealexpectations.com/blog/wp-content/uploads/2011/03/Screen-shot-2011-03-04-at-10.18.28-PM-150x150.png" class="attachment-thumbnail" alt="YOURLS Install Screen Shot 2" title="YOURLS Install Screen Shot 2" /></a>

<p>The second screen may complain about not being able to write the .htaccess file, but since nginx is used, that can easily be ignored.</p>
</ol>
<h2> Conclusion </h2>
<p>The process to create your own personal shortening service can take a little as little as 15 minutes with YOURLS.  It will probably take longer to figure out your short domain name and acquire it.</p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2011/03/install-your-own-url-shortener/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ForbesPrint.com and Open Source</title>
		<link>http://unrealexpectations.com/blog/2010/06/forbesprint-com-and-open-source/</link>
		<comments>http://unrealexpectations.com/blog/2010/06/forbesprint-com-and-open-source/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 04:22:40 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[slicehost]]></category>

		<guid isPermaLink="false">http://unrealexpectations.com/blog/?p=115</guid>
		<description><![CDATA[<p>A year ago, my wife, daughter and I visited my wife&#8217;s aunt and uncle in Waterford, Michigan area.  She signed me up to do a small web site for them to promote the printing business.  The printing business has been in the family since 1946. </p>
<p>I decided to use open source tools as [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago, my wife, daughter and I visited my wife&#8217;s aunt and uncle in Waterford, Michigan area.  She signed me up to do a small <a href="http://www.forbesprint.com/">web site</a> for them to promote the printing business.  The printing business has been in the family since 1946. </p>
<p>I decided to use open source tools as much as possible to deliver the site.  Long term, I don&#8217;t expect to have access to tools I use at work and I actually know I shouldn&#8217;t use tools from work to work on external projects. And so, I stayed with open source tools as much as possible.</p>
<p>I set up the website relatively quickly with ruby on rails, but did not launch it for awhile.  While I like the ruby on rails approach to rapid development I haven&#8217;t used ruby enough to learn the syntax and be productive in it.  In the meantime between developing the site and actually launching it, I worked on a project for a client that utilized <a href="http://www.symfony-project.org">symfony</a>.   This gave me enough opportunity and time to learn php and the symfony framework.  So the in-development site was migrated from a ruby on rails to symfony project.  </p>
<p>One thing I liked when I set up the rails project was the usage of <a href="http://www.capify.org">capistrano</a> to manage the deployment of the application to my slicehost instance.  I decided to see how it could work with symfony as well.  In the end, I was able to get a good amount of information from the following <a href="http://blog.codingspree.net/2008/5/12/deploying-symfony-project-with-capistrano/">site</a>.  Besides paths and server changes to the configuration presented on the page, I utilize git as version control.   </p>
<p>I have found great value in git over subversion.  I like the fact that git does not require server software to run.  Getting it <a href="http://articles.slicehost.com/2009/5/13/capistrano-series-setting-up-git">up and running</a> with just a dedicated user and ssh was a snap.  Even better, git doesn&#8217;t manage every file with 3 extra files per instance like subversion seems to do.  To copy a subversion branch from one server to another takes forever due to all the .svn files.  Git can easily be moved around and ability to remove git from a file structure works just as easily.  </p>
<p>In the end, I built the very small site, <a href="http://www.forbesprint.com/">ForbesPrint.com</a> with the following tools:</p>
<ul>
<li>php for scripting language</li>
<li>symfony for php framework</li>
<li>nginx for web server</li>
<li>fastcgi for php runtime environment</li>
<li>git for source control</li>
<li>gimp for image editing</li>
<li>slicehost for server hosting utilizing Ubuntu virtual machine</li>
<li>SpringSource Tool Set for IDE with Aptana Studio plugin for php project support</li>
</ul>
<p>Now that the basics are in place, I hope to expand the site to better accommodate their needs and growth the business.</p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2010/06/forbesprint-com-and-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAMP &amp; PECL/UUID Module Working On Snow Leopard</title>
		<link>http://unrealexpectations.com/blog/2010/04/mamp-pecluuid-module-working-on-snow-leopard/</link>
		<comments>http://unrealexpectations.com/blog/2010/04/mamp-pecluuid-module-working-on-snow-leopard/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 06:33:05 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[mac wizardry]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://unrealexpectations.com/blog/?p=107</guid>
		<description><![CDATA[<p>I had a previous article that discussed in detail on how to get imagick php plugin working on MAMP.   As always, as you get more exposed to technologies and frameworks you find new ways to do things.  One thing to keep in mind with MAMP is that 1.8.4 is still 32-bit build. [...]]]></description>
			<content:encoded><![CDATA[<p>I had a previous article that discussed in detail on how to get <a href="http://unrealexpectations.com/blog/2010/01/mamp-imagick-on-snow-leopard/">imagick</a> php plugin working on MAMP.   As always, as you get more exposed to technologies and frameworks you find new ways to do things.  One thing to keep in mind with MAMP is that 1.8.4 is still 32-bit build.  Once it goes 64-bit, I am sure the whole thing will get easier.</p>
<p>In this instance, I was working through adding UUID generation support to my PHP code.  While the <a href="http://php.net/manual/en/function.uniqid.php">uniqid</a> provides a function to generate IDs, it is not a <a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier">GUID specification</a>.  There is <a href="http://pecl.php.net/package/uuid">PECL UUID module</a> that provides &#8220;a wrapper around libuuid from the ext2utils project&#8221;.  After looking around for how to add it to MAMP, I came across the following <a href="http://smbjorklund.no/how-enable-pecl-uploadprogress-extention-mamp#SL">article</a> that talked about how to enable the uploadprogress module.  utilizing the same process I attempted to build the uuid module.  Unfortunately, the uuid module failed to compile.  This eventually lead to a <a href="http://pecl.php.net/bugs/bug.php?id=14503">defect report</a> for the uuid module about Mac OS X and older version of files.  Attached was a patch file; patched the files and remade.  Installed, reloaded and all was good.</p>
<p>The following are the steps I used for the installation of uuid module.</p>
<p><b> Download and extract the uuid module</b><br />
Grabbed the 1.2 version of the uuid module.<br />
<pre><code>
macbook:Downloads mleo$ wget http://pecl.php.net/get/uuid-1.0.2.tgz
...
mabook:Downloads mleo$ tar -xzf uuid-1.0.2.tgz 
macbook:Downloads mleo$ cd uuid-1.0.2
</code></pre></p>
<p><b> Get &#038; Apply Patch </b><br />
Copy patch code from <a href="http://pastie.org/435461">here</a>.   Save the contents into mac.patch file.  Apply patch.  It did require entry of the path to two test files during the patch process.<br />
<pre><code>
macbook:uuid-1.0.2 mleo$ patch &lt; mac.patch 
patching file config.m4
patching file php_uuid.h
can&#039;t find file to patch at input line 103
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urp uuid-1.0.2/tests/uuid_mac.phpt uuid-
|1.0.2.mine/tests/uuid_mac.phpt
|--- tests/uuid_mac.phpt  2008-04-01 08:59:22.000000000 -0700
|+++ tests/uuid_mac.phpt  2008-08-14 10:21:57.000000000 -0700
--------------------------
File to patch: tests/uuid_mac.phpt
patching file tests/uuid_mac.phpt
can&#039;t find file to patch at input line 116
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urp uuid-1.0.2/tests/uuid_time.phpt uuid-
|1.0.2.mine/tests/uuid_time.phpt
|--- tests/uuid_time.phpt  2008-04-01 08:59:22.000000000 -0700
|+++ tests/uuid_time.phpt  2008-08-14 10:22:50.000000000 -0700 
--------------------------
File to patch: tests/uuid_time.phpt
patching file tests/uuid_time.phpt
patching file uuid.c
</code></pre></p>
<p><b> Configure and Build the Module </b><br />
I&#8217;ll leave the prompts out of this one to make it easier to copy and paste the set of commands, but each line in the below code block is different command. </p>
<p><pre><code>
/Applications/MAMP/bin/php5/bin/phpize
MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp&quot;
CCFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot;
CXXFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot;
LDFLAGS=&quot;-arch i386 -arch x86_64 -bind_at_load&quot;
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config
make
make install
</code></pre></p>
<p><b> Add module to php.ini </b><br />
Edit the /Applications/MAMP/conf/php5/php.ini file and add &#8220;extension=uuid.so&#8221;.</p>
<p><b> Test Installation </b><br />
Can check info to see if uuid module loads and run the uuid_create() function to see if it returns.</p>
<p><pre><code>
macbook:uuid-1.0.2 mleo$ /Applications/MAMP/bin/php5/bin/php -r &#039;print phpinfo();&#039;
...
uuid
UUID extension

Version =&gt; 1.0.2 (stable)
Released =&gt; 2008-04-01
CVS Revision =&gt; $Id: uuid.c,v 1.9 2008/04/01 15:58:52 hholzgra Exp $
Authors =&gt; Hartmut Holzgraefe &#039;hartmut@php.net&#039; (lead)
...

macbook:uuid-1.0.2 mleo$ /Applications/MAMP/bin/php5/bin/php -r &#039;print uuid_create() . &quot;\n&quot;;&#039;
85C43B35-1416-435F-AEFF-3E4693ACEE65
macbook:uuid-1.0.2 mleo$ 

</code></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2010/04/mamp-pecluuid-module-working-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAMP &amp; Imagick on Snow Leopard</title>
		<link>http://unrealexpectations.com/blog/2010/01/mamp-imagick-on-snow-leopard/</link>
		<comments>http://unrealexpectations.com/blog/2010/01/mamp-imagick-on-snow-leopard/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 00:51:20 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[mac wizardry]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://unrealexpectations.com/blog/?p=60</guid>
		<description><![CDATA[<p>Most web searches for adding the imagick extension to MAMP suggest using MacPorts to install ImageMagick and then use this compiled version as the library to running &#8216;pecl install imagick&#8217;.</p>
<p>As I was in the process of setting up a clean Mac Book Pro, I tried going through this process.   I quickly ran into [...]]]></description>
			<content:encoded><![CDATA[<p>Most web searches for adding the imagick extension to <a href="http://www.mamp.info/en/index.html">MAMP</a> suggest using <a href="http://www.macports.org/">MacPorts</a> to install ImageMagick and then use this compiled version as the library to running &#8216;pecl install imagick&#8217;.</p>
<p>As I was in the process of setting up a clean Mac Book Pro, I tried going through this process.   I quickly ran into some problems getting the imagick extension running under MAMP.  This is a tail of that adventure.</p>
<p>I started with the latest version of MAMP 1.8.4 and MacPorts 1.8.2 installed.<br />
Then installed ImageMagick</p>
<p><pre><code>
$ sudo port install ImageMagick
</code></pre></p>
<p>This went off without a problem.  Could then easily run the &#8216;convert&#8217; program to see if is working.  Next step felt like to install imagick extension.</p>
<p><pre><code>
$ cd /Applications/MAMP/bin/php5/bin
</code></pre></p>
<p>And just make sure the right version of PECL is executed  via &#8216;./&#8217; else may get Mac OS X installed or even MacPorts installed version.</p>
<p><pre><code>
$ ./pecl install imagick
</code></pre></p>
<p>The process doesn&#8217;t stop with error, but immediately it has gripes about missing header files.</p>
<p><pre><code>
downloading imagick-2.3.0.tgz ...
Starting to download imagick-2.3.0.tgz (86,976 bytes)
.....................done: 86,976 bytes
12 source files, building
WARNING: php_bin /Applications/MAMP/bin/php5/bin/php appears to have a suffix 5/bin/php, but config variable php_suffix does not match
running: phpize

grep: /Applications/ MAMP/bin/php5/include/php/main/php.h: No such file or directory

grep: /Applications/ MAMP/bin/php5/include/php/Zend/zend_modules.h: No such file or directory

grep: /Applications/ MAMP/bin/php5/include/php/Zend/zend_extensions.h: No such file or directory

Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
configure.in:158: warning: AC_CACHE_VAL(lt_prog_compiler_static_works, ...): suspicious cache-id, must contain _cv_ to be cached
../../lib/autoconf/general.m4:1998: AC_CACHE_VAL is expanded from...
...
aclocal.m4:4641: _LT_AC_TAGCONFIG is expanded from...
Please provide the prefix of Imagemagick installation [autodetect] : 
$
</code></pre></p>
<p>The first problem encountered was simply getting &#8216;pecl&#8217; to compile the imagick extension as the MAMP distribution does not include the php headers where pecl is expecting them.</p>
<p>There is probably a way to get pecl to pick them up properly, but in the interest of time, one can just create a link from</p>
<p><pre><code>
$ cd /Applications/MAMP/bin/php5

$ ln -s /Applications/MAMP/Library/include include

</code></pre><br />
And then re-run &#8216;pecl&#8217;</p>
<p><pre><code>
$ ./pecl install imagick
...
Please provide the prefix of Imagemagick installation [autodetect] : /opt/local
building in /var/tmp/pear-build-mleo/imagick-2.3.0
running: /private/tmp/pear/temp/imagick/configure --with-imagick=/opt/local
...
</code></pre></p>
<p>and provide &#8216;/opt/local&#8217; when prompted for prefix of Imagemagick installation.  Everthing seemed to go well.  Finally, modified /Applications/MAMP/conf/php5/php.ini to add</p>
<p><pre><code>
extenstion=imagick.so
</code></pre></p>
<p>And modified /Applications/MAMP/Library/bin/envvars to add</p>
<p><pre><code>
DYLD_LIBRARY_PATH=&quot;/Applications/MAMP/Library/lib:/opt/local/lib:$DYLD_LIBRARY_PATH&quot;
</code></pre></p>
<p>Finally ran:</p>
<p><pre><code>
$ /Applications/MAMP/bin/php5/bin/php -i | less
</code></pre></p>
<p>to see if it was enabled.  Unfortunately, the imagick module was not listed.  After a little investigation, in the php error log was the following entry:</p>
<p><pre><code>
PHP Warning:  PHP Startup: Unable to load dynamic library &#039;/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/imagick.so&#039; - (null) in Unknown on line 0
</code></pre></p>
<p>After some various searching and other, checking what I did wrong, I finally considered the files:</p>
<p><pre><code>
$ file /Applications/MAMP/bin/php5/bin/php
/Applications/MAMP/bin/php5/bin/php: Mach-O universal binary with 2 architectures
/Applications/MAMP/bin/php5/bin/php (for architecture ppc):  Mach-O executable ppc
/Applications/MAMP/bin/php5/bin/php (for architecture i386):  Mach-O executable i386</code></pre></p>
<p><code> </code></p>
<p><pre><code>$ file /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/imagick.so
/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/imagick.so (for architecture x86_64):  Mach-O 64-bit x86_64
</code></pre></p>
<p>So discovered that MAMP is a Universal binary, just not an x86_64 universal binary.  So, first, make sure to rebuild imagick.so with i386 binary support and just to be safe, add those settings for the php header files as well.</p>
<p>So, back to the php distribution and run configure setting some flags, although this may not be needed, it can&#8217;t hurt.<br />
<pre><code>
$ MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp&quot; CCFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot; CXXFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot; LDFLAGS=&quot;-arch i386 -arch x86_64 -bind_at_load&quot;  ./configure --enable-shared</code></pre></p>
<p><code> </code></p>
<p><pre><code>loading cache ./config.cache
checking for Cygwin environment... (cached) no
...
</code></pre></p>
<p>Copy the headers back to MAMP location.  And re-run pecl to build universal binary.</p>
<p><pre><code>
$ ./pecl uninstall imagick</code></pre></p>
<p><code> </code></p>
<p><pre><code>$ MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp&quot; CCFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot; CXXFLAGS=&quot;-arch i386 -arch x86_64 -g -Os -pipe&quot; LDFLAGS=&quot;-arch i386 -arch x86_64 -bind_at_load&quot;  ./pecl install imagick
</code></pre></p>
<p>Run php printinfo and<br />
<pre><code>
$ /Applications/MAMP/bin/php5/bin/php -i | less</code></pre></p>
<p><code> </code></p>
<p><pre><code>dyld: NSLinkModule() error
dyld: Library not loaded: /opt/local/lib/libMagickWand.2.dylib
Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/imagick.so
Reason: no suitable image found.  Did find:
/opt/local/lib/libMagickWand.2.dylib: mach-o, but wrong architecture
</code></pre></p>
<p>And discover that MacPorts isn&#8217;t creating universal binaries.<br />
<pre><code>
$ file /opt/local/lib/libMagickCore.2.dylib
/opt/local/lib/libMagickCore.2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
</code></pre></p>
<p>Again, head to the favorite search engine and look at how MacPorts can work with Universal binaries.  After some criteria changes came across this simple set of <a href="http://rcaguilar.wordpress.com/2009/11/04/universal-binaries-in-macports/">details</a>.</p>
<p>MacPorts provides a variant +universal for all installs that use configure script to initialize build process that will build Universal binaries.  The specific architecture has some defaults based on the OS and current hardware.</p>
<p>A bit of pain to add +universal to every port install command, so make +universal, uh, universal it can be added to the /opt/local/etc/macports/variants.conf file as last line:</p>
<p><pre><code>
# To specify global variants to use for all port builds,
# customize this file to list variant settings you want.
#
# Be sure to uncomment/define the variants_conf setting
# in the system wide ${prefix}/etc/macports/macports.conf
# file or in your personal ~/.macports/macports.conf to
# point to this file to enable this feature.
#
# Any variants specified here that are not supported by
# a port will just be ignored. Multiple variants can be
# specified per line, or one per line is also allowed.
#
# Example:
# +ipv6 +no_x11
+universal
</code></pre></p>
<p>And to force a rebuild of anything you have installed</p>
<p><pre><code>
sudo port upgrade --force installed
</code></pre></p>
<p>Finally, we try php again:</p>
<p><pre><code>
$ /Applications/MAMP/bin/php5/bin/php -i | less</code></pre></p>
<p><pre><code>...
imagick

imagick module =&amp;gt; enabled
imagick module version =&amp;gt; 2.3.0
imagick classes =&amp;gt; Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version =&amp;gt; ImageMagick 6.5.8-0 2010-01-05 Q16 http://www.imagemagick.org
ImageMagick copyright =&amp;gt; Copyright (C) 1999-2009 ImageMagick Studio LLC
ImageMagick release date =&amp;gt; 2010-01-05
ImageMagick Number of supported formats:  =&amp;gt; 194
ImageMagick Supported formats =&amp;gt; 3FR, A, AI, ART, ARW, AVI, AVS, B, BGR, BMP, BMP2, BMP3, BRF, BRG, C, CAL, CALS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FITS, FRACTAL, FTS, G, G3, GBR, GIF, GIF87, GRADIENT, GRAY, GRB, GROUP4, HALD, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, INFO, INLINE, IPL, ISOBRL, JNG, JPEG, JPG, K, K25, KDC, LABEL, M, M2V, M4V, MAP, MAT, MATTE, MIFF, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NULL, O, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RADIAL-GRADIENT, RAF, RAS, RBG, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, Y, YCbCr, YCbCrA, YUV

Directive =&amp;gt; Local Value =&amp;gt; Master Value
imagick.locale_fix =&amp;gt; 0 =&amp;gt; 0
imagick.progress_monitor =&amp;gt; 0 =&amp;gt; 0

</code></pre></p>
<p><pre><code>...
</code></pre></p>
<p>Somewhere during this adventure I definitely considered dumping MAMP and using apache, php and mysql from MacPorts but MAMP does generally provide a simple package installation and a GUI for quickly starting and stopping the services.</p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2010/01/mamp-imagick-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nginx, FastCGI, WordPress Permalink &amp; &#8220;No Input file specified&#8221;</title>
		<link>http://unrealexpectations.com/blog/2010/01/nginx-fastci-wordpress-no-input-file-specified/</link>
		<comments>http://unrealexpectations.com/blog/2010/01/nginx-fastci-wordpress-no-input-file-specified/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 04:25:58 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[slicehost]]></category>

		<guid isPermaLink="false">http://www.unrealexpectations.com/blog/?p=17</guid>
		<description><![CDATA[<p>If you have spent any time recently look into the state of web servers then you know that nginx is getting recommended as the replacement for apache left, right and center.  Apache has a rich history, platform extensive, and highly extensible, and while these are great traits it&#8217;s 15 years of legacy code hasn&#8217;t seemed [...]]]></description>
			<content:encoded><![CDATA[<p>If you have spent any time recently look into the state of web servers then you know that nginx is getting recommended as the replacement for apache left, right and center.  Apache has a rich history, platform extensive, and highly extensible, and while these are great traits it&#8217;s 15 years of legacy code hasn&#8217;t seemed to keep pace with some of the modern design patterns such non-blocking i/o and simple configuration.  To apache developers&#8217; credit it is built to support a wide array of architectures and operating systems.</p>
<p>There is definitely a fair amount of information out there on how to get nginx running with WordPress via FastCGI.  Slicehost, my current hosting provider, offers a wealth of <a href="http://articles.slicehost.com/nginx">articles </a>on setting up nginx along with a rails cluster. I followed several other <a href="http://codeintensity.blogspot.com/2008/08/wordpress-nginx-subdirectories-and.html">articles</a> in getting FastCGI working through spawn-fcgi with requisite<a href="http://saturnboy.com/2008/10/nginx-init-script/"> init scripts</a> to ensure everything starts up properly.  Everything was working great until I enabled <a href="http://codex.wordpress.org/Using_Permalinks">pretty permalinks</a> and then got the unfortunate error:</p>
<p><code>No input file specified.</code></p>
<p>I understood this to mean FastCGI could find the script attempting to be called, but couldn&#8217;t immediately see why that was the case.  In the end it was something simple and obvious.</p>
<p>My initial configuration server configuration looked something like:</p>
<p><pre><code>
server {
  listen   80;
...
  location / {
    # this serves static files that exist without running other rewrite tests
    if (-f $request_filename) {
      expires 30d;
      break;
    }

    # this sends all non-existing file or directory requests to index.php
    if (!-e $request_filename) {
      rewrite ^.+?(/.*\.php)$ $1 last;
      rewrite ^ /index.php last;
    }
  }

  location ~ .php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /var/www/html/www/public$fastcgi_script_name;

    root /var/www/html/www/public;
  }
}
</code></pre></p>
<p>And searching there were other suggestions for the rewrite as:</p>
<p><pre><code>
    # this sends all non-existing file or directory requests to index.php
    if (!-e $request_filename) {
      rewrite ^(.+)$ /index.php?q=$1 last;
    }
</code></pre></p>
<p>Which made no difference in the error condition.  As I said in the end, the problem was something obvious.  In my configuration, the wordpress installation is not at the root of the web server, rather it is in a subdirectory called <strong>blog</strong>.  Therefore, with the initial configuration when a path could not be found, rather than call the wordpress index.php script located at /blog/index.php, it was calling just /index.php which initially didn&#8217;t exist.  Had it existed, I probably would have quickly see which file was getting called and how to address.  The change was to set up the wordpress rewrite information in the correct location block.  The updated configuration became:</p>
<p><pre><code>
  location /blog {
    # this serves static files that exist without running other rewrite tests
    if (-f $request_filename) {
      expires 30d;
      break;
    }

    # this sends all non-existing file or directory requests to index.php
    if (!-e $request_filename) {
      rewrite ^.+?(/.*\.php)$ $1 last;
      rewrite ^ /blog/index.php last;

    }
  }
</code></pre></p>
<p>I haven&#8217;t yet configured out the &#8220;No Input file specified&#8221; when a bad php url is used, but that will probably be done shortly.</p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2010/01/nginx-fastci-wordpress-no-input-file-specified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

