I've recently upgraded to OS X 10.6 Snow Leopard and I was quite happy to know that it came with recent versions of Apache, PHP and Python. The first thing I did was enable PHP in Apache by editing http.conf
sudo mate /etc/apache2/httpd.conf
and then I uncommented the PHP line by changing
#LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module libexec/apache2/libphp5.so
on line 115.
Next, I checked out my company's source code and browsed to the website at http://localhost/~mwilliamson/website and tried to login. Unfortunately, I came across this lovely error:
Warning:
mysql_pconnect(): OK packet
6 bytes shorter than expected in
/Users
/mwilliamson
/Sites
/GCS
/EZrate
/classes
/database.
class.php on line
59
Warning:
mysql_pconnect(): mysqlnd cannot connect to
MySQL 4.1+ using old authentication in
/Users
/mwilliamson
/Sites
/GCS
/EZrate
/classes
/database.
class.php on line
59 mysqlnd cannot connect to
MySQL 4.1+ using old authentication
So I Googled around and saw various people with the same issue where none was able to be fixed. I checked to see if the MySQL database was using old passwords-- it wasn't. I changed the password on the database user. No dice. Then I decided to recompile PHP without mysqlnd and woo! It worked! Naturally, I'm making it sound much quicker than it really was. This took several days.
Here's the commands to recompile PHP and restart Apache.
$ cd ~/Downloads
$ curl http://us.php.net/distributions/php-5.3.0.tar.gz -o php-5.3.0.tar.gz
$ tar -xzf php-5.3.0.tar.gz
$ cd php-5.3.0
We can't make and install yet. There's a bug in the PHP sources which messes up iconv. We'll need to change line 186 in ext/iconv/iconv.c:
change:
#ifdef HAVE_LIBICONV
#define iconv libiconv
#endif
to
#ifdef HAVE_LIBICONV
#define iconv iconv
#endif
Save, then run:
$ ./configure '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-exif' '--enable-ftp' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=/usr/local/mysql' '--with-mysql-sock=/var/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-iodbc=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr'
Calling `Make` at this point will yield the following error:
Undefined symbols:
"_res_9_dn_expand", referenced from:
_php_parserr in dns.o
_php_parserr in dns.o
...
ld: symbol
(s
) not found
collect2: ld returned
1 exit status
make:
*** [libs
/libphp5.bundle
] Error
1
We'll need to change the Makefile first. Add "-lresolv" to the EXTRA_LIBS line on line 102 like so:
EXTRA_LIBS = -lexslt -liodbc -lmysqlclient -lldap -llber -liconv -liconv -lssl -lcrypto -lcurl -lbz2 -lz -lssl -lcrypto -lm -lxml2 -lz -licucore -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lssl -lcrypto -lssl -lcrypto -lz -lz -lxml2 -lz -licucore -lm -lmysqlclient -lz -lm -liodbc -lxml2 -lz -licucore -lm -lnetsnmp -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxslt -lxml2 -lz -licucore -lm
to
EXTRA_LIBS = -lexslt -liodbc -lmysqlclient -lldap -llber -liconv -liconv -lssl -lcrypto -lcurl -lbz2 -lz -lssl -lcrypto -lm -lxml2 -lz -licucore -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lssl -lcrypto -lssl -lcrypto -lz -lz -lxml2 -lz -licucore -lm -lmysqlclient -lz -lm -liodbc -lxml2 -lz -licucore -lm -lnetsnmp -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxslt -lxml2 -lz -licucore -lm -lresolv
Then we can build and install:
$ make
$ sudo make install
$ sudo apachectl restart
Hope it helps!