Friday, November 14, 2008

Facebook app on MacOS X Leopard + PHP + MySQL

PHP is preinstalled on MacOS X Leopard, so just go to system configuration, go sharing panel and activate web sharing. PHP is not initially enabled, so edit /private/etc/apache2/httpd.conf and uncomment this line:


LoadModule php5_module


MySQL is not preinstalled, so go to MySQL.org, download and install MySQL for Mac OS X. Start it, and then do the following:


/usr/local/mysql/bin/mysqladmin -u root password ’passwordhere’


Then edit /private/etc/php.ini (if there is no php.ini, then copy php.ini.default to php.ini) by adding the sockets for MySQL as follows:


mysql.default_socket = /private/tmp/mysql.sock
mysqli.default_socket = /private/tmp/mysql.sock


Now you are ready to access MySQL via PHP, using localhost as hostname and the password you set above as password.


Then download Facebook libraries for PHP, and try the Footprints application as explained in the doc. You'll have a jsonwrapper related error. Leopard comes standard with PHP 5.2, and jsonwrapper does not need to be included, so just comment out the following line in Facebook library:


include_once 'jsonwrapper/jsonwrapper.php';


That's it, have fun.


No comments: