Getting WordPress, mod_rewrite and Leopard to work together

December 25, 2007 · Posted in Tech · 3 Comments 

I’ve been trying to get Leopard, Apache 2 and WordPress working together for a while now. I want to use the WordPress friendly URL feature, and this requires the Apache mod_rewrite module to work too. There are various places around the web that have partial solutions to these problems. Here’s the procedure I followed – YMMV

First off, WordPress is installed in /Users/jameshiggs/Sites/blog. Leopard comes with Apache 2.2 installed, but has PHP disabled by default. To correct this, go to the console and change directory to /etc/apache2 and open httpd.conf in your favourite editor. For me this means typing:

sudo mate httpd.conf

You’ll probably have to enter your admin password. Find the line that reads:

#LoadModule php5_module libexec/apache2/libphp5.so

and uncomment it so that it looks like this:

LoadModule php5_module libexec/apache2/libphp5.so

Next, we need to make sure that your user directory allows .htaccess rules. To do this, create a file called jameshiggs.conf (obviously, you’ll need to replace my user name with yours) in /etc/apache2/users. The contents of that file should read:

<Directory "/Users/jameshiggs/Sites">
	Options Indexes MultiViews
	AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

Again, you’ll need to replace my user name with yours.

The final piece of the jigsaw is to configure WordPress to use friendly URLs – which you do from the Options > Permalinks page. I’ve selected the second option which makes URLs look like this: http://localhost/~jameshiggs/blog/2007/12/25/sample-post/. If WordPress can write to the site root then it will automatically create the .htaccess file. If not, you’ll need to create it yourself in the root of your blog site. On my machine, the file should look like this:

<IfModule mod_rewrite.c>
	Options +FollowSymLinks
	RewriteEngine On
	RewriteBase /~jameshiggs/blog/
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /~jameshiggs/blog/index.php [L]
</IfModule>

Finally, you need to restart Apache – the easiest way to do that is to go to System Preferences > Sharing panel and untick Web Sharing. Once Apache has stopped, tick it again and Apache should start up. And that’s it.

Let me know if you have any variants to this procedure.

Thanks to Bagelturf and Ariadoss for hints that helped me get this running.

More book reviews

December 11, 2007 · Posted in Books · Comment 

I’m ploughing through the book backlog at a decent pace, with three more finished this evening. They are:

Just as I thought there was some order returning to my piles of books, there was a book sale at work today where I picked up seven paperbacks for a pound. Reading is never-ending (I hope).

Book backlog

December 10, 2007 · Posted in Books · Comment 

I’ve been remiss recently in writing up my reviews for 26 Books. Tonight, I caught up on three that were waiting – The Carhullan Army by Sarah Hall, The Book of Laughter and Forgetting by Milan Kundera and Exit Ghost by Philip Roth, which still leaves me with five on the pile, plus the half-dozen I have on the go at the moment. If work would get out of the way, I might be in with a fighting chance to finish them before the end of the year.

REST links

December 7, 2007 · Posted in Tech · Comment 

I’ve been doing some research into REST and API design over the last couple of days for a client. In my travels, I collected a few really useful links and quotes.

The overriding feeling is that most APIs that claim to be REST APIs are in fact not. Most of them seem to be more RPC-style services. The pragmatic part of me says that you should just do whatever works, while the perfectionist in me admires the simplicity and cleanliness of a true RESTful style.

Anyway, here are the links and quotes, in no particular order:

There’s no way to get around platform differences when building distributed applications. The sooner people realize that, the better. – Dare Obasanjo

Mark Baker – Accidentally RESTful

Dare Obasanjo – Misunderstanding REST: A look at the Bloglines, del.icio.us and Flickr APIs

Joe Gregorio – How to Create a REST Protocol

Roy Fielding – Represetnational State Transfer (REST) – the original dissertation that coined the term REST.

Excellent concrete example of a RESTful API:

Instead of a “turnOnTheLightbulb?” request to a server object, we have a PUT “true” to the http://example.com/lightbulb/lit object supplied by the server. The http://example.com/lightbulb/lit object also responds to a GET request that returns true or false. POST is an “add information” request that doesn’t make sense for the lightbulb, nor does it really make sense to DELETE the lightbulb. So those requests would fail with a response indicating the fact. – from REST in plain English

Dare Obasanjo – WS-* is to REST as Theory is to Practice – read the comments too: they’re brilliant.

Steve Vinoski – The ESB Question includes a great quote:

Frankly, if I were an enterprise architect today, and I were genuinely concerned about development costs, agility, and extensibility, I’d be looking to solve everything I possibly could with dynamic languages and REST, and specifically the HTTP variety of REST. I’d avoid ESBs and the typical enterprise middleware frameworks unless I had a problem that really required them [...]. I’d also try to totally avoid SOAP and WS-*

The comments there are also a must.

From the archive: How to be a Brain in a Brainstorm

December 6, 2007 · Posted in Opinion · Comment 

[The third in my series of posts that have disappeared with Interesource, but which I would like to keep available. This one was a look at how to be useful and polite in a brainstorm. It was originally published on 2nd April 2007.]

We often run brainstorms for clients here at Interesource. We have a group of experts, who we refer to as ‘brains’, that we call on to help us with these. They’re all expert in some area of the Internet and are all early adopters of the latest and shiniest stuff. You won’t need to explain to them what Twitter is or mashups are, or how Facebook is different from MySpace for example.

Of course this has its downside too: they’re all remarkably opinionated. Now, of course we love opinions because we’ve all got them and exposure to other opinions is the best way to challenge your preconceptions. That’s why clients pay for brainstorms, after all. The brains also tend to be too radical for most practical purposes, but that again is a benefit because ideas can always be toned down for the market they’re aimed at.

We usually mix in a few Interesource employees as ‘brains’ too. After all, we have experts a plenty on the staff. Recently I’ve been called on for two brainstorms. Here are my observations on what it takes to be useful in one.

You have to remember that you’re in the brainstorm for your opinions and expertise, so it’s OK to say things that are controversial and, in all likelihood, not fully formed or even at all practical.

The flip-side of this is that you’re not there to force your opinions or priorities on other people. You’ve been asked to tell people what you think, not suppress what other people think. You have to trust the people running the brainstorm to harvest the ideas and use the best ones. Just because you think it’s an awesome idea doesn’t mean that everyone else does. People who know me will recognise that this is the bit I really struggle with. Hopefully I’m getting better at it.

The two brainstorms I’ve been in recently have both been very positive and useful, but in both there was some behaviour that I felt was unhelpful. The first instance was one of the attendees telling the group ‘you haven’t come up with anything new’. Let’s deconstruct that.

First: you don’t *have* to come up with anything new in a brainstorm. They can be super-efficent ways of transferring knowledge, and that’s a great outcome. Second: a brainstorm group should behave as a team, not a series of individuals in competition with each other. If the brainstorm hasn’t produced anything new and it should have then the whole team has failed. It’s no good accusing the rest of the group of failure and trying to stand outside the failure.

This notion of it being teamwork is why brainstorms often start with trust games. Tim often runs brainstorms here and he usually makes people reveal an embarrassing hobby or fact about themselves to break the ice. This is great because it helps people to relax, lets everyone get some sense of the people they’re in a room with. After all, they may never have met several of the participants before.

I usually feel quite a lot of pressure before a brainstorm because I feel that there’s an expectation that I will say something brilliant or original and that’s difficult to do. You’re in a room with some very bright people and you don’t want to look stupid in front of them. But you have to remember that this is why there is no bad idea in a brainstorm – just say what you think.

You also have to submit to the moderator’s discipline. A good moderator will understand the client’s brief very well and will steer you away from topic areas that are not relevant. It’s important not to be offended by this; it doesn’t mean that the idea is bad, just that it’s better to move on to talk about something else. And for heaven’s sake, don’t keep trying to get your big idea back into the conversation if it’s moved on from there.

Running a good brainstorm is a tricky blend of finding people with egos and confidence who don’t mind shutting up when they’re told or listening to things they fundamentally disagree with without attacking it.

iPhone beats Windows Mobile in 5 short months.

December 4, 2007 · Posted in Tech · Comment 

Wow. The iPhone already has a greater share of the browser market than all Windows Mobile/CE devices combined. Windows CE is 10 years old, while the iPhone is just 5 months old.

(Via 9 to 5 Mac.)

Facebook and iPhoto

December 3, 2007 · Posted in Tech · Comment 

I’m probably the last person in the known universe to find out about this, but I’ve been very impressed recently with the Facebook iPhoto Exporter. It adds another tab to the Export dialog that lets you create albums, upload photos and tag your friends in them. Very slick.

Here’s what it looks like in practice (click for full-size):

A screenshot of the Facebook iPhoto plugin