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.
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:
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 &
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