After installing Panther at the weekend, I decided that I really should install PHP and MySQL again so that I can test portability of my PHP. The last time I installed PHP and MySQL on the Mac was back when I was running Cheetah, and I rapidly discovered that the process has changed quite a bit since then. In fact, it’s a whole lot simpler, Jaguar and Panther already have a MySQL user set up on the system by default – so it couldn’t be easier.
Anyway, installation of the entropy.ch package was uneventful and straightforward. I copied the code from my current PHP project over to the Mac (yay for cross-platform network browsing in Panther), set up a virtual host in my httpd.conf, restarted apache (apachectl restart for those taking notes), ran up the project in Safari and … nothing. No page, no error, no output, no message. Blank page.
Okay, so I figured that my code was erroring somewhere right near the top, but that the PHP module had been configured not to throw errors to the screen. No problem I thought – just need to update the php.ini file. Could I find it? Turns out it’s at /usr/local/php/lib/php.ini, and unsurprisingly it’s the top FAQ on the site.
I fire up emacs and comment out the display_errors = Off statement at line 292 of my php.ini. Easy – except the file won’t save, I don’t have permission. I’m the highest level of admin on my own machine and I can’t modify a simple ini file. Looks like I need to be root, except this is OS X client, and root isn’t enabled by default. (This was supposed to just work wasn’t it?).
Here’s how you enable root on OS X. Open up a Finder window and browse to Applications/Utilities, and run NetInfo Manager. From the Security menu, click Enable Root User and just follow your nose (you’ll need to set a password – make it a good one).
I abandon my emacs session, su to root and reopen the file. Make the edit, save the file, exit emacs. Restart apache. Deep breath. Refreshed Safari, and I’ve never been so pleased to see an error message in my life. The error? I forgot to chmod the files to give PHP permission to run them. Oops.



Comments
sudo vi /path/to/file/php.iniPassword: *********
Hehe.. err.. hahah.. ya the root v admin debate rages with OS X. I had a similar issue back with X.2 when I had someone ask me to configure mySQL for them. Boy did I hate Apple for a day or two.
I think the idea with admin is so that you can’t totally take out your system files. In theory removing the threat of any virus that will reformat your machine so I am told. But you are like this >
sudowas the first thing I tried - no joy.I understand that on OS X Server the root account isn’t disabled - it’s just a client thing, which makes sense in a way. It’s very unlikely that you’d need the root account if you’re purely using a machine as a client. I guess Apple figure that if you’re doing stuff that needs access to root, then you can cope with working out how to enable it.
vishould beemacs;-)sudo pico /path/to/fileor
bbedit /path/to/filebbedit has some nice tricks up its sleeve with permissions.
I can’t think of a good reason to enable root in OS X, except to satisfy a habit learned elsewhere :)
php.ini is not necessarily in /usr/local/php/lib—it might not even exist. Assuming you’ve got php running, put the phpinfo.php file somewhere your webserver display it. phpinfo.php has a single line:
phpinfo(); (enclosed by the php open and close tags)
It generates a web page that will tell you where the server expects to find php.ini.
If the file isn’t there, then php is running the default configuration. You should have a file default configuration file—it may be called php.ini.default. You can find the default configuraiton file by using the following command:
sudo find / -iname ‘php.ini*’
Once you find that file, just make a copy of it (calling it php.ini, of course) to where the php expects to find it, and then you can start tailoring php the way you want to.
I have made this change in the php.ini file and checked to make sure PHP is looking in the proper place. Still getting a blank page on every error. Argh. Makes debugging pretty difficult.