Go to a directory below the root of your website (usually /var/www/). Get the latest version of DyanmoDB local from Amazon using the command below.
wget http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz
Unzip the file after you get it.
tar -zxvf dynamodb_local_latest.tar.gz
Remove the tar.gz file after unzipping it.
rm -f dynamodb_local_latest.tar.gz
You then need to run this command to start DynamoDB local.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
To run this on boot of the server, you can setup or add to the boot script of the server. The boot script file on CentOS is:
/etc/rc.d/rc.local
You would just add the below to the file. Adding the ‘&’ at the end will make it non-blocking so if you have processes that need to run after it.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb &
Once you have it setup and running you can use the javascript shell that comes with it to add tables or input, edit and delete items.
http://yourdomain.com:8000/shell
I used PHP and interacted with the setup. This got a little tricky and I found the documentation provided by Amazon is incorrect with the configuration. Instead of ‘endpoint’ you need to use ‘base_url’ and you also need your key and secret even though they will not be used.
$client = DynamoDbClient::factory(array(
‘profile’ => ‘default’,
‘region’ => ‘us-west-2’, #replace with your desired region
‘endpoint’ => ‘http://localhost:8000’,
‘base_url’ => ‘http://localhost:8000’,
‘key’ => ‘YOURKEY’,
‘secret’ => ‘YOURSECRET’
));
Once you have your configuration setup like the above for PHP you can start using the <a href=”http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-dynamodb.html” target=”_blank”>PHP SDK</a> for Amazon like you would normally access the Hosted DyanmoDB.
Helpful links for Local Config
http://stackoverflow.com/questions/26022387/dynamodb-local-basic-php-setup
http://databasefaq.com/index.php/answer/64208/php-amazon-web-services-amazon-s3-s3client-php-sdk-object-of-class-class-could-not-be-converted-to-string
PHP DynamoDB
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelPHPItemCRUD.html