DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day  back to index

MySQL - Build the Apache PHP Module

By Adrian Mayo - Editor - OSXFAQ

As of the 10.4.4 update, and until Apple corrects it, the Apache-PHP module was built in a way that's incompatible with most MySQL installs. This can be corrected by building your own PHP install, or by re-installing and re-configuring MySQL. The problem lies in the configuration of Apple's PHP build, applied when Apple builds the PHP module. In particular, Apple used the configuration commands:

'--with-mysql=/usr'
'--with-mysql-sock=/var/mysql/mysql.sock'

meaning MySQL is expected to be found at /usr instead of /usr/local, and also the socket is to be found at /var/mysql instead of /tmp.

You can solve this by moving the MySQL installation and starting the MySQL daemon (in the startup items) using the option:

--socket=/var/mysql/mysql.sock

Alternatively, re-build PHP. These instruction apply to PHP-4. If you are running 5, you'll already know how to install PHP-5.

Download the (bzip2) source from: PHP.

Extract it by typing:

$ tar xf php-4.4.1.tar.bz2 --bzip2
$ cd php-4.4.1

(You version may be different to 4.1.1).

Configure it by typing (on a single command line):

$ ./configure --with-mysql=/usr/local/mysql
--with-apxs --mandir=/usr/local/share/man

Or, for a more fully featured PHP, configure by typing:

$ ./configure --prefix=/usr/local
--mandir=/usr/local/share/man --with-apxs
--with-mysql=/usr/local/mysql
--with-mysql-sock=/tmp/mysql.sock
--with-openssl=/usr --with-ldap=/usr
--with-kerberos=/usr --with-zlib-dir=/usr
--with-iodbc=/usr --with-curl=/usr --enable-exif
--enable-ftp --enable-dbx --enable-sockets

Build it by typing:

$ make

Install it by typing:

$ sudo -s
Password:
# mv /usr/libexec/httpd/libphp4.so /usr/libexec/httpd/libphp4.so.orig
# make install

NOTE: Run

./configure --help

for a full list of the configure options.

Restart Apache (if it's already running) so the new PHP module is read.

# apachectl graceful

Install extra packages with PEAR. The install does not include the DB package by default. (Why?) It can be installed by user root using pear. Type:

# pear install DB
NOTE: Some handy pear commands:
  pear                # lists all pear commands
  pear help command   # get help on a specific command
  pear config-show    # shows the config settings, these       
                        should point to directories
                        within /usr/local
  pear list           # list all installed packages

With any luck, you should have an Apache-PHP module that talks to the MySQL 5 installation from the earlier tips.


Visit the Site of the Book of the Unix Tips:


Discuss this trick in the OSXFAQ Learning Center forum

E-mail your comments or suggestions to webmaster@osxfaq.com


Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.