Install ssl certificate on apache server in ubuntu 16.04

Install Apache2

sudo apt-get install apache2

Enable SSL Module

sudo a2enmod ssl

Apply SSL Module to Site

sudo a2ensite default-ssl
sudo /etc/init.d/apache2 restart

Add your certificates in default-ssl.conf in /etc/apache2/sites-available

SSLEngine on
SSLCertificateFile /path/to/your_domain_name.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/DigiCertCA.crt

 

Sometimes you need to create a .ca-bundle file. Use this command to create it

Note : the names of files should be something similar

cat ComodoRSAAddTrustCA.crt ComodoRSADomain/Organization/ExtendedvalidationSecureServerCA.crt AddTrustExternalCARoot.crt > yourDomain.ca-bundle

 

Advertisements

Getting Started With Amazon’s Database DynamoDB

DynamoDB is a fast, fully managed NoSQL database service. With DynamoDB, you can offload the administrative burden of operating and scaling a highly available distributed database cluster, while paying a low price for only what you use.

Getting Started with AWS PHP SDK

1. First of all you need to install phing. Run these two commands in your terminal.

$> pear channel-discover pear.phing.info
$> pear install [–alldeps] phing/phing

2. Now Download Packaged Phar from http://pear.amazonwebservices.com/get/aws.phar. Run this command in linux terminal

$> wget  http://pear.amazonwebservices.com/get/aws.phar

This will download aws.phar in your current directory.

3. Including the SDK in your project

 require ‘/path/to/aws.phar’;

4. Now You need to create a config file. Create config.php

<?php
return array(
'includes' => array('_aws'),
'services' => array(
 'default_settings' => array(
 'params' => array(
 'key' => 'Your Key  provided by Amazon',
 'secret' => 'Your Secret provided by Amazon',
 'region' => 'Your region'
 )
 )
 )
 );      ?>

5.  Adding data to your database. Create add_data.php

<?php
 require ("aws.phar");
 use Aws\DynamoDb\DynamoDbClient;
 use Aws\DynamoDb\Enum\ComparisonOperator;
 use Aws\DynamoDb\Enum\Type;
try
 {
 $aws = Aws\Common\Aws::factory("config.php");
 $client = $aws->get("dynamodb");
 $res=$client->putItem (array (
 'TableName' => 'Your_Table_Name',
 'Item' => $client->formatAttributes(array(
 'id' => '12345',
 'url' => 'www.fosterzen.com'
 ))
 ));
 }
 catch (Exception $ex)
 {
 echo $ex->getMessage();
 }
 print_r($res);
 ?>

It should enter id and url  provided in your table.

6. Querying for data. Create get_data.php

<?php
 require ("aws.phar");
 use Aws\DynamoDb\DynamoDbClient;
 use Aws\DynamoDb\Enum\ComparisonOperator;
 use Aws\DynamoDb\Enum\Type;
try
 {
 $aws = Aws\Common\Aws::factory("config.php");
 $client = $aws->get("dynamodb");
 $response = $client->getItem(array(
 "TableName" => "Your_Table_Name",
 "Key" => array(
 "id" => array( Type::STRING=> "12345" )
 )
 ));
 }
 catch (Exception $ex)
 {
 echo $ex->getMessage();
 }
echo $response[Item]['url']['S'];
 echo $response[Item]['id']['S'];
 ?>

7. Delete An Item

<?php
$response = $client->deleteItem(array(
    'TableName' => 'YourTableName',
    'Key' => array(
        'Id' => array(
            Type::NUMBER => 101
        )
    )
));
?>