PHP & MySQL Setup

From Eunuchs to UNIX
(Or how Popeye gets the Spinach)

Page 1: Turning on the Apache Web server-->>
Page 2: Enabling PHP-->>
Page 3: Installing mySQL-->>
Page 4: Installing and configuring phpMyAdmin-->

Preparing Mac OS X for PHP/mySQL

Admit it: As much as we love our Macs, as much as we believe in their superiority for graphics, video editing, and ease of use, there is one area in which our beloved computer has been a wimp. As Web servers, personal Macs have not been, uh, the biggest studs on the Net. Home PC users could use their Personal Web Server (PWS) to run Active Server Pages. They could learn a little VB script, ASP, and a database system, and soon they were testing and running dynamic (aka database-driven) Web pages and Web applications. The Mac user could only drool in envy.

That has all changed in Mac OS X. Because the Mac now comes with the Apache Web server, the PHP scripting language, and the ability to run the mySQL server, we have joined forces with the power that runs the much of the Internet: UNIX. We’re in the game! We no longer have to capitulate to the bullying of Bluto in the guise of Microsoft.
How do we set it all up? It’s not quite out-of-box, and you'll have to do a couple of things that may make you want to revert to Wimpy with your hamburger. Most notably, you're going to have to enter a few commands in the Terminal. Well, sew a big "S" for Spinach on your shirt, and follow the directions carefully. I hope to help you prepare your computer to take advantage of what has to be the most powerful feature in Mac OS X. The steps are primarily written for Jaguar, but I make note of the differences for versions of 10.1.

Starting the Apache Web server

The first thing you have to do is start your Apache Web server. The new OS has a "System Preference" to make this blissfully easy. Open the "Sharing" panel, select and check the "Personal Web Sharing" preference, and click the "Start" button on the right. That's it! You have begun your Web server.

Sharing Panel

To test it out, open your browser and type the URL http://127.0.0.1/ and press your enter key. You'll see a generic page that you'll want to replace right away. For now, let's do something simple. Open up BBedit (or your favorite plain text editor) and type out an HTML document. Save it as index.html.

<html>
<head><title>Sheri's Spinach Factory</title></head>
<body bgcolor="#FFFFFF">
<h1>You gotta eat your spinach, baby! </h1>
</body>
</html>

You can type anything you like between the title and h1 tags. We're going to place this file in the Library/Webserver/Documents folder. (You may want to save the default index page and all of the translations of the page in various languages to a backup folder.) Now when you type in http://127.0.0.1/ you'll see your new page.

Backing up the httpd.conf file

We are now going to type in the Terminal, and directly alter the Apache configuration file. If you think this sounds dangerous, it is. Still, you have a backup configuration file that you can use to replace the working one if you make any egregious errors. (If you would like to verify the location of the configuration file as well as its backup, you can use "Sherlock" with the invisible file option selected to take a look. Just type "httpd.conf" without the quotes.) If you have hopelessly destroyed the original (one way to tell is that the Web server no longer starts up), use the cp command to copy and rename a file all at once. Type as follows:
cp httpd.conf.bak httpd.conf What this will do is give you two identical files, the original uncorrupted backup file, and the returned-to-pristine httpd.conf file.

Next let's enable PHP-->
Back to Unix Tips Page-->