<?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>david winter &#187; howto</title>
	<atom:link href="http://davidwinter.me.uk/articles/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidwinter.me.uk</link>
	<description>you were expecting someone else?</description>
	<lastBuildDate>Mon, 28 Jun 2010 20:37:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using o2 PAYG mobile broadband</title>
		<link>http://davidwinter.me.uk/articles/2010/06/19/using-o2-payg-mobile-broadband/</link>
		<comments>http://davidwinter.me.uk/articles/2010/06/19/using-o2-payg-mobile-broadband/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 21:34:42 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[o2]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=195</guid>
		<description><![CDATA[Our internet connection via our landline has been dead since Tuesday afternoon, so I&#8217;ve needed an alternative connection in the meantime to give me my twitter fix! I&#8217;d kept an eye on the o2 pay-as-you-go mobile broadband for a while, because it offered the cheapest, noncommittal setup. A one off £20 for the USB dongle, [...]]]></description>
			<content:encoded><![CDATA[<p>Our internet connection via our landline has been dead since Tuesday afternoon, so I&#8217;ve needed an alternative connection in the meantime to give me my twitter fix! </p>

<p>I&#8217;d kept an eye on the o2 pay-as-you-go mobile broadband for a while, because it offered the cheapest, noncommittal setup. A one off £20 for the USB dongle, and then as little as £2 for 500MB for a 24 hour period. </p>

<p>So I plug in the dongle and we get a nice little installer to set everything up; installing drivers and the o2 Mobile Connect application. The annoying thing is that if you install going this route, you can only connect if you have this app open. You can&#8217;t just use system preferences. Also, turns out this &#8216;handy&#8217; installer program then blocks you from getting to the installation files again, and the dongle will refuse to do anything unless Mobile Connect is open (you&#8217;ll get a red light on the dongle when it&#8217;s being evil).</p>

<p>So, what can you do?</p>

<p><span id="more-195"></span></p>

<ol>
<li>Drag <code>Mobile Connect.app</code> to the trash from your Applications directory. </li>
<li>Then head into System > Library > Extensions and delete <code>ZTEUSBCDCACMData.kext</code> and <code>ZTEUSBMassStorageFilter.kext</code></li>
<li>Go into Network in System Preferences and remove the devices starting with ZTEUSB.</li>
<li>Then restart your Mac.</li>
</ol>

<p>Now, let&#8217;s install things a different route giving everyone more flexibility.</p>

<ol>
<li>Plug in the dongle and when the CD Icon appears on the desktop, open it up, but rather than double clicking on the installer, right click on it and select &#8216;Show Package Contents&#8217;. </li>
<li>Now head to Contents then Resources. Now double click on the <code>drv.pkg</code> file and install this only. </li>
<li>Once complete, restart your Mac again. </li>
</ol>

<p>And now to configure the connection:</p>

<ol>
<li>Open System Preferences, and go to the Network pane. </li>
<li>You should have three new items in there. Click on ZTEUSBModem. </li>
<li>Set the telephone number to <code>*99#</code></li>
<li>Username to <code>o2bb</code></li>
<li>Password to <code>password</code> </li>
<li>Click on Advanced. Select Vendor; Generic, Model; GPRS (GSM/3G) and set the APN to <code>m-bb.o2.co.uk</code> </li>
<li>Click on OK and then Apply. </li>
<li>Now you can click &#8216;Connect&#8217; and all should work fine. </li>
</ol>

<p>That is of course, besides the crappy image compression and caching o2 force onto you! Need to find a solution for that next.</p>

<p><strong>Update</strong>: Here&#8217;s a solution for getting around the image compression, and Javascript injection; use a SSH SOCKS proxy. Works a treat.</p>

<ol>
<li>Open up <code>Terminal.app</code></li>
<li>Run <code>ssh -ND 9999 username@yourserver.com</code></li>
<li>Enter your password if/when prompted (you may have key authentication setup)</li>
<li>That&#8217;s the SOCKS proxy setup. Now go to System Preferences and open the network connection.</li>
<li>Click on ZTEUSBModem.</li>
<li>Then Advanced, Proxies</li>
<li>Check the SOCKS Proxy and enter in <code>localhost</code> and <code>9999</code></li>
<li>Click OK and then Apply.</li>
</ol>

<p>All done. You should now get perfect images and no longer have Javascript inserted into all webpages. Both of which weren&#8217;t clearly mentioned when purchasing my dongle.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2010/06/19/using-o2-payg-mobile-broadband/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirecting Apache traffic to a maintenance page</title>
		<link>http://davidwinter.me.uk/articles/2010/05/03/redirecting-apache-traffic-to-a-maintenance-page/</link>
		<comments>http://davidwinter.me.uk/articles/2010/05/03/redirecting-apache-traffic-to-a-maintenance-page/#comments</comments>
		<pubDate>Mon, 03 May 2010 18:54:21 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=173</guid>
		<description><![CDATA[Here&#8217;s a simple solution to redirect users to a maintenance page in Apache. This rewrite rule can stay in your config (&#60;VirtualHost&#62; or .htaccess) all the time; all that you need to enable it is to create the file maintenance.html. The first rewrite condition checks to see if the file exists, and only if it [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple solution to redirect users to a maintenance page in Apache. This rewrite rule can stay in your config (<code>&lt;VirtualHost&gt;</code> or <code>.htaccess</code>) all the time; all that you need to enable it is to create the file <code>maintenance.html</code>.</p>

<p>The first rewrite condition checks to see if the file exists, and only if it does, will it redirect all traffic to it. The second rewrite condition is there to prevent an infinite loop, by  only redirecting traffic to files other than <code>maintenance.html</code>.</p>

<pre><code>RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$    /maintenance.html [L]
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2010/05/03/redirecting-apache-traffic-to-a-maintenance-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and nginx on Ubuntu: the easy way</title>
		<link>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/</link>
		<comments>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 19:31:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=139</guid>
		<description><![CDATA[I&#8217;ve now changed my slice from running lighttpd to nginx. Here&#8217;s the simplest way, in around 6 commands, to get PHP up and running via FastCGI. Install and setup Install PHP 5: sudo aptitude install php5-cgi Install nginx: sudo aptitude install nginx Create PHP 5 FastCGI start-up script: sudo nano /etc/init.d/php-fastcgi Inside, put: #!/bin/bash BIND=127.0.0.1:9000 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve now changed my slice from running lighttpd to nginx. Here&#8217;s the simplest way, in around 6 commands, to get PHP up and running via FastCGI.</p>

<h2>Install and setup</h2>

<p>Install PHP 5:</p>

<pre><code>sudo aptitude install php5-cgi
</code></pre>

<p>Install nginx:</p>

<pre><code>sudo aptitude install nginx
</code></pre>

<p>Create PHP 5 FastCGI start-up script:</p>

<pre><code>sudo nano /etc/init.d/php-fastcgi
</code></pre>

<p>Inside, put:</p>

<pre><code>#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}

case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL
</code></pre>

<p>Make start-up script executable:</p>

<pre><code>sudo chmod +x /etc/init.d/php-fastcgi
</code></pre>

<p>Launch PHP:</p>

<pre><code>sudo /etc/init.d/php-fastcgi start
</code></pre>

<p>Launch at start-up:</p>

<pre><code>sudo update-rc.d php-fastcgi defaults
</code></pre>

<p>That&#8217;s it. All installed and ready to go.</p>

<h2>Test</h2>

<p>In your server config, add the following:</p>

<pre><code>location ~ \.php$ {
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
    include         fastcgi_params;
}
</code></pre>

<p>Restart nginx:</p>

<pre><code>sudo /etc/init.d/nginx restart
</code></pre>

<p>Create a file in your web root (in the example above, /var/www/nginx-default/test.php):</p>

<pre><code>&lt;?php

phpinfo();
</code></pre>

<p>Visit the page in your browser and you should see the standard PHP info page. And you&#8217;re done.</p>

<p>Source: <a href="http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/">Aberration</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Authentication with CodeIgniter</title>
		<link>http://davidwinter.me.uk/articles/2009/02/21/authentication-with-codeigniter/</link>
		<comments>http://davidwinter.me.uk/articles/2009/02/21/authentication-with-codeigniter/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 17:37:52 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=127</guid>
		<description><![CDATA[Here&#8217;s how I do some basic authentication for a controller in CodeIgniter. It basically consists of creating a new class that extends the default Controller class. You then sub-class this on any controller that requires authentication. Create your authentication controller in system/application/libraries and call it MY_Controller.php. It&#8217;s important that you prefix the controller name with [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how I do some basic authentication for a controller in <a href="http://codeigniter.com/">CodeIgniter</a>. It basically consists of creating a new class that extends the default <code>Controller</code> class. You then sub-class this on any controller that requires authentication.</p>

<p><span id="more-127"></span></p>

<p>Create your authentication controller in <code>system/application/libraries</code> and call it <code>MY_Controller.php</code>. It&#8217;s important that you prefix the controller name with <code>MY_</code>, or whatever you have specified <code>$config['subclass_prefix']</code> as in your configuration.</p>

<pre><code>&lt;?php

class MY_Controller extends Controller
{
    public function __construct()
    {
        parent::__construct();
        $this-&gt;load-&gt;library('session');
        if (!$this-&gt;session-&gt;userdata('loggedin'))
        {
            header('Location: /sessions/login');
        }
    }
}
</code></pre>

<p>This basically checks if the session data for <code>loggedin</code> is set to <code>true</code>. If not, it&#8217;ll redirect the user to the <code>/sessions/login</code> URL. This means we have to create a basic controller to handle the sessions.</p>

<pre><code>&lt;?php

class Sessions extends Controller
{
    public function __construct()
    {
        parent::__construct();
        $this-&gt;load-&gt;library('session');
    }

    public function login()
    {
        $this-&gt;load-&gt;view('header');
        $this-&gt;load-&gt;view('sessions/login');
        $this-&gt;load-&gt;view('footer');
    }

    public function authenticate()
    {
        $this-&gt;load-&gt;model('user', '', true);
        if ($this-&gt;user-&gt;authenticate($this-&gt;input-&gt;post('username'), $this-&gt;input-&gt;post('password')))
        {
            $this-&gt;session-&gt;set_userdata('loggedin', true);
            header('Location: /');
        }
        else
        {
            header('Location: /sessions/login');
        }
    }

    public function logout()
    {
        $this-&gt;session-&gt;unset_userdata('loggedin');
        header('Location: /');
    }
}
</code></pre>

<p>The <code>login</code> view is a basic form with fields for <code>username</code> and <code>password</code> that submits to <code>/sessions/authenticate</code>. This controller then loads the user model and checks that a user with the username and password exists. If so, it sets the session data for <code>loggedin</code> to <code>true</code> and redirects the user back to the default controller. If not, it takes the user back to the login page.</p>

<p>Then to implement the authentication in a controller, simply do:</p>

<pre><code>&lt;?php

class SecretPlace extends MY_Controller
{
...
</code></pre>

<p>It&#8217;s a good idea to <a href="http://codeigniter.com/user_guide/libraries/sessions.html">store your session data in your database</a> and encrypt your cookies with <code>$config['sess_encrypt_cookie'] = TRUE;</code> in <code>config.php</code>. That way people won&#8217;t be able to snoop around and try to trick your application into thinking they&#8217;re authenticated.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2009/02/21/authentication-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Hide GIT or SVN files with lighttpd</title>
		<link>http://davidwinter.me.uk/articles/2009/02/20/hide-git-or-svn-files-with-lighttpd/</link>
		<comments>http://davidwinter.me.uk/articles/2009/02/20/hide-git-or-svn-files-with-lighttpd/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 18:01:43 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lighttpd]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2009/02/20/hide-git-or-svn-files-with-lighttpd/</guid>
		<description><![CDATA[Add this to the bottom of your lighttpd.conf file: $HTTP["url"] =~ "/\.(git&#124;svn)/" { url.access-deny = ( "" ) }]]></description>
			<content:encoded><![CDATA[<p>Add this to the bottom of your <code>lighttpd.conf</code> file:</p>

<pre><code>$HTTP["url"] =~ "/\.(git|svn)/" {
    url.access-deny = ( "" )
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2009/02/20/hide-git-or-svn-files-with-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install pecl_http for PHP</title>
		<link>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/</link>
		<comments>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 21:33:41 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pecl_http]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=117</guid>
		<description><![CDATA[You will probably want to ensure that curl supports https before getting underway: curl -V Check that the output contains https: &#62;: curl -V curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3 Protocols: tftp ftp telnet dict http file https ftps Features: Largefile NTLM SSL libz If it doesn&#8217;t: sudo port deactivate curl sudo port install curl [...]]]></description>
			<content:encoded><![CDATA[<p>You will probably want to ensure that <code>curl</code> supports <code>https</code> before getting underway:</p>

<pre><code>curl -V
</code></pre>

<p>Check that the output contains <code>https</code>:</p>

<pre><code>&gt;: curl -V
curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3
Protocols: tftp ftp telnet dict http file https ftps 
Features: Largefile NTLM SSL libz
</code></pre>

<p>If it doesn&#8217;t:</p>

<pre><code>sudo port deactivate curl
sudo port install curl +ssl
</code></pre>

<p>Once you have <code>curl</code> with <code>https</code> support:</p>

<pre><code>sudo pecl install pecl_http
</code></pre>

<p>If you followed my previous <a href="/articles/2008/11/22/php5-lighttpd-and-imagick-on-mac-os-x-leopard/">howto</a>, you&#8217;ll want to move the module to the location specified in your <code>php.ini</code> file:</p>

<pre><code>sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20060613/http.so /opt/local/lib/php/extensions
</code></pre>

<p>Restart <code>lighttpd</code> and then you&#8217;ll be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PHP5, lighttpd and Imagick on Mac OS X Leopard</title>
		<link>http://davidwinter.me.uk/articles/2008/11/22/php5-lighttpd-and-imagick-on-mac-os-x-leopard/</link>
		<comments>http://davidwinter.me.uk/articles/2008/11/22/php5-lighttpd-and-imagick-on-mac-os-x-leopard/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 19:51:23 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[imagick]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=101</guid>
		<description><![CDATA[It&#8217;s a little tricky getting a nice clean install of PHP5 for OS X 10.5. The packages that I always used to depend on over at Entropy don&#8217;t seem to work anymore. At least not for Leopard. A great shame. I&#8217;m now switching to lighttpd for my development server, so have come up with the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a little tricky getting a nice clean install of <a href="http://www.php.net">PHP5</a> for OS X 10.5. The packages that I always used to depend on over at <a href="http://www.entropy.ch/software/macosx/php/">Entropy</a> don&#8217;t seem to work anymore. At least not for Leopard. A great shame.</p>

<p>I&#8217;m now switching to <a href="http://www.lighttpd.net">lighttpd</a> for my development server, so have come up with the following recipe to install PHP5 and the great <a href="http://www.php.net/imagick">Imagick</a> extension for image manipulation.</p>

<p><span id="more-101"></span></p>

<p>Follow these instructions at your own risk! They worked fine on my setup but I can&#8217;t guarantee they will for you.</p>

<ol>
<li>Install <a href="http://developer.apple.com/technology/xcode.html">Xcode</a>.</li>
<li>Install <a href="http://www.macports.org/">MacPorts</a>.</li>
<li><p>Now update MacPorts:</p>

<pre><code>sudo port selfupdate
</code></pre></li>
<li><p>Install lighttpd:</p>

<pre><code>sudo port install lighttpd
</code></pre>

<p>Install the startup item and copy the default configuration file:</p>

<pre><code>sudo launchctl load -w /Library/LaunchDaemons/org.macports.lighttpd.plist
sudo cp /opt/local/etc/lighttpd/lighttpd.conf.default /opt/local/etc/lighttpd/lighttpd.conf
</code></pre></li>
<li><p>Now we install PHP with the FastCGI, MySQL and Pear variants.</p>

<pre><code>sudo port install php5 +fastcgi +mysql5 +pear
</code></pre>

<p>In order for this to work, I had to disable the port <code>perl5.8</code> by using the following command:</p>

<pre><code>sudo port deactivate perl5.8
sudo port activate perl5
</code></pre>

<p>Then run the command again and it should succeed:</p>

<pre><code>sudo port install php5 +fastcgi +mysql5 +pear
</code></pre></li>
<li><p>Copy over the default PHP configuration:</p>

<pre><code>sudo cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini
</code></pre></li>
<li><p>Now open up the PHP configuration file:</p>

<pre><code>sudo mate /opt/local/etc/php.ini
</code></pre>

<p>Add the following line to the file:</p>

<pre><code>cgi.fix_pathinfo=1
</code></pre>

<p>Find <code>extension_dir = "./"</code> and replace it with:</p>

<pre><code>extension_dir = "/opt/local/lib/php/extensions"
extension=imagick.so
</code></pre></li>
<li><p>Edit the lighttpd configuration file:</p>

<pre><code>sudo mate /opt/local/etc/lighttpd/lighttpd.conf
</code></pre>

<p>Ensure that the following is uncommented:</p>

<pre><code>fastcgi.server = ( ".php" =&gt;
    ( "localhost" =&gt;
        (
            "socket" =&gt; "/var/run/lighttpd/php-fastcgi.socket",
            "bin-path" =&gt; "/opt/local/bin/php-cgi"
        )
    )
)
</code></pre>

<p>And also make lighttpd run as the user <code>www</code>:</p>

<pre><code>server.username = "www"
server.groupname = "www"
</code></pre>

<p>Add the following if you want to be able to use your <code>Sites</code> directory in your home directory. I also changed the default document root to the OS X default:</p>

<pre><code>server.modules += ("mod_userdir")
userdir.path = "Sites"
userdir.basepath = "/Users/"
server.document-root = "/Library/WebServer/Documents"
</code></pre>

<p>Ensure that <code>"mod_fastcgi",</code> is uncommented.</p></li>
<li><p>Now we need to setup a few directories, and make the user <code>www</code> the owner for them:</p>

<pre><code>sudo mkdir /var/run/lighttpd
sudo mkdir /var/log/lighttpd
sudo chown www:www /var/run/lighttpd
sudo chown www:www /var/log/lighttpd
</code></pre></li>
<li><p>Now install ImageMagick:</p>

<pre><code>sudo port install imagemagick
</code></pre></li>
<li><p>Now we need to download the Imagick PHP module. I was hoping this would be as easy as <code>sudo pecl install imagick</code>, however I got an error for that, and so a manual build and install of the module is necessary:</p>

<pre><code>curl -O http://pecl.php.net/get/imagick-2.2.1.tgz
tar xvfz imagick-2.2.1.tgz
cd imagick-2.2.1/
phpize
./configure --with-imagick=/opt/local
make
sudo make install
sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20060613/imagick.so /opt/local/lib/php/extensions
</code></pre></li>
</ol>

<p>And finally, you can then run LightTPD with the following. The <code>-D</code> flag tells lighttpd not to run in the background&#8211;you don&#8217;t need to use it:</p>

<pre><code>lighttpd -f /opt/local/etc/lighttpd/lighttpd.conf -D
</code></pre>

<p>You should then be able to visit a PHP file in your browser to test that it works. A simple test file would be:</p>

<pre><code>&lt;?php
$img = new Imagick('pic.jpg');
$img-&gt;rotateImage('#fff', 45);
header('Content-type: image/jpeg');
echo $img;
?&gt;
</code></pre>

<p>This is just a simple Imagick rotate on an image.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/11/22/php5-lighttpd-and-imagick-on-mac-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>lighttpd and PHP on CentOS 5</title>
		<link>http://davidwinter.me.uk/articles/2008/06/22/lighttpd-and-php-on-centos-5/</link>
		<comments>http://davidwinter.me.uk/articles/2008/06/22/lighttpd-and-php-on-centos-5/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 15:34:14 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=96</guid>
		<description><![CDATA[Here&#8217;s a quick run down on getting lighttpd and php running on CentOS 5. yum install lighttpd lighttpd-fastcgi php mkdir /var/run/lighttpd touch /var/run/lighttpd/php-fastcgi.socket chown -R lighttpd:lighttpd /var/run/lighttpd/ vim /etc/php.ini Add in php.ini the following; cgi.fix_pathinfo = 1. Save and close the file. Now open up /etc/lighttpd/lighttpd.conf. Uncomment the following line "mod_fastcgi", from the server.modules option. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick run down on getting <a href="http://www.lighttpd.net/">lighttpd</a> and <a href="http://php.net">php</a> running on <a href="http://www.centos.org/">CentOS 5</a>.</p>

<pre><code>yum install lighttpd lighttpd-fastcgi php
mkdir /var/run/lighttpd
touch /var/run/lighttpd/php-fastcgi.socket
chown -R lighttpd:lighttpd /var/run/lighttpd/
vim /etc/php.ini
</code></pre>

<p>Add in <code>php.ini</code> the following; <code>cgi.fix_pathinfo = 1</code>. Save and close the file.</p>

<p>Now open up <code>/etc/lighttpd/lighttpd.conf</code>. Uncomment the following line <code>"mod_fastcgi",</code> from the <code>server.modules</code> option. Then ensure that the following is uncommented:</p>

<pre><code>fastcgi.server  = ( ".php" =&gt;
    ( "localhost" =&gt;
        (
            "socket" =&gt; "/var/run/lighttpd/php-fastcgi.socket",
            "bin-path" =&gt; "/usr/bin/php-cgi"
        )
    )
)
</code></pre>

<p>Save the file. Now create a test file, <code>/srv/www/lighttpd/index.php</code> and just include <code>&lt;?php phpinfo(); ?&gt;</code>. Now open your <a href="http://getfirefox.com">favourite browser</a> and visit <a href="http://localhost/index.php">http://localhost/index.php</a>. You should be greeted with a friendly PHP page, and you&#8217;re set to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/06/22/lighttpd-and-php-on-centos-5/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Remove Floppy Icon from Gnome</title>
		<link>http://davidwinter.me.uk/articles/2008/02/29/remove-floppy-icon-from-gnome/</link>
		<comments>http://davidwinter.me.uk/articles/2008/02/29/remove-floppy-icon-from-gnome/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 19:00:16 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nautilus]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2008/02/29/remove-floppy-icon-from-gnome/</guid>
		<description><![CDATA[Floppy drive. Who uses them anymore? I haven&#8217;t in about 5 years at least, and I certainly don&#8217;t want it making my Gnome environment looking messy. To make the icon disappear from the Places etc, simply comment out the /dev/fd0 line in your fstab file: sudo gvim /etc/fstab /fd0 I # &#60;esc&#62; :wq That should [...]]]></description>
			<content:encoded><![CDATA[<p>Floppy drive. Who uses them anymore? I haven&#8217;t in about 5 years at least, and I certainly don&#8217;t want it making my Gnome environment looking messy. To make the icon disappear from the <strong>Places</strong> etc, simply comment out the <code>/dev/fd0</code> line in your fstab file:</p>

<pre><code>sudo gvim /etc/fstab
/fd0
I
#
&lt;esc&gt;
:wq
</code></pre>

<p>That should do it. Check out Nautilus.</p>

<p>For those interested about the vim commands I used in this post, <a href="http://davidwinter.me.uk/articles/2008/02/29/vim-find-comment-save-and-quit/">read here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/02/29/remove-floppy-icon-from-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GDM Login Screen Resolution Too Big</title>
		<link>http://davidwinter.me.uk/articles/2008/02/26/gdm-login-screen-resolution-too-big/</link>
		<comments>http://davidwinter.me.uk/articles/2008/02/26/gdm-login-screen-resolution-too-big/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 10:06:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[gdm]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[x11]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2008/02/26/gdm-login-screen-resolution-too-big/</guid>
		<description><![CDATA[If you&#8217;ve noticed that the login screen for Ubuntu Gutsy (GDM) is too big, and that you can use the mouse to move the screen around, you&#8217;ll need to update your xorg.conf file. sudo gvim /etc/X11/xorg.conf When gVim opens, type in the following: /Virtual Then hit enter. That&#8217;ll search the file for the line that [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve noticed that the login screen for Ubuntu Gutsy (GDM) is too big, and that you can use the mouse to move the screen around, you&#8217;ll need to update your <code>xorg.conf</code> file.</p>

<pre><code>sudo gvim /etc/X11/xorg.conf
</code></pre>

<p>When gVim opens, type in the following:</p>

<pre><code>/Virtual
</code></pre>

<p>Then hit enter. That&#8217;ll search the file for the line that we need to comment out. When it&#8217;s found, hit <code>i</code> on the keyboard to enter the Insert mode of gVim. Now prepend a <code>#</code> before the <code>Virtual</code> keyword to comment out the entire line.</p>

<p>Hit escape on the keyboard, then type in <code>:wq</code> to save and quit.</p>

<p>Next time you have the login screen in front of you, it should be using the correct screen resolution.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/02/26/gdm-login-screen-resolution-too-big/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
