# configuring php with mysql problem



## dtra (Jun 28, 2008)

hi all

i've searched the web and have seen people with similar problems, but no real solutions
i'm just a newbie with macs, but have had a few years experience using linux servers (nothing advanced but enough to get by)
i've installed mysql (64 bit) from the dmg provided by mysql.com (5.051 community edition), it's up and running
i've installed the apache web server from source (though i haven't really configured it yet)
but i'm having problems getting php to install (from source)
basically, i'm trying to set something up similar to what i've got running on dreamhost, so it will be a local test environment, i'm trying to set up a fast cgi php (basically a modified version of the script at http://wiki.dreamhost.com/index.php/Installing_PHP5) using php 5.2.6

```
./configure --prefix=/path/to/php5  --with-config-file-path=/path/to/php5
/etc/php5/example.com 
--enable-fastcgi --enable-force-cgi-redirect 
--with-libxml-dir=/path/to/php5 --with-freetype-dir=/path/to/php5 --enable-soap
 --with-openssl=/usr --with-mhash=/path/to/php5 
--with-mcrypt=/path/to/php5 --with-zlib-dir=/path/to/php5 --with-jpeg-dir=/sw 
--with-png-dir=/sw --with-gd --enable-gd-native-ttf 
--enable-ftp --enable-exif --enable-sockets --enable-wddx 
--with-iconv=/path/to/php5 --enable-sqlite-utf8 --enable-calendar 
--with-curl=/path/to/php5 --enable-mbstring --enable-mbregex 
--with-mysql=/usr/local/mysql --with-mysqli 
--with-pear=/path/to/php5/lib/php --with-gettext --with-imap=/usr 
--with-imap-ssl=/usr --enable-zip --enable-bcmath 
--with-pdo-mysql --with-kerberos
```

when i run configure, i get

```
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log for more information.
```

in config.log

```
configure:59418: checking for MySQL UNIX socket location
configure:59609: checking for mysql_close in -lmysqlclient
configure:59628: gcc -o conftest -I/path/to/php5/include -g -O2  -no-cpp-precomp -Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib -liconv -L/path/to/php5/lib  -Wl,-rpath,/path/to/php5/lib -L/path/to/php5/lib -Wl,-rpath,/sw/lib -L/sw/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib conftest.c -lmysqlclient  -lmhash -lmcrypt -lltdl -lssl -lcrypto -lpam -liconv -liconv -lintl -lfreetype -lpng -lz -ljpeg -lssl -lcrypto -lcurl -lz -lssl -lcrypto -lm  -lxml2 -lz -liconv -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lssl -lcrypto -lz -lxml2 -lz -liconv -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err 1>&5
ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
Undefined symbols:
  "_mysql_close", referenced from:
      _main in ccETiqHI.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
configure: failed program was:
#line 59617 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char mysql_close();

int main() {
mysql_close()
; return 0; }
configure:59851: checking for mysql_error in -lmysqlclient
configure:59870: gcc -o conftest -I/path/to/php5/include -g -O2  -no-cpp-precomp -Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib -Wl,-rpath,/path/to/php5/lib -L/path/to/php5/lib -liconv -L/path/to/php5/lib  -Wl,-rpath,/path/to/php5/lib -L/path/to/php5/lib -Wl,-rpath,/sw/lib -L/sw/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib -Wl,-rpath,/path/to/php5 -L/path/to/php5 conftest.c -lmysqlclient  -lz -lmhash -lmcrypt -lltdl -lssl -lcrypto -lpam -liconv -liconv -lintl -lfreetype -lpng -lz -ljpeg -lssl -lcrypto -lcurl -lz -lssl -lcrypto -lm  -lxml2 -lz -liconv -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lssl -lcrypto -lz -lxml2 -lz -liconv -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err 1>&5
ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
Undefined symbols:
  "_mysql_error", referenced from:
      _main in cckceZnr.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
configure: failed program was:
#line 59859 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char mysql_error();

int main() {
mysql_error()
; return 0; }
```

i see that it says file is not of required architecture in the config.log, i'm not sure what that means, is my system not 64 bit? should i be using the 32 bit mysql? it's a macbook i got less than two months ago, the middle version

[update]
well i tried the 32 bit mysql, and that seems to work a bit better, but i run into a different problem, similar to http://www.phpbuilder.com/board/showthread.php?threadid=10326862
but their solution isn't working, the shared libs did exist already

other than that, i'm pretty sure that php will configure.

any suggestions
dave


----------



## ksv (Jun 29, 2008)

From my experience, you need to build mysql from source as well for php to be able to build with the mysql extension. Just download the mysql source package and follow the instructions for Mac OS X.

Apparently you need a 32 bit mysql build to build php in 32 bit, but once php is built it can communicate perfectly with a 64 bit mysql installation.

If you're running leopard, you'll have to build php as well in 64 bit.

This should get you a step further:
http://blog.softboysxp.info/2008/05/27/compiling-64-bit-php-on-mac-os-x-leopard/


----------



## dtra (Jun 29, 2008)

hi
thanks for your reply
i may have to recompile apache as well then, cos i want to customise that as well
i'm not sure if it's the mac or the 64bit, but this was a lot easier to set up on my fedora 8 machine (32 bit)
one advantage i guess, is that i should learn a bit more about this low level stuff 

thanks again
dave


----------



## ksv (Jun 29, 2008)

It's both; Mac OS X doesn't have as many preinstalled libraries as linux usually does, which means you have to install some of those required for php manually. Also the apache installation in leopard runs in 64 bit on 64 bit machines, which means modules like php must be compiled as 64 bit or universal bimary.


----------

