Upgrading Tiger to Leopard: Apache, MySQL, PHP and Virtual Hosts
Having upgraded one machine to Leopard and seeing that it didn’t trash my hosts file, I got all cocky and thought that I’d upgrade my Mac Mini, which I was running as a development server.
Because it took me a while to set up and get right, I was loath to have to go through this again. I use a virtual host for every client I work with, and the only way I could get other machines on the network to see these is by manually editing host files. This is a small pain, so I was glad that Leopard didn’t obliterate these edited host files on either machine.
Having learned painful lessons before, I actually took the unusual step of making a full backup (of both machines as it turns out) before upgrading. I’ve never ever done this before, because I am essentially lazy. Not this time.
After running through the same painless installation process as previously, I had a Leopard running Mac Mini, that seemed to be doing just fine. A quick check of the hosts file and it is again intact as before.
Sadly, and altogether expectedly, it knackered the server. I was praying that there would be some form of magic that would actually mean that I’d install Leopard and it would all just work. Clearly I was living in cloud cuckoo land, but hey, I’m prone to this occasionally.
Setting up Apache. Or am I?
Firstly I had to turn the server on again. No bother with that, a quick trip to the preferences panel and away we go. With it now working, I obviously wanted to apply the changes I had previously made to my httpd.conf file.
At this juncture I should say that I find Cocoatech’s Pathfinder indispensable for setting up the server. I hate using the Terminal to edit text files (it’s just too nerdy), and as TinkerTool is not Leopard ready yet, it’s the only other way I can access hidden files. Yes, I do know about the ‘Go’ command. Now.
I have a user on the mac configured to serve the files, as I find this easier than navigating through to the webserver folder. When I am working, I edit the servers files from my MacBook, and I have encountered permission problems with the webserver folder before. So this (the document root), the virtual hosts and the usual includes and extended index options were going to need changing.
Having found my back up copy of httpd.conf, I then navigated to /etc/httpd/httpd.conf. Opening them both up side by side, I prepared to work through the document. Odd then, that both appeared to be the same. Turning the server off and on (come on – it’s the IT support fail safe the world over) did nothing, so I then started to frantically Google “Leopard Apache problems”.
It was at this point (and when I say at this point, I mean a good 45 minutes later) that I noticed out of the corner of my eye a folder in /etc entitled ‘apache2’. Balls.
A quick peek in here revealed another httpd.conf. The Leopard installer had been kind enough to save my old folder, despite it’s redundancy, and this (plus my own stupidity) confused the hell out of me.
Anyway, now that I found it, I set about editing it. This version of Apache splits the config files up. The httpd.conf file now draws in info from separate files that control other aspects, amongst them virtual hosts and also now PHP. This I think is a good thing. It will take a bit of getting used to though. If you prefer you can still stick it all in one file, but this seems to be the way forward, so if you can’t beat em etc…
It took a while to find all the things I needed, as things were spread across different files or in different places to what I am used to, however, within about half an hour I had the server bit up and running. The only thing that was playing up was virtual hosts. Agh.
Virtual host-gate
I’ve had problems with Virtual Hosts before. The annoying knack of not correctly identifying the problem, coupled with not knowing how to approach a solution, always sees me waste hours on these buggers. This time was not really that different.
A few Google’s later and I had read a load of stuff that didn’t help at all, including one Apple Discussion post that was supposed to provide the answer but didn’t. I then came across a post that showed a way of checking to see if the syntax in your configuration files works. So via terminal, I typed in:
apachectl configtest
The result?
[warn] NameVirtualHost *:80 has no Virtual Hosts
Thanks. For. That.
Another half an hour of frantic searching and non-understanding of the Apache docs and I finally stumbled upon a paragraph in this article:
If name-based vhosts should be used a NameVirtualHost directive must appear with the IP address set to be used for the name-based vhosts. In other words, you must specify the IP address that holds the hostname aliases (CNAMEs) for your name-based vhosts via a NameVirtualHost directive in your configuration file.
Now, I might be wrong here, but that basically intimated that I might actually need to put an IP address in. Previously, in my 1.3.3 I had always gotten away with NamVirtualHost *:80 and VirtualHost *. Not anymore it seems. I put in the IP address, in both the NameVirtualHost directive and the VirtualHost directives and bingo, I finally had my virtual hosts back.
So, only PHP and MySQL left…
PHP and MySQL
Now I’d already read that you need to re-create a symbolic link to your mysql default socket file for MySQL to play nice in Leopard. PHP, it seems, might also require a change to the php.ini file to point to a new PHP executable location. The addtype directives for PHP were also missing from http.conf.
Within /etc/apache2/other there is a php.conf file though, and this contains the PHP addtype directives. This conf file is automagically appended to the httpd.conf file, so there’s actually no need to add it in to httpd.conf. This is confusing, as there are the usual addtype directives within httpd.conf.
So with this in mind, I thought I’d test both first to see if they worked. I’ve got an installation of TextPattern and PHPBB on the server, as well as PHPMyAdmin, so this was going to be fairly easy. Much to my surprise, both worked.
And relax…
With the server now working, there’s one more machine to go. On the face of it, this last machine should be easy, but given my previous fuck ups and general idiocy, I’m not holding my breath.