<?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; nginx</title>
	<atom:link href="http://unrealexpectations.com/blog/category/nginx/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>Video, from Camcorder to Nginx Flash Streaming</title>
		<link>http://unrealexpectations.com/blog/2010/01/video-from-camcorder-to-nginx-flash-streaming/</link>
		<comments>http://unrealexpectations.com/blog/2010/01/video-from-camcorder-to-nginx-flash-streaming/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 06:44:28 +0000</pubDate>
		<dc:creator>mleo</dc:creator>
				<category><![CDATA[mac wizardry]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://unrealexpectations.com/blog/?p=36</guid>
		<description><![CDATA[<p>About two years ago before my daughter was born I talked my wife into the value of having a video camera to record all those wonderful moments that kids are supposed to have.  At the time I was a fan of Sony products and we ended up purchasing the Sony HDR-SR5 High Definition Camcorder. [...]]]></description>
			<content:encoded><![CDATA[<p>About two years ago before my daughter was born I talked my wife into the value of having a video camera to record all those wonderful moments that kids are supposed to have.  At the time I was a fan of Sony products and we ended up purchasing the <a href="http://www.sonystyle.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10551&#038;storeId=10151&#038;langId=-1&#038;productId=8198552921665089060">Sony HDR-SR5</a> High Definition Camcorder.  I have actually had no complaints with the operation of the camera itself and didn&#8217;t give much thought to the need to pull video off the camera and what I would do with it once I did pull it off.</p>
<p>My daughter came and we filmed various moments early on and my first attempt to pull the video off the camera did not go so well.  I had a copy of Adobe Premiere Elements 4 or something.  It was purchased along with Adobe Elements that I mainly use for organizing all the digital photos of my daughter.  Much to my dismay, I quickly discovered that Premiere Elements did not support <a href="http://en.wikipedia.org/wiki/AVCHD">AVCHD</a>, Sony&#8217;s format format for encoding video on their camcorders.  While I liked Sony hardware and they offered some software for dealing with AVCHD, I don&#8217;t care for OEM software included with hardware as it is often feature limited with a horrible user experience and included purely to ensure there is some way to access the content the user has created.  I don&#8217;t envy the developers who have to put those applications together as they are probably given next to no time to work on it and lack adequate numbers of competent developers to get it complete.  </p>
<p>So eventually the disk on the camcorder was starting to get full and I needed to pull the video off of the drive.  I had purchased a Mac Mini for use in the kitchen to play DVDs, iTunes Videos, and access <a href="http://www.foodnetwork.com/recipes/paula-deen/crab-cakes-with-lemon-dill-sauce-recipe/index.html">recipes</a> off the web.  I finally discovered that iMovie &#8217;08 has support for AVCHD and could import the videos off the camera.  Initially it was more about getting the videos off the camera and freeing the camera&#8217;s hard disk more than making them available in any sort of way to anyone.</p>
<p>On a recent client engagement for work we are working with a music company that is rebuilding their eCommerce platform from the ground up.  Part of the solution we designed and built incorporated videos that are streamed using Akamai fronted by Flow Player.  We ran into some of the oddest issues with missing files and integrating the Akamai streams.<br />
As I was setting up nginx recently to get this site running, I revisited the details that nginx has built-in support for FLV HTTP Streaming. This doesn&#8217;t provide any real protection of the stream, but does provide an ability for users to quickly start watching the video and forward to any point in the video without needing to download everything up to that point.  In thinking about the possibility of incorporating this, I finally found a reason to do something fun with the videos and make them available to family to view.  The following is a list of the steps I did to get this enabled.</p>
<h2>1. Importing the Video From Camera</h2>
<p>This was a pretty simple process with iMovie.  The only problem I ran into is that it seems iMovie needs to be up and running when the camera is set to computer mode otherwise iMovie doesn&#8217;t seem to recognize it as a camera.  When not running, the camera would connect in MacOS X and appear as a hard drive that could be opened and have images pulled from, but when iMovie started, it does not see it.  What tripped me up most before I realized this is that I tried it on a Mac Book Pro (with iMovie running) and it came right up for importing, but when I tried with my Mini (without iMovie running) it did not appear.</p>
<p>So step one was to connect the camera while iMovie was running and import the appropriate clips into an iMovie event.  </p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-1.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-1-300x179.png" alt="" title="iMovie &#039;09 Import From Camera" width="300" height="179" class="alignnone size-medium wp-image-39" /></a></p>
<h2>2. Create the Movie</h2>
<p>I won&#8217;t get into the details on how to create the project from the imported movie, but suffice it to say, iMovie makes it easy to select parts or all of the imported video and create titles and transitions and apply effects to the movie.  Once the project is ready, go to Share>Export Movie&#8230; to open a dialog.  I exported the movie as Medium and time yet will tell if that is too large for friends and family to view.  </p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imoveimport-2.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imoveimport-2.png" alt="" title="iMovie &#039;09 Share Menu" width="289" height="300" class="alignnone size-full wp-image-40" /></a></p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-3.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-3-300x188.png" alt="" title="iMovie &#039;09 Export Movie" width="300" height="188" class="alignnone size-medium wp-image-41" /></a></p>
<p>One additional point before leaving iMovie is the creation of still image to use as title slide before the movie starts.  When the flash video player loads, it doesn&#8217;t start playing the movie unless the user actively clicks the play button.  It can be configured to start automatically, but I personally find sites that do that annoying as I am sure many other people do as well.  Since the player doesn&#8217;t start loading the video automatically, there is no way for the player to present a frame of the video as place holder.  To provide a better experience to users, a still frame should be produced and provided to the flash player to use at startup.  With it specified, the player will present the image with a play button in place.<br />
To generate the a still image from iMovie is not the most obvious thing to do, though once the process is understood, it is not difficult to do.  I eventually found the information on how to do this <a href="http://imovie08.blogspot.com/2007/08/how-to-capture-still-image-from-clip.html">here</a>.  The short information on the process is to create a project with a small clip including the frame you want to capture and then use Share>Export using Quicktime.  </p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport5.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport5.png" alt="" title="Export Using Quicktime" width="272" height="286" class="alignnone size-full wp-image-45" /></a></p>
<p>This will bring up the &#8220;Save export file as&#8230;&#8221; dialog box with two drop downs.  In the first, Export, choose &#8220;Movie to Image Sequence&#8221;</p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport6.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport6-300x93.png" alt="" title="Export Movie as Image Sequence" width="300" height="93" class="alignnone size-medium wp-image-46" /></a></p>
<p>In the second drop down, make a choice on how the export should occur and image format used with the export.</p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport7.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport7-300x180.png" alt="" title="Export Movie as Image Sequence Settings" width="300" height="180" class="alignnone size-medium wp-image-47" /></a></p>
<p>Depending on how long the clip is and how many frames per second are set on export, a few images will be generated that need to be sifted through to find the right one.</p>
<h2>3. Convert to Flash Video</h2>
<p>Once the movie is exported, the next step is to convert it into flash video.  In order to perform this transcoding I used <a href="http://www.ffmpegx.com/">ffmpegx</a> that provides a graphical user interface to several utilities that perform the actual encoding.    The <a href="http://www.ffmpegx.com/download.html">download</a> page has all the details on how to install and initially configure the application.  There are specific notes on the page on how to enable the FLV encoding.</p>
<p>Once it was up and running it was nearly as dragging and dropping the source movie,  choosing the output encoding, and clicking Encode.  The only added effort was making changes to the output size and settings.  Once set, click Encode and wait for the computer to do the dirty work.</p>
<p><a href="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-4.png"><img src="http://unrealexpectations.com/blog/wp-content/uploads/2010/01/imovieimport-4-300x250.png" alt="" title="ffmpegX user interface" width="300" height="250" class="alignnone size-medium wp-image-42" /></a></p>
<p>ffmpegX is licensed as shareware.  So far I have only encoded a small number of videos but could easily see doing more and paying the shareware fee.</p>
<h2>4. Enable nginx Flash Streaming</h2>
<p>The video is encoded as flash video and now it is time to ensure nginx is configured to stream the file over HTTP.  In the server block for the given virtual host, just adding an additional location block is all that is needed.</p>
<p><pre><code>
    location ~ \.flv$ {
      root   /home/mleo/www/public/;
      flv;
    }
</code></pre></p>
<p>The <a href="http://wiki.nginx.org/NginxHttpFlvStreamModule">flv</a> directive ensure the necessary meta data is sent with an flv file response and incoming requests with file seek data are handled properly and the data is sent back as requested.</p>
<h2>5. Embed the Flash Video in Page</h2>
<p>I&#8217;ll skip over the step on copying the flv file from local computer to the server and move on to the final step of configuring a flash video player to consume the video, splash image, and stream via http.  In my case I chose to use <a href="http://www.longtailvideo.com/">JW Player</a> which offers a non-commercial license which can be used on sites with no advertising (like this one).   Once the package is downloaded and installed on the server, minimally consisting of the swfobject.js, player.swf and some supporting files, one can use the <a href="http://www.longtailvideo.com/support/jw-player-setup-wizard?example=201">setup wizard</a> to initially configure the settings.  Most of the defaults are fine, but the most immediate settings to change include:</p>
<ul>
<li>height: The video dimension height</li>
<li>width: The video dimension width</li>
<li>file: The path to the flv file</li>
<li>image: The path to the splash image</li>
<li>provider: Set to &#8220;http&#8221; in order to enable http streaming</li>
</ul>
<p>The following is the sample code for the video embedded  below.</p>
<p>These few settings are all that is needed to embed the video player and have it function.  JW Player offers all sorts of additional plugins and skins, but for simple video sharing that isn&#8217;t really needed.</p>
<p><pre><code>
&lt;script type=&#039;text/javascript&#039; src=&#039;/media/swfobject.js&#039;&gt;&lt;/script&gt;

&lt;div id=&#039;mediaspace&#039;&gt;This text will be replaced&lt;/div&gt;
 
&lt;script type=&#039;text/javascript&#039;&gt;
  var so = new SWFObject(&#039;/media/player.swf&#039;,&#039;mpl&#039;,&#039;640&#039;,&#039;360&#039;,&#039;9&#039;);
  so.addParam(&#039;allowfullscreen&#039;,&#039;true&#039;);
  so.addParam(&#039;allowscriptaccess&#039;,&#039;always&#039;);
  so.addParam(&#039;wmode&#039;,&#039;opaque&#039;);
  so.addVariable(&#039;file&#039;,&#039;/media/SampleVideo.flv&#039;);
  so.addVariable(&#039;image&#039;,&#039;/media/SampleVideo.png&#039;);
  so.addVariable(&#039;provider&#039;,&#039;http&#039;);
  so.write(&#039;mediaspace&#039;);
&lt;/script&gt;
</code></pre></p>
<h3> Sit back and enjoy streaming video</h3>
<p>The following video is of my daughter&#8217;s day care holiday show. It is the first of my videos to be imported, encoded, and streamed.</p>
<p><script type='text/javascript' src='/media/swfobject.js'></script></p>
<div id='mediaspace'>This text will be replaced</div>
<p><script type='text/javascript'>
  var so = new SWFObject('/media/player.swf','mpl','640','360','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file','/media/SampleVideo.flv');
  so.addVariable('image','/media/SampleVideo.png');
  so.addVariable('provider','http');
  so.write('mediaspace');
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://unrealexpectations.com/blog/2010/01/video-from-camcorder-to-nginx-flash-streaming/feed/</wfw:commentRss>
		<slash:comments>1</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>

