Thursday, June 5, 2014

Setting up Wordpress on Elastic Beanstalk

ElasticBeanStalk is a service that automates scaling, load-balancing, and deploying applications so you can concentrate on only software development. In a way, it is very similar to Google App Engline.

In this article, we will visit how we can set up Wordpress on Elastic Beanstalk.


Configuration the Elastic Beanstalk Environment

First log into your ElasticBeansTalk and click on Create a New Application.

Enter the Application Name and Description and click Next.

Click on "Create one now" to create a new environment.

Environment tier: Web Server 1.0
Predefined configuration: PHP
Environment type: Load balancing, autoscaling

Note for Environment tier, Web Server handles web requests (HTTP/S) while workers handle background processes.

Choose sample application for now

You will then be prompted to input an Environment Name. Label it whatever, as we will use CNAME later.

For Additional Resources, check create an RDS DB instance with this environment.

In Configuration Details, select your EC2 key pair and leave the other details as it is. You can always change these later.

For RDS configuration, put 5GB for allocated storage. Input the username and password. Select Create snapshot and single availability zone.

Click Launch.

Once it's launched, click Configuration on the left sidebar, then Software Configuration. In PARAM1, set to production, staging or something else.


Installing Wordpress

We need to have different wp-config files for local development and Elastic BeanStalk. Let's define the local config as local-config.php.

Set up wordpress in your local computer. 

In wp-config, replace the database configs with the following: 

if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
    define( 'WP_LOCAL_DEV', true );
    include( dirname( __FILE__ ) . '/local-config.php' );
} else {
    define( 'WP_LOCAL_DEV', false );
    define('WP_HOME','');
    define('WP_SITEURL','');
    define('DB_NAME', 'database');
    define('DB_USER', 'username');
    define('DB_PASSWORD', 'password');
    define('DB_HOST', 'localhost');
}

Fill in the above db_name, db_user, db_password, db_host with the appropriate settings.

Create a file called local-config.php at the same directory as wp-config.php

Put in the following with your local database information.

<?php
    define('WP_HOME','');
    define('WP_SITEURL','');
    define('DB_NAME', '');
    define('DB_USER', '');
    define('DB_PASSWORD', 'root');
    define('DB_HOST', '');


Install AWS ElasticBeanstalk Tools and AWSDevTools

Download  from http://aws.amazon.com/code/6752709412171743

Read this: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.GetSetup-devtools.html

Check to make sure eb is running properly:

eb --version

Configure your ElasticBeanstalk Git settings:

git aws.config

Reading Credentials from C:\Users\Kenneth\.elasticbeanstalk\aws_credential_file.

The file does not exist.  You can supply credentials by creating the file or editing .elasticbeanstalk/config to reference a different file.
The credential file should have the following format:

AWSAccessKeyId=your key
AWSSecretKey=your secret

AWS Access Key:
AWS Secret Key:
AWS Region [default to us-east-1]: (Check this in your Elastic Beanstalk console)
AWS Elastic Beanstalk Application: <put in the application name you created above>
AWS Elastic Beanstalk Environment: <put in the environment name you created above>

Check if Elastic Beanstalk can detect your app:

eb status --verbose

Now deploy your application:

git aws.push

Remember to use Route53 to map to Elastic Beanstalk.

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customdomains.html

After you point the domain to the Elastic Load Balancer. If the site does not load up in the browser, do not panic. Give it 15 mins. It will be back up.

Wednesday, May 14, 2014

AWS s3 - The specified bucket is not valid.

If you receive the message "The specified bucket is not valid." while trying "enable website hosting", make sure your bucket name adhere to the following:

- Should not contain uppercase characters
- Should not contain underscores (_)
- Should be between 3 and 63 characters long
- Should not end with a dash
- Cannot contain two, adjacent periods
- Cannot contain dashes next to periods (e.g., "my-.bucket.com" and "my.-bucket" are invalid)

Sunday, April 27, 2014

composer update killed on ec2 micro

I was updating my symfony plugins using composer and I received the following error in ssh:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Killed

My research founded that it's because the ec2 instance does not have enough ram to perform such an update.

What you can do is to do a "composer.phar update" in a local machine. This would produce a composer.lock file.

Upload this .lock file to production, and run "composer.phar install" instead.

Saturday, February 8, 2014

Study Flashcards For Android

During the past month, I worked on a new version of StudyFlashcard For Android.

StudyFlashcard 3.0 is a mobile flashcards application for students to learn foreign languages, review exam materials, or simply as a memorization tool.
Here is the UI of the application:











StudyFlashcard Android is different from other flashcard applications in the following ways:

1) Organize flashcards with #hashtags

Powerful #hashtag system lets you add flashcards to your midterms, exams, favorite lists, or secret lists. Study in whatever ways you imagine.
2) Study multiple subjects at once with Merge Play

Whether you have three exams on the same day or you are just bored of studying one subject for too long, Merge Play lets you study multiple flashcard sets together.
3) Study multiple questions at once with Cram Mode (Web only)

Cram mode offers a multi-column view that lets you study a lot of questions at once. This is perfect for a quick memory refresh before exams.
4) Perfect for learning vocabularies and foreign languages with three sided flashcards

Each StudyFlashcard has three sides: question, answer, and hint. Three-sided flashcards are perfect for learning Asian languages such as Chinese and Japanese.

Full list of features:

• Sync Flashcards with StudyFlashcard.com
• Score tracking
• hashtags
• play multiple sets of flashcards/quizzes at the same time
• Sign up is not necessary
• Works completely offline (You can create flashcards offline)
• Three sided flashcards/quizzes with question, answer and hint
• Can adjust text size


Give StudyFlashcard Android a try. Let us know what you think.