Archive for the 'General' Category

Officially a lazy bugger blogger

Monday, June 23rd, 2008

Inspired by The Local’s accusations of abandonment, I realised I’d not mentioned one of my new hangouts. I’ve been trying to compete with Rob Allen on the blog for our almost-in-production book Zend Framework in Action. As always he’s way ahead of me just as he is on the Author’s forum!

So if you’re really missing what I have to say or need to tell me what you have to say, you can catch me in any of those places. Once the book comes out I’m sure I’ll have more time for this blog.

Feedburning Feeds

Tuesday, November 28th, 2006

Just a quick note to mention that I’m testing passing the feeds from this site through FeedBurner, partly to get an idea of how the feed is being used and partly because it’s my job to know about all these internet technology thingies.

Anyway, if anyone has any issues with the feed please let me know.

Using Netinfo Manager to add hosts

Thursday, November 23rd, 2006

As an addition to my Networked Virtual Hosting Party on Mac OS X article, comments in the How To Setup Development Domains On OS X article on The Apple Blog pointed to something I’d not tried before; using NetInfo Manager to add hosts to local hosts file.

An official Apple article; How to Add Hosts to Local Hosts File clearly outlines the steps. It’s a little confusing as the instructions for Mac OS X 10.2 or later are to edit the /private/etc/hosts file (the same file as /etc/hosts) directly. However, I just tried using NetInfo Manager to add a host on one of the machines on our network and it worked fine despite it running OS X 10.4.8.

A minor detail to mention is I that the niload command was more like this for me:

sudo niload hosts . < /etc/hosts

Really there is not a huge difference between editing the /etc/hosts file directly or using NetInfo Manager and I’m not convinced the latter really makes it that much easier. Either way, it’s useful to know about alternatives.

Seven of Diamonds

Saturday, November 4th, 2006

Lying in the dark, lit only by the glare of my MacBook I suddenly had one of those “Woah!!”, shoot-out-of-skin experiences, as, flicking through Cal Evans PHP Community Playing Cards, I suddenly came face-to-face with this one.

It seems these cards were an actual 3D freebie at the Zend/PHP Conference and Expo which means that I was there in an odd, fakey kind of way.

Apparently only those at the conference or featured on the cards got a copy so …erm, let’s just say I was playing blackjack for M&M’s with the kids the other day and it would have been great to see the proud look on their little faces every time the seven of diamonds was pulled out …ahem, cough, hint…

Collaboration Markup

Thursday, July 6th, 2006

I work in plain text a lot, from using Markdown or more specifically PHP Markdown on this Wordpress setup and elsewhere, as well as doing HTML markup and programming PHP. It is therefore not surprising that this article on Collaboration Made Simple with Bracket Notation caught my eye (linked via Lifehacker).

It’s a simple but clever idea that eschews a specific software solution for collaborative content editing in favour of notations in plain text. I don’t want to steal anyone away from reading the article but I did want to note a simple way of remembering their idea…

[delete][replace with][comment]

…so if we take the text…

The Bat in the Hat

…and apply some collaborative revision markup…

The [Bat][Cat][less sinister?!] in the Hat

…it would be revised to…

The Cat in the Hat

It’s a useful trick to to remember e.g., for passing edits around in text format via IM or Email. Whether I use it or not is another thing but I certainly like the inventive use of simple tools.

A Networked Virtual Hosting Party on Mac OS X

Wednesday, June 28th, 2006

There are plenty of articles on setting up virtual hosts on Mac OS X but I’d not found a simple one that showed you how to set up named virtual hosting that could be read across your LAN. The aim for me is to be able to type in e.g., http://myparty/, in any browser on our small local network and get to the locally hosted site.

My requirements are pretty minimal, needing only to have one or two other Macs running OS X (Tiger) access the development server. I’m not going to go into too much detail, partly as I’m too lazy, but also as your setup and needs will be different to mine anyhow. Instead I’ll just give a general run through and point to further reading.

Decide where we’re going to host the party

The first thing we need to establish is the main server which requires that that server have a static IP address. In my case this involved going to System Preferences > Network > TCP/IP and setting Configure IPv4 to “Using DHCP with manual address”. In that same dialog I then set an IP address of 192.168.1.100 and clicked “Apply Now”. That now means that this machine has a consistent address that others on the network will refer to.

Tell everyone where the party is

When the other OS X machines on the network type http://myparty/ in their browsers the first thing their machines do is check in the file /etc/hosts to see if there’s an IP address that matches “myparty”. If there isn’t things won’t go very far. So if you take a look at my one…

127.0.0.1   localhost
127.0.0.1   myparty
255.255.255.255 broadcasthost
::1             localhost

…you’ll see that http://myparty/ maps to my localhost IP address 127.0.0.1 which is fine as my machine is the host. In order that the other machines know where to go for “myparty” we have to edit their /etc/host files to send requests to the static IP address I set earlier:

127.0.0.1   localhost
192.168.1.100   myparty
255.255.255.255 broadcasthost
::1             localhost

Set up the virtual hosts

Now that everyone knows where myparty is being hosted we need to prepare. First you need to edit the Apache web server configuration file httpd.conf which by default lives here /private/etc/httpd/httpd.conf. I’ve installed Apache2 in /usr/local/ which is the more generally expected place for it to be and since this is my notepad I’m going to go with that. So first I need to open httpd.conf as the all powerful root user so I need to type…

$ sudo vim /usr/local/apache2/conf/httpd.conf

…whereas you could go…

$ open -a TextWrangler.app /private/etc/httpd/httpd.conf

…or whatever your personal setup/preference is. Once open you might like to use this little tip I picked up of having your specific settings in a separate file so e.g. at the end of my httpd.conf I have the following…

include /Users/nicklo/Sites/apacheconf/users

…that points to a directory which contains the file nicklo.conf. Inside that file are my virtual host settings. Having those settings separate from the main httpd.conf makes them more easy to backup along with all my other projects. It also potentially keeps them out of harms way in case a Software Update decides it’s time to fiddle with your httpd.conf file.

In keeping with the example my nicklo.conf could then have the following…

NameVirtualHost *:80

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

<VirtualHost *:80>
    ServerName 127.0.0.1
    DocumentRoot /Users/nicklo/Sites
</VirtualHost>

<VirtualHost *:80>
    ServerName myparty 
    DocumentRoot /Users/nicklo/Sites/myparty
</VirtualHost>

You’ll notice the settings specific to “myparty” are the last ones. These basically say if you get any requests for “myparty” on any IP address (* wildcard) via port 80 then send them through to /Users/nicklo/Sites/myparty.

Party on!

All that’s left now is restart Apache via System Preferences > Sharing > Services > Personal Web Sharing or…

$ sudo apachectl graceful

…which is actually better as it will at least tell you if there are any issues rather than just sit there.

Actually, we we still have to build the myparty website/web application in /Users/nicklo/Sites/myparty/public_html but hey, that’s the easy part right?!

Now in an even more perfect world I would be able to tell you how to set up a proper DNS Server on the host machine, that would replace the somewhat hacky need for individually configured /etc/host files. However, right now I’m just too stupid and honestly, a bit scared, to even attempt that. If anyone can give me a simple and if possible metaphorical run through I’d be very interested.

Further Reading

Virtual Hosting on Mac OS X I need to give credit to the comments by “Mats” on that page for much of my setup above.

Staging websites on Mac OS X

Virtual Hosts for Dummies

Location, Location, Location: Tips for Storing Web Site Files

Apache Virtual Host documentation

VirtualHost Examples