Submitted by rok on

I've ran into an issue with my PHP mapper script where an PHP extension I needed was missing. These are the extensions available that mapreduce instances start with by default.

hadoop@ip:~$ php -m
[PHP Modules]
bcmath
bz2
calendar
ctype
date
dba
dom
exif
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
mime_magic
ncurses
openssl
pcntl
pcre
PDO
pdo_sqlite
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
SQLite
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

In order to add specific PHP extensions that you need you have to create a bootstrap script that Amazon will run before your jobs.

As an example if you want to install PHP cURL extension crate a install-script.sh file and put code bellow in it.

#!/bin/bash
sudo apt-get -y install php5-curl

This will install php extension and not ask any questions. Now all you need is to put this script in your S3 bucket and tell Amazon to run this as a bootstrap script. If you start your jobs via Amazon console you can do that on Bootstrap actions step or if you use Amazon Elastic MapReduce ruby client add

--bootstrap-action s3n://[bucket]/path/to/install-script.sh

to your commands.

Tags: 

Add new comment