05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

394<br />

CHAPTER 22 LEOPARD AS A WEB SERVER<br />

Aside from the fact that SQLite is already set up for you, it has the major advantage of being<br />

the same database server used throughout the system. Applications written with Core Data can<br />

use SQLite as their backing store. That means you can share a database between your Core Data<br />

application and your PHP web site without ever having to touch SQL.<br />

NOTE For more information on Core Data and other application development topics, see<br />

Chapter 24.<br />

If you’re serving web pages from your machine, or if your remote host has SQLite (and the<br />

requisite PHP modules) running, you’re good to go. Run sqlite3 from the command line<br />

to access the included management program. You can also learn more by visiting http://<br />

sqlite.org/.<br />

MySQL<br />

If, however, you want to be like everyone else and run MySQL, you’re going to have to install it<br />

yourself. Fortunately, MySQL maintains a <strong>Mac</strong> <strong>OS</strong> X installer package on its web site,<br />

www.mysql.org/. To install MySQL, simply download the disk image that matches your architecture<br />

and run it.<br />

NOTE At the time of this writing, there is no <strong>Leopard</strong> version of MySQL available on the<br />

download site. This may change by the time you get there, but in either case, the 10.4 version<br />

can be made to work with one minor tweak. See http://www.beyondmac.com/2007/10/30/<br />

php-mysql-on-leopard-mysqlsock-location/.<br />

NOTE Apple also provides a good tutorial on getting up to speed with MySQL, including<br />

installation and initial configuration. See http://developer.apple.com/internet/opensource/<br />

osdb.html.<br />

Although it’s available in more traditional tarball format, I downloaded the more <strong>Mac</strong>-like<br />

disk image installer package. This contains an installer for the database server itself, and a separate<br />

installer if you’d like MySQL to start automatically. If you’re running a web server, that’s<br />

probably a good idea.<br />

Once it’s installed, you can start the MySQL server from the command line. It’s installed in<br />

/usr/local, which is not in the default path, so to run any MySQL tools you will have to actually<br />

go into the directory, or use the full path:<br />

sudo -b /usr/local/mysql/bin/mysqld_safe<br />

After entering your password, the server will start. The -b flag on sudo invokes the server as<br />

a background process. At your option, you can eliminate the background flag on your first run<br />

just to make sure everything is copacetic.<br />

Alternately, if you installed the startup item, you can use it to start the MySQL database:<br />

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start<br />

Finally, the installer includes a MySQL preference pane for System Preferences, as shown in<br />

Figure 22-7. Double-clicking will install it. The preference pane tells you whether MySQL is running,<br />

lets you start and stop MySQL, and includes a setting to automatically start MySQL at<br />

boot time.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!