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

Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.