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

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom 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
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.