Apparently Mac OS X 10.5 comes with the PHP module installed on the Apache web server. The “Web Sharing” option in System Preference actually switches on a pre-installed, full-fledged web server. I’ve known about the web server for a while, but it’s pretty cool that I didn’t have to install the PHP module.
What this is all about is I wanted to use PHP to do server side includes so I didn’t have to update as many files when I make changes to my client’s sites, but I wanted to preview the pages while I worked on them. The best solution was to preview the files through the Sites folder on my Mac by steering my browser to http://127.0.0.1/. The Mac is now my test server!
It wasn’t working at first, though. I had to look up some tutorials on the subject to find out how to edit the appropriate configuration files. I went one step further and installed Webmin so I can spend less time manually editing configuration, which are annoying because they’re hidden files in hidden folders so unless I want to force Finder to show hidden files, I have to use Terminal to open the file.
On top of all that work I had somehow broken my web sharing without realizing it. I did a port scan and found Privoxy answering port 80 instead of apached. For the life of me I don’t know how that got there. Once that was gone, port 80 was closed even though System Preferences showed it still open. I checked console logs and discovered that somehow I’d lost the directory apached was trying to save log files to. I also had no configuration file (there used to be a default one) for my user account.
When all was said and done I got it working and the whole experience has given me a better idea of how web servers work. It was actually kind of fun.
Originally published at www.Devvyn.com. You can comment here or there.
