Skip to content

Instantly share code, notes, and snippets.

@oh-sky
Created October 22, 2015 00:47
Show Gist options
  • Save oh-sky/1b101ec897cf06136cf1 to your computer and use it in GitHub Desktop.
Save oh-sky/1b101ec897cf06136cf1 to your computer and use it in GitHub Desktop.
aws-lambda-hello-php
<?php
echo "Hello world.\n";
exports.handler = function(event, context) {
var exec = require('child_process').exec;
exec('sh script.sh', function (error, stdout, stderr) {
if(stdout){
console.log('stdout: ' + stdout);
}
if(stderr){
console.log('stderr: ' + stderr);
}
if (error !== null) {
console.log('Exec error: ' + error);
}
context.succeed(stdout);
});
};
#!/bin/sh
cp php /tmp/php
chmod a+x /tmp/php
mkdir /tmp/lib
cp lib/libedit.so.0 /tmp/lib/libedit.so.0
export LD_LIBRARY_PATH=/tmp/lib:$LD_LIBRARY_PATH
/tmp/php hello.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment