OSXFAQ Mac OS X UNIX Tip-of-the-Day
MySQL - Build the Apache PHP Module
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.
|