Using OS X as a decent web server operating system

For quite some time I’m trying to figure out how I could use old and current Apple hardware as decent server platform. Somebody was asking why I wasn’t using Linux or BSD operating systems which are known to work smoothly. Actually I’m using FreeBSD where ever I can for servers but installing and running FreeBSD on PowerPC machines isn’t smooth at all. Linux is out of the question because – well because I’m into the BSD way of Unix. When you look at OS X you find a lot of BSD similarities. Apple is even »claiming« that OS X is based on FreeBSD technology although it is more like FrankensteinsBSD when you look at it – still it is the operating system which is made for that exact hardware, especially for the G4’s and G5’s.

Both, OS X and OS X server are shipping with apache and php but their versions are far behind of current development. Same thing for OS X Server and MySQL. But this is not really the worst part. Even more problematic is the lack of options for configuration. In OS X you can only click on the checkbox for »Personal Web Sharing« which starts / stops the pre-installed apache. That’s all. In OS X Server you got a lot more options but still not enough. The Interface for managing the MySQL daemon is a crime. It feels like somebody used InterfaceBuilder for less than two minutes.

Of course OS X has a Unix underneath the hood and you have a terminal but when you start editing config files for the pre-installed software packages and you change options that aren’t available in the graphical interface, everything blows up. Next time you start the GUI tools everything is a mess. The configurations is either completely lost or simply unusable. Things like apache is not starting anymore, PHP files won’t get executed or MySQL isn’t allowing any connections anymore and other weird stuff like that. So if you are using OS X Server and its graphical user interfaces for setting up a webserver you shouldn’t really use the command line for any configuration or modification of the pre-installed software. Did I mention that you shouldn’t try to replace or delete the pre-installed software either? If you want maximum pain – do it, if you don’t – let it be.

OS X Server is good for other things. Like setting up a mail server or a LDAP server. This part works really smooth via the GUI. I mean the web server part works too but only for setups that are within the limits of the GUI, besides its outdated software.

The other approach is to build all the necessary software manually. Fortunately there is an equivalent to the FreeBSD ports collection available for OS X which is called »MacPorts«. MacPorts are offering a huge collection of open source software and best of all it makes it easy to install, update and delete software. Of course you could download all the sources of apache, php, mysql and their dependencies in order to compile them by hand but MacPorts does all that for you so relax. There are even some useful tutorials out there, explaining how you get apache, mysql and php running. These are two of them which helped me:

But it’s not that easy. You are always encountering problems of ownership or permissions, weird paths and missing directories. You need a little of Unix experience and the ability to read logfiles from time to time (see the previous post on how to add users to the www group). The big advantage is you have up to date software, you can maintain the software and update it easily and you are able to make use of every configuration option offered by the software and not only the ones that Apple wants you to access. For example this way you could use your G4 or G5 to set up a current apache with the current version of ruby on rails, you could set up a mongrel cluster and lots of other custom setups which wouldn’t be possible if you’d be only using the graphical interface.

This whole article is true for OS X. I haven’t really played enough with OS X Server yet. I mean it is really convenient to use the GUI Server Tools but you have basically the same problems as on the client version. Since it is shipping with MySQL you have to make sure that you don’t accidently bind your self compiled software to the pre-installed versions – again – maximum pain. This is because of the different environments. MacPorts uses /opt for everything while the pre-installed software lives in /usr or even in / – so when it comes to sockets or databases which are either in /var/db/… or in /opt/local/var/db/… it is geting quite messy and hard to keep track of all the pathes for librarys, sockets, modules etc. Stick with one approach.

I’m going to write more about this when I had time to play with OS X Server a little bit more and feel free to leave interesting links on that topic.

Main entry continued

Leave a Reply

Your email address will not be published. Required fields are marked *