PHP Installation & MYSQL Installation In Mac OS X

Started by sivaji, Jan 11, 2008, 01:16 PM

Previous topic - Next topic

sivaji

Mac OS X Installation

As of version 10.2 (Jaguar), Mac OS X distinguishes itself by being the only consumer OS to install both Apache and PHP as components of every standard installation. That said, the version of PHP provided is a little out-of-date, and you'll need to install the MySQL database as well.

In this section, I'll briefly cover what's involved in setting up up-to-date versions of PHP and MySQL on Mac OS X. Before doing that, however, I'll ask you to make sure that the Apache Web server built into your Mac OS X installation is enabled.

1. Click to pull down the Apple menu.

2. Choose System Preferences from the menu.

3. Select Sharing from the System Preferences panel.

4. If the Sharing preference panel says Web Sharing Off, click the Start button to launch the Apache
    Web server.

5. Exit the System Preferences program.

With this procedure complete, Apache will automatically be run at startup on your system from now on. You're now ready to enhance this server by installing PHP and MySQL!

Installing MySQL

Apple maintains a fairly comprehensive guide to installing MySQL on Mac OS X on its Mac OS X Internet Developer site[15] if you want to get your hands dirty and compile MySQL yourself. It is much easier, however, to obtain the precompiled binary version directly from the MySQL Website, and follow the installation instructions in the MySQL manual. In this section, I'll attempt to boil down this information to the essentials to help you get started as quickly as possible.

First of all, if you happen to be running Mac OS X Server, MySQL is already installed for you. You can run Applications/Utilities/MySQL Manager to access it. More likely, however, you are using the client version of Mac OS X.

To install MySQL on the client version of Mac OS X, begin by going to http://dev.mysql.com/downloads/ and selecting the latest production release of MySQL (4.0 as of this writing). Scroll down to the Mac OS X downloads section, then select and download the Installer package version for your operating system. You'll have a choice of the Standard, Max, and Debug releases; choose the Standard release unless you have a special reason for choosing one of the others.

Once you've downloaded the mysql-standard-version-apple-darwinversion-powerpc.dmg file, double-click it to mount the disk image if your browser hasn't already done this for you. Inside it, you'll find the installer in .pkg format, as well as a MySQLStartupItem.pkg file. Double-click the installer, which will guide you through the installation of MySQL.

Once MySQL is installed, you can launch the MySQL server by opening a Terminal window and typing this command:

shell%sudo /usr/local/mysql/bin/mysqld_safe

Enter the administrator password if prompted. Once MySQL is running, you can switch it to background execution by typing Ctrl-Z to suspend it, and typing this command:

shell%bg

You can then close the Terminal window and MySQL will continue to run as a server on your system.

Presumably, you'll want your system automatically to launch the MySQL server at startup so that you don't have to repeat the above process whenever you restart your system. To do this, simply double-click the MySQLStartupItem.pkg file and follow the instructions.

When you're done, you can safely drag the mounted drive for the MySQL installation package to the trash, then delete the .dmg file.

Installing PHP

As with MySQL, a Mac OS X version of PHP is not available from the official Website, but from a third party. Again, Apple also maintains a Web page detailing the installation procedure[17], although in this case it is somewhat out of date. A better source of information is  http://www.entropy.ch/software/macosx/php/, where you can download an installer package in the form of a disk image.

The latest version of PHP available for Mac OS X 10.2 is PHP 4.3.4. More recent versions of PHP (up to 5.0.1 as of this writing) are available for Mac OS X 10.3 or later only. Select the version that is right for your system and download it.

If your browser doesn't do it for you, mount the disk image by double-clicking the Entropy-PHP-version.dmg file, then double-click the installer .pkg file it contains. Simply follow the instructions, and PHP will be installed on your server. That's all there is to it!
Am now @ Chennai