TweetFollow Us on Twitter

Panther Roars, Database Meows

Volume Number: 19 (2003)
Issue Number: 12
Column Tag: Programming

UNTANGLING THE WEB

Panther Roars, Database Meows

by Kevin Hemenway

Panther worth your time? Databases besides Filemaker? Pffffttt.

Panther worth your time? Databases besides Filemaker? Pffffttt.

"What's new in Panther?" you shout with mindless adulation, anxious saliva and drool waiting to soil the pages of your newest MacTech. Bad news, bub: absolutely nothing: nothing to write about, nothing to justify your upgrading, nothing worth your time, effort, or worrisome heart palpitations. I was hoping I could pound out a peck of pickled pages on pathetic Panther proselytizing, but no, Apple has spurned my deadly Shaolin technique.

I am, of course, talking specifically about web serving.

Mr. Piser, I Think You Should Come Up Here

Sure, a lot of other incredible drool-worthy stuff has happened in the latest OS: Expose, word completion in certain applications (via Option-Escape or F5), FileVault for the paranoids, gcc 3.3 and distributed building, a finished version of X11, Xcode, blah, blah, blah. But web serving? Nothing, nadda, zilch. Happily, this is not really a negative--it's hard to improve on something that was nearly perfect in the first place (of course, this all depends on your needs, desires, and expectations).

Which isn't to say there's nothing new with the Apache web server and its related technology... just nothing monumental, merely incremental, ornamental, and supplemental. I'd have loved to see Apache 2.0 and MySQL 4.0, but let's cover the relevant changes we got instead. Note that I'll only cover areas we've touched upon in the previous columns: explaining the differences between features we've yet to use isn't very productive. When the time comes, if there are crucial differences between Jaguar and Panther, I'll address them.

  • Apache is now version 1.3.28; the latest available for Jaguar was 1.3.27. 1.3.28 is mostly a security and bugfix release so, although welcome, there's nothing to really get excited about. If you're interested in the specifics and technicalities, you can read the sordid details at http://www.apache.org/dist/httpd/CHANGES_1.3 (which also lists modifications for the just-released, as of this writing, 1.3.29).

  • The output of httpd -V (which shows what Apache has been compiled with) includes a new entry: -D DYNAMIC_MODULE_LIMIT=64. This is a standard Apache compile-time setting, and controls how many modules can be dynamically loaded (fairly obvious, eh?). "64" is the standard Apache default; its explicit definition here is unnecessary (but there's no harm in doing so). More info at http://httpd.apache.org/dev/apidoc/apidoc_DYNAMIC_MODULE_LIMIT.html.

    <
  • Our included PHP is now version 4.3.2 (as grep PHP /var/log/httpd/error_log confirms). Even though 4.3.4 or higher will probably be available by the time you read this, a number of good security, performance, and language enhancements were made from 4.1.2 (the latest Jaguar version) onward. Most notably, PEAR (the "PHP Extension and Application Repository") is now part of PHP by default, although it seems to be broken in 10.3--see "Homework Malignments" below for analysis.

    The PHP configuration has been improved in /etc/httpd.conf. Under Apache 1.3.27, we had the AddModule and LoadModule lines, as well as AddType's for .php and .phps (see last month's Untangling the Web). We've got the same thing in 1.3.28, but they've been slightly improved (Listing 1). First, the MIME types are more tightly defined--they'll only come into play when the PHP module is loaded (IfModule is a simple conditional... if mod_php was loaded, then do this). The second improvement is the addition of index.php to the DirectoryIndex, which allows that file to be served by default when someone requests a directory (http://disobey.com/example/).

  • As you'd expect from a new PHP install, the <? phpinfo(); ?> we learned about last issue is different (Figure 1). Along with a heavier command line that explicitly enables a few features, the configuration file (php.ini) has moved from /usr/lib/ to /etc/, an arguably smarter location. If you've installed the recommended php.ini (http://cvs.php.net/co.php/php-src/php.ini-recommended), be sure to move it and restart Apache (sudo apachectl restart). Even with the upgrade, the default Apple-supplied PHP doesn't come close to the number of features and built-ins provided by Liyanage's version (http://www.entropy.ch/software/macosx/php/) or Server Logistics' Complete PHP (http://www.serverlogistics.com/php4.php).

  • Perl, which we talked about during our two CGI articles, has been upgraded to 5.8.1-RC3; the final version of 5.8.1 has since been released. If you already know a thing or two about Perl, be forewarned that any modules you've compiled under Jaguar's 5.6.0 (like XML::Parser, HTML::Parser, Compress::Zlib, etc.) will need to be reinstalled, as the two different Perls are not binary compatible. Also note that cpan, similar to perl -MCPAN -esomething, is also available (find out more with man cpan).

Listing 1: Configuring PHP under Panther

The improved PHP configuration from httpd.conf

<IfModule mod_php4.c>
      # If php is turned on, we respect .php and .phps files.
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      # Since most users will want index.php to work we
      # also automatically enable index.php
      <IfModule mod_dir.c>
            DirectoryIndex index.html index.php
      </IfModule>
</IfModule>


Figure 1: The output of PHP 4.3.2's phpinfo() under Panther.

Wait, Wait, Hold Up Dog... MySQL?

"Apache 2.0 and MySQL 4.0?" What's this MySQL (http://www.mysql.com/) thingy thing? Quite simply, it's your new Filemaker or 4D, only without the pretty pictures. Pronounced my-ess-que-ell, it's one of the most popular free and open sourced databases, installed and readily available to most web hosting accounts you'd normally pay monthly fees for. It's also installed by default in Apple's Mac OS X Server. Another, arguably stronger, database program is PostgreSQL (http://www.pgsql.com/) but, in a move sure to flirt with disaster, I'll rudely ignore it for most of my Untangling the Web columns. Enough emails convincing me otherwise will certainly sway my decision.

Since this column assumes you're not using OS X Server, our first step is to install MySQL. Incidentally, this is also the most complicated, not because it's difficult, but because there are so many different directions in which to approach it:

  • Compile the Source Code: The geekiest among us will take MySQL's raw source code and compile it from scratch. This is the approach taken by Jay Greenspan in his Apple Internet Developer article (http://developer.apple.com/internet/macosx/osdb.html). Incidentally, I offered the same approach in a similar web-serving series for 10.1: http://www.macdevcenter.com/pub/a/mac/2002

    /03/08/apache_mac_5.html. While compiling from source gives you ultimate control, I've yet to see a situation that wasn't adequately handled by using a pre-packaged version (below).

  • Install the Official Binary: MySQL provides Mac OS X double-clickable installers in "Standard", "Max", or "Debug" varieties (http://www.mysql.com/downloads/mysql-4.0.html). "Standard" is recommended for most, "Max" contains features that have yet to be fully tested, and "Debug" is suicidal for production environments. If you're always anxious for a double-clickable of the latest version in a timely fashioned, you can't do better than using the officials.

  • Install Using a Package System: If you're a fan of automated installers like Fink (http://fink.sourceforge.net/) or DarwinPorts (http://www.opendarwin.org/), there's probably a MySQL package waiting for you (for fink: fink list mysql; for DarwinPorts, check the "databases" category). Package systems can usually upgrade everything you've installed in one fell-swoop (fink selfupdate and fink update-all, for example), and they're one of the easiest ways to uninstall a package too (something that most other alternatives have no equivalent).

  • Install an Unofficial Binary: Various user-created double-clickables exist, most notably ServerLogistics' Complete MySQL (http://www.serverlogistics.com/mysql.php). While not "official", they're often "value-added" in some way, and Complete MySQL is no different: it comes with a handy System Preference pane for controlling MySQL (Figure 3), a Mac OS X StartupItem (see "Homework Malignments" for some tips on building your own; the official binary also ships with one), and various drivers for database connectivity with ODBC or JDBC. Unofficial binaries may not be updated as regularly as the official releases, and you run the risk of them not being continued at all (due to lack of interest, impetus, or inspiration).

Which adventure should you embark on? As much as I like the thrills of a shiny new "official" release, the added treasure of ServerLogistics' unofficial binary can save you a couple of steps in your initial exploration. Regardless which path you choose to install MySQL, its continued configuration and administration is the same: you can use the command line to do everything, or nearly everything through GUIs (like CocoaMySQL, phpMyAdmin, etc.) or code (like PHP). We'll cover CocoaMySQL (http://cocoamysql.sourceforge.net/) and PHP database coding (http://www.php.net/mysql) in our next column and, if there's time, possibly phpMyAdmin (http://www.phpmyadmin.net/).

Installing Complete MySQL

Complete MySQL comes with a rather verbose installation document, but we'll cover the process quickly here. Go ahead and download the latest version (4.0.15 at the time of this writing; the latest official release is 4.0.16). Extract and mount, double-click the MySQL.pkg, agree to everything, and pause for a second when you get to the "Select a Destination" screen.

It continually surprises me how many people don't know about the File > Show Files command. Within any installer built using Apple's package system, you can always get a list of the files that are about to installed simply by choosing that menu item (Figure 2 shows the file lists for both the official MySQL binary and Complete MySQL). The list can be saved, printed, and used as a roadmap if, and when, you want to uninstall the package (though some creative license will need to be applied to find out where the package's root install directory is, represented as ./).


Figure 2: Using "Show Files" gives you a roadmap for uninstalling in the future.

Once the Installer finishes, you should be able to browse to /Library/MySQL and see a bunch of newly added files. Likewise, you should notice that a MySQL StartupItem has been installed into /Library/StartupItems. Note that even though MySQL has successfully been installed, it has not been automatically started... there's still some initialization to do.

Next, install the MySQL Preference Pane. Since I alone will be administrating MySQL, I've dragged my copy into /Users/morbus/Library/PreferencePanes/; if you'd like it accessible to any user on the machine, choose /Library/PreferencePanes/ instead. Once it's in place, open up your System Preferences, and choose the new "MySQL" item (Figure 3).


Figure 3: The newly installed MySQL Preference Pane.

To finalize your installation of MySQL, you'll want to first "Initialize" the database, than assign a password to the MySQL root user. MySQL database users have nothing to do with users that you've created within OS X, so don't get them confused. Once MySQL has been initialized, "Start" the server, then "Set Root Password" (Figure 4).


Figure 4: Setting MySQL's root password in the MySQL Preference Pane.

We can ensure that MySQL is running a few different ways: by checking the newly created logfiles (at /Library/MySQL/data/computername.local.err; you'll need to authenticate as an administrative user to do so), or by checking the currently running processes via the shell (ps auwx) or Panther's Activity Monitor (Figure 5), a much improved replacement for Jaguar's Process Viewer. If you've got hundreds of processes, use the "Filter" input to narrow in on "mysql".


Figure 5: Verify MySQL is running with Panther's Activity Viewer

Homework Malignments

In our next column, we'll look into interacting with our new MySQL database: administrative tasks from the command line, visual interaction with GUI-based tools like CocoaMySQL, inserting and manipulating database records with PHP, and more. We'll really just be scratching the surface on what's possible, but it'll give you enough knowledge to start your own database project, or feel relatively confident about installing someone else's. For now, students may contact the teacher at morbus@disobey.com.

  • Who's in the attic?

  • In non-Panther versions of OS X, Apple manually installed the optional PEAR, as well as a number of PEAR-released modules, into /System/Library/PHP. In Panther, they probably opted not to do this since PEAR became a default PHP extension. Unfortunately, it appears that the PEAR installation under 10.3 is incomplete (witness the "missing System.php" complaint when running /usr/bin/pear). Simply copying an existing System.php from Jaguar won't work, so you'll want to grab the latest from http://cvs.php.net/cvs.php/php-src/pear/System.php. Save this file to your Desktop and copy it into place with sudo cp ~/Desktop/System.php /usr/lib/php. You should then be able to run PEAR without a problem (list PEAR modules currently installed with sudo pear list).

  • Every time Mac OS X boots, zillions of things occur... a fair portion of this zillion is controlled by StartupItems, files that say what should run and when. To create your own StartupItems, take a look at "Creating SystemStarter Startup Item Bundles" (http://www.opensource.apple.com/projects/documentation/howto/html/SystemStarter_HOWTO.html) and "Start Me Up: Writing and Understanding OS X StartupItems" (http://www.oreillynet.com/pub/a/mac/2003/10/21/startup.html).

  • If you're interested in seeing what the MySQL PreferencePane actually does for you, the installation PDF provided with Complete MySQL has the command line equivalents.


Kevin Hemenway, coauthor of Mac OS X Hacks and Spidering Hacks, is better known as Morbus Iff, the creator of disobey.com, which bills itself as "content for the discontented." Publisher and developer of more home cooking than you could ever imagine (like the popular open-sourced aggregator AmphetaDesk, the best-kept gaming secret Gamegrene.com, the ever ignorable Nonsense Network, etc.), he is absolutely and positively disgusted by the lack of Jolt cola within walking distance. Contact him at morbus@disobey.com.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »

Price Scanner via MacPrices.net

New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more
Updated Apple MacBook Price Trackers
Our Apple award-winning MacBook Price Trackers are continually updated with the latest information on prices, bundles, and availability for 16″ and 14″ MacBook Pros along with 13″ and 15″ MacBook... Read more
Every model of Apple’s 13-inch M3 MacBook Air...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices are the lowest currently available for new 13″ M3 MacBook Airs among... Read more
Sunday Sale: Apple iPad Magic Keyboards for 1...
Walmart has Apple Magic Keyboards for 12.9″ iPad Pros, in Black, on sale for $150 off MSRP on their online store. Sale price for online orders only, in-store price may vary. Order online and choose... Read more
Apple Watch Ultra 2 now available at Apple fo...
Apple has, for the first time, begun offering Certified Refurbished Apple Watch Ultra 2 models in their online store for $679, or $120 off MSRP. Each Watch includes Apple’s standard one-year warranty... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
IT Systems Engineer ( *Apple* Platforms) - S...
IT Systems Engineer ( Apple Platforms) at SpaceX Hawthorne, CA SpaceX was founded under the belief that a future where humanity is out exploring the stars is Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.