how to setup facebook php client library on Amazon EC2 AMP AMI


before you begin, have a quick look at the opensolaris AMP AMI(Amazon Machine Images) catalog
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1692

Following are the steps for setting up facebook application development platform on amazon ec2 AMP AMI.

[ step 1]
Launch ec2 instance using the AMI ID (ami-45f1152c) and get the instance id

bash # ec2-run-instances -k <your-keypair> ami-45f1152c

[ step 2]
get the public dns address of the instance using the instance id

bash # ec2-describe-instances <i-xxxxxxxx>

[ step 3]
make ssh connection to the instance.

bash # ssh -i <keypair file> ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com

[ step 4]
download Official PHP client library from http://wiki.developers.facebook.com/index.php/PHP

bash # cd /var/apache2/2.2/htdocs/
bash # wget http://developers.facebook.com/clientlibs/facebook-platform.tar.gz

[ step 5]
extract the platform library and place it at appropriate location

-bash # pwd
/var/apache2/2.2/htdocs
bash # gunzip facebook-platform.tar.gz
bash # tar -xf facebook-platform.tar
bash # rm facebook-platform.tar
bash # cd facebook-platform/
bash # mv client/ facebookphp/
bash # mv facebookphp/ /usr/lib/

[ step 5]

make necessary changes in the php.ini file located at /etc/php5/5.2/php.ini
add “/usr/lib/facebookphp” path in the include_path variable.

after the change it should look like this

include_path = ".:/var/php/5.2/pear:/usr/lib/facebookphp"

enable the short_open_tag, so that you can run sample facebook application correctly without any error.

after the change it should look like

short_open_tag = On

[step 6]

restart the apache to apply the changes done in the php.ini file.

bash # svcadm restart svc:/network/http:apache22

[step 7]

arrange directories and perform clean up.

bash # cd /var/apache2/2.2/htdocs/facebook-platform
bash # mv footprints/ ../
bash # mv README ../footprints/
bash # cd ..
bash # pwd
/var/apache2/2.2/htdocs
bash # rm -rf facebook-platform/

[step 8]
change the include path in the sample footprint application as we no longer require relative path for the client library.Library path is already included within the php.ini file.

bash # cd footprints/
bash # vi index.php

change

// the facebook client library
include_once '../client/facebook.php';

to

// the facebook client library
include_once 'facebook.php';

[step 9]

facebook php client library is now installed and necessary changes has been applied to the sample footprint application.

follow the Readme file located at /var/apache2/2.2/htdocs/footprints/README to begin testing facebook application on amazon ec2.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s