03 December 2006

[tech] The PHP 5, Didn't Follow All The Instructions (Even Though I Thought I Did), OS Reinstallation Blues (Complete with Off-The-Cuff FAQ)

A while back, it will be recalled, I flirted with the idea of upgrading the native PHP on my Macintosh (that version being PHP 4.4.1), wanting to self-teach me some MySQL and reasoning that in order to have all the tools, I ought to have both of the most current versions.

I did try installing PHP 5, but omitted an important step, thus b0orkingating my Apache installation. No problem, said I to myself, said I, so I tried reinstalling OS X Tiger over my extant (and now flawed) installation.

The result is funny–provided it hasn't happened to you.

Herewith, a cautionary tale.

The First Signs Of a Problem

It may (or may not) also be recalled that I was chasing down a kernel panic problem I've had since installing Le Tigre. The thing would KP on wakeup. I was hoping to kill two birs with one stone.

For some reason which will never be within the ken of man, the OS reinstall hung in the middle of installing one of the sets of language files (ironically, it wouldn't finish Finnish). after waiting twenty minutes for it to complete the last 2% of installation, I tried rebooting the system.

Bad move. I was introduced to the feeling a Mac user gets when they reboot and find that instead of the calming screen with the Apple logo and the rotating throbber, you get a low-rez rectangle in the middle of the screen with a file folder straight out of OS 9, with alternating Finder logo and question mark.

Sighted system folder, sank same.

Strangely, this was not the depths of my despair. But I get ahead of myself.

OS Rehab

The next natural step was to boot from the optical drive. I hate booting from a CD or DVD; it takes so damn long. But it had to be done, so it was done. Nothing seemed to be physically damaged, so it was on to reinstalling the OS.

I decided to start by reinstalling OS 10.3 Panther. That went without too much hassle, and I even found that our old stuff was in the Previous Systems folders; I "root"ed them out and reattached them. My creative apps didn't reactivate then; I contemplated communicating with Quark and Adobe (amongst others). But Panther was up and stable, and so I forged ahead into Tiger

Tiger reinstalled fine (with a bit of nailbiting as we paused to watch it install the Finnish language files). Once in Tiger, the creative apps reactivated flawlessly, a beam of light in the darkness. Aside from anomalous behavior with Spotlight (which passed and did not recur) the system seemed to be stable, but, soon enough, the kernel panics recurred–and I was still at PHP 4.4.1. What to do?

This Is The Wrong Tool, Gromit–And It's Gone Wrong!

When I aquired SunDial Three, I managed to also obtain AppleCare (a $249 security blanket, but that $249 buys a lot of peace, let me tell you). Cared-for Applers know that the AppleCare box comes with a CD-ROM that includes TechTool Deluxe. Now, my AppleCare expired about six months back, but I still have the TechTool CD. In it goes.

Copying the app to the hard drive it tells me I need to update it to work with Tiger, and I do this. Everything checks out over multiple runs...except something called the volume structure. But I can't repair the volume if I booted from the startup disk so, of course, I boot from the CD-ROM.

TTD running from CD-ROM (remember, this is the version Tiger isn't supposed to be compatible with) reported volume structure errors, so, with the confidence of someone who trusts authority sometimes way too much, I forge ahead and let TTD go to work on the disk. Almost six torturous hours later (who knew it would take so damned long?) the disk repair is complete.

Did I fix it?

Oy. Did I ever fix it.

Houston, We Have Screwed The Pooch

Several grafs back, I menched how I had though I had committed the worst OS transgression ever. Had I but known.

TTD in the version I had it is, as said, incompatible with Tiger. It identifies natural OS tendencies as problems. Fix those problems, and you irrevocably break the OS.

How bad?

Well, the first sign of trouble was when the kernel panic occurred within seconds of powering-on. At least, however, this saves time when waiting for the next KP.

The next sign of problem is when you boot from the Tiger DVD and find that Disk Utility can't. Repair of the volume is impossible because of something called a corrupted B-Tree node. The volume can't even be mounted.

The final sign of hard drive Gehenna is trying to reload (once again) the OS, and finding that the Installer can't find the hard drive at all.

Yes, my friends, logically speaking, I nuked the hard drive. There may or may not have been files still there, but as far as my instrumentality was concerned, the file system was as dead as the President's concern for the poor. It was thus that, with a heavy heart, I proceeded to erase and repartition the drive, taking with it things I collected over three and a half years of use; some of it not replaceable, a lot of it uncritical, and waving a fond goodby to some apps (Internet Reconnector and Speed Download) at least for now.

Now, your saying to yourself (If you've hung on this long), hey, Sam, surely you printed off some of that reg info to refeed in case of this? To which I'd answer, are you kidding? Who does that sort of backups? Haw haw! And when you're through laughing, let me tell you about my investment plan (hint-two words: Oregon Lottery).

The State of The System

The system is back up and running and seems stable. I have had a couple of kernel panics but instead of waking from sleep they happened when I was opening a couple of apps (Real player and iTunes).

As it turned out, iPhoto (I was still using version 2) is gone too. It came bundled with my Mac when I bought it; I may dig back into the original CDs and see if maybe the package is hidden away there somewhere. I have also lost Internet Reconnector and Speed Download 3, but replacing those is irritating and maybe will have a nominal cost. All my iTunes purchaes music is gone.

If the kernel panics continue, I'll contact Crucial about that 512M memory stick I bought from them and see if they'll work with me on it.

And now, the promised FAQ

I thought I'd known enough about Unices to install PHP 5 and fix it if it went wrong, but only proved the adage that a little knowledge is a dangerous thing. Once the system was up and running, I looked at the instruction on Marc Liyanage's PHP for Mac OS page and followed them a little more closely this time.

If you're a relative Unix tyro, there are some things you should do to kick PHP 5 on your Macintosh. The following are notional FAQs that should steer you around the shoals (the Q's I FA'd myself weren't this but more along the lines of why me, God, why me? But, as usual, I digress). So now, without further ado, I give you:

Samuel John Klein's Quick, Off-The-Cuff Guide and FAQ to Installing PHP 5 in Mac OS X 10.4, Without Nuking Your OS

  • Mac OS X 10.4 comes with PHP version 4.4.1. The currently available version is 5.2.x. You will probably want to upgrade if you want to use things such as MySQL5; it will work with PHP 4, but you won't have access to some of the more recent MySQL tools, we are told.
  • The first step in upgrading is to obtain the current package. Marc Liyanage's highly informative PHP for Mac OS X page has linkages to PHP 5 for Mac that will run not only under Apache 1.3 (the default for Mac OS X) but also for Apache 2 (if you really want to punish yourself and install that). Go to Marc's page here. This package is a complete installation; if you just want to run PHP in a default-for-Mac-OS style, this installer will install a working PHP 5 setup on your Mac with no recompiling. Nifty.
Now that you have the binary downloaded, become aware of what your system is already running. If you already have PHP 4 working on your Mac, you'll know it–it requires you to go sudo-jitsu and edit the file /etc/httpd/httpd.conf. Uncommenting the following lines:
#LoadModule php4_module libexec/httpd/libphp4.so
#AddModule mod_php4.c
And then restarting Personal Web Sharing (System Preferences>Sharing) will cause PHP 4 to wake up on your system.

PHP5 Installation Concerns

As I've said, if you've done this, you'll know; if you haven't done this, PHP is still inactive on your system, and you can proceed to install. If, however, you really, really want to be sure, use TextEdit or a plain text editor (not a word processor) to create the following file:
<?php
phpinfo();
?>
call it "test.php" and drop it into the Sites folder in your account's home folder. This is where Apache looks for your own local web pages. Then, copy the following line:
http://127.0.0.1/~yourname/test.php
paste it into your web browser's address box, replace "yourname" with your "short" user name (the name of your home folder) and hit return. If PHP is enabled, a bunch of tables will display with PHP Information. If it isn't, your browser will just display the unadorned PHP code. Also, do not simply drag the file into the browser; your browser has to request it from the web server who passes the code through PHP.

If You Do Have PHP 4 Enabled, then, it is imperative that you recomment the two lines in the httpd.conf file that enabled PHP to begin with before installing PHP 5. Go back there, now, and put the pound signs back in. Don't argue. Just do it. There are ways to run both PHP 4 and PHP 5, and you're welcome to learn them, but learn them first. I only need, at this self-learning time, to run one. Edit the httpd.conf file, restart Personal Web Sharing, and proceed to install.

If you were foolish enough to install PHP 5 without recommenting the crucial lines, you now have a problem. Apache isn't sure what PHP you want to use, and so Personal Web Sharing will not work at all. Marc Liyanage saith "bad things will happen"; from my POV, it looked like I broke my web server. There may well have been a way to come back from that, but my bull-in-a-china-shop approach rendered any other attempt at repair academic.

So please, as God is my witness, and by all that is holy, learn from my bad example, please?

Installing PHP 5

Hopefully we're at the point where we have cut PHP 4 out of the loop. You've made sure your httpd.conf file is correctly commented out and you've restarted Personal Web Sharing. Here's what you do next:
  • Unarchive the PHP tar.gz file. Use BOMArchive Helper (says Marc), not Stuffit Expander. To make sure you're using BOMArchive Helper, do a Get Info on the file, mouse over "Open With", and select it from the flyout menu.
  • Mount the disk image
  • Double-click on the package file.
  • Let 'er rip
The package will install itself to /usr/local/php5. All PHP 5 files will now be there, and a symbolic link from /etc/httpd will cause Apache to wake up PHP 5 instead of 4 (the new installation has its own configuration file that will do the job; there should be no need to do anymore configuration-jitsu.

Now, stop and restart Personal Web Sharing; and take this line:
http://127.0.0.1/~yourname/test.php
and enter it into your web browser and, assuming you've placed the test.php file there, a display should obtain telling you more than you ever wanted to know about your new PHP 5 installation.

Marc Liyanage's pages at Entropy.ch are a good place to go for troubleshooting info. The above was my whole experience. If you have any troubleshooting questions, go to the PHPBB discussion forums there, register, and post away.

Good luck. And don't be too intimidated; if you do the above, you should have the most recent PHP on your system with no problems.

Tags: , , ,

2 comments:

Judy said...

I feel your pain. Really.

I think you should send your story to the guy who writes the "Macs are wonderful and easy and PCs are hard and not very fun" ads that have been running ad nauseum on TV.

I like Macs. Really I do. I used to have one. :-)

Samuel John Klein Portlandiensis said...

I hear you, Judy, but really, it's not a Mac vs PC issue, as far as I see it, it's a "I really ought to have known better" issue.

I was in over my depth–but I didn't think so at the time. Now I know better.

Believe me, I could really screw up a Windows system the same way. Probably just as fast too.

As a baby computer user my first OS was CP/M (the big dog before the IBM PC debuted and Encom's...er, I mean Microsoft's...rise to famedom. I fancy I see OSs in a certian "zen" way; regardless of the quality or perception of quality of the product the product's usefulness as a tool doing basic system operations from the user standpoint is the most important thing. Quality (however one perceieves it) is secondary; if the OS won't do what you need it to, what difference does it make that it'll never crash?

Oh, well, went on a bit of a semi-rant there. Sorry. B-)