Mindmajix

How to Deploy Your Web Application into AWS

Deploy Your Application

Now that, you’ve launched your Amazon EC2 instance, it’s time to connect to it and deploy your application. In this post, you’ll first connect to your Amazon EC2 instance, and then you’ll deploy Drupal, which is already available on the Linux AMI.

Connecting to your Amazon EC2 Instance from Your Web Browser Using the MindTerm SSH Client:

The steps to connect to a Linux/ UNIX instance using your browser are as follows:

  1. Install and Enable Java on Your Browser
  2. Connect Using the MindTerm (SSH) Client

Install and Enable Java on Your Browser:

To connect to your instance from the Amazon Elastic Compute Cloud (Amazon EC2) console, you must have Java installed and enabled in your browser. To install and enable Java, follow the steps provided by Oracle as shown below or contact your IT administrator to install and enable Java on your web browser.

  1. Install Java (see http:// java.com/ en/ download/ help/ index_installing.xml).
  2. Enable Java in your web browser (see http:// java.com/ en/ download/ help/ enable_browser.xml).

Connect Using the MindTerm (SSH) Client

To connect to your instance through a web browser

  1. Sign in to the AWS Management Console and open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  2. In the Navigation pane, click Instances.
  3. Right-click your instance, and then click Connect.
  4. Click Connect from your browser using the MindTerm SSH client (Java Required). AWS automatically detects the public DNS address of your instance and the key pair name you launched the instance with.
  5. In User name, enter the user name to log in to your instance. For this example, enter eC2user.
  6. The Key name field is automatically populated for you.
  7. In Path to private key, enter the fully qualified path to your .pem private key file.
  8. Click Save key location, click Stored in browser cache to store the key location in your browser cache so that the key location is detected in subsequent browser sessions, until you clear your browser’s cache.
  9. Click Launch MindTerm.
  10. Screenshot_8
  11. If necessary, click Yes to trust the certificate.
  12. Click Run to run the MindTerm client.
  13. If you accept the license agreement, click Accept.
  14. If this is your first time running MindTerm, a series of dialog boxes will ask you to confirm setup for your home directory and other settings.
  15. Confirm settings for MindTerm setup.
  16. A screen similar to the below opens and you automatically get connected to your instance.

Screenshot_9

Connect to Your Amazon EC2 Instance from a Windows Computer Using PuTTY:

If you are running Windows from your local machine, Secure Shell (SSH) is not built in, so you will need to install PuTTY and PuTTYGen. You’ll need the contents of the private key file that you created (e.g., mykeypair.pem) in Step 4: Launch an Instance.

To connect to your Amazon EC2 instance from a Windows machine

1) Download and install PuTTY and PuTTYGen. A search on “download Putty” on Google returns a list of download sites. Be certain that you install both PuTTY and PuTTYGen, because you will need both of them.

2) Convert the key pair using PuTTYGen. For information on key pairs, see Step 4: Launch an Instance.

  • Launch PuTTYGen. On the Conversions menu, click Import Key.
  • Browse for mykeypair.pem, and then click Open.

Screenshot_10

  • Click Save private key. In the message it asks if you want to continue without a passphrase, click OK. Save the key as mykeypair.ppk.
  • Close PuTTYGen.

3) Configure the SSH settings.

  • Start PuTTY, expand the SSH node, and then click Auth.
  • In the Private key file for authentication box, enter the location for mykeypair.ppk.

Screenshot_11

4) Modify the keepalive.

  • In the PuTTY Configuration window, in the Catgeory pane, click Connection.
  • In the Seconds between keepalives (0 to turn off) box, type 60. If you don’t change this value, your session will time out.

Screenshot_12

5) Save the session settings.

  • In the PuTTY configuration window, in the category pane, click session.
  • In the load, save, or delete a stored session box, click default settings, and click save.

Screenshot_13

6) Type the DNS address of the Amazon EC2 instance, which you have retrieved in the previous task.

  • In the PuTTY Configuration window, in the Category pane, click Sessions. In the Host Name (or IP address) box, type < ec2-user@ DNS address of your Amazon EC2 instance >.

Note : The user name for the AMI is ec2-user.

Screenshot_14

  • Click Open. When the PuTTY Security Alert dialog box appears, click Yes to confirm that the fingerprint is OK. The SSH PuTTY window will open.

Note : The SSH fingerprint will eventually appear in the system log. You can use the SSH fingerprint as a comparison to protect against a man in the middle attack. For more information, go to Connecting Using PuTTY SSH in the Amazon Elastic Compute Cloud (Amazon EC2) User Guide.

Your screen should look similar to this:

Screenshot_15

Now that you have successfully signed in to your instance, you are ready to configure it. For instructions on configuring your instance, see Configure the Amazon EC2 Instance.

Connecting to Your Amazon EC2 Instance from a Linux/ UNIX Machine Using a Standalone SSH Client:

Use the ssh command to connect to your Linux/ UNIX instance from a Linux/ UNIX computer.

Note : Most Linux and UNIX computers include a Secure Shell (SSH) client by default. If yours doesn’t, the OpenSSH project provides a free implementation of the full suite of SSH tools. For more information, go to http:// www.openssh.org.

To use SSH to connect

  1. In a command line shell, change directories to the location of the private key file that you created in Step 4: Launch an Instance.
  2. Use the chmod command to ensure that your private key file isn’t publicly viewable. For example, for mykeypair.pem, you would enter the following : chmod 400 mykeypair.pem
  3. Sign in to the AWS Management Console and open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  4. In the Navigation pane, select US East (Virginia) from the Region drop-down menu.
  5. Click Instances in the Navigation pane.
  6. Right-click your instance, and then click Connect.
  7. Click Connect using a standalone SSH client. AWS automatically detects the public DNS address of your instance and also the key pair name you have launched the instance with.
  8. Connect to your instance by using the public DNS name of the instance. For example, if the key file is mykeypair.pem and the instance’s DNS name is ec2-184-72-209-110. compute-1. amazonaws.com, use the following command.

ssh -i mykeypair.pem ec2-user@ ec2-184-72-209-110. compute-1. amazonaws.com

Note : We use ec2-user as the user name in this exercise for this AMI.

You’ll see a response like the following.

The authenticity of host ‘ec2-184-72-209-110. compute-1. amazonaws.com (10.254.142.33)’ can’t be established.

RSA key fingerprint is 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00: 00.

Are you sure you want to continue connecting (yes/ no)? yes

Note The SSH fingerprint will eventually show up in the system log. You can use the SSH fingerprint as a comparison to protect against a man in the middle attack. For more information, go to Connect to Linux/ UNIX Instances from Linux/ UNIX with SSH in the Amazon Elastic Compute Cloud (Amazon EC2) User Guide.

  • Enter yes.

You’ll see a response like the following.

Warning: Permanently added ‘ec2-184-72-209-110. compute-1. amazonaws.com’ (RSA) to the list of known hosts.

Now that you have successfully logged into your instance, you are ready to configure your instance. For instructions on how to configure your instance, see Configure the Amazon EC2 Instance.

Configure the Amazon EC2 Instance:

In this topic, we will configure the running instance. You will do the following tasks:

  • Set permissions on the settings file
  • Install MySQL Server.
  • Start the web server and MySQL.
  • Configure a database.
  • Configure the application.

To simplify this tutorial, we are creating a database that will run locally on one Amazon EC2 instance. You will configure the Drupal application to use this Amazon EC2 instance for your database; all other Amazon EC2 instances will connect to this instance to access the database.

If you are going to use more than one Amazon EC2 instance, you will usually set up your database on a different server from the one that is running your application. That way, the information is stored in one location, and all instances have access to the same data instead of a local running database that may be out of sync.

Creating a separate database is beyond the scope of this document. For more information about setting up Amazon RDS for your web application, go to Step 8: Add Amazon RDS inside the Getting Started Guide Web Application Hosting for Linux.

To set permissions on the settings file

  • On your Amazon EC2 instance, at a command prompt, use the following command to set permissions:
sudo chmod 666 /var/ www/ html/ sites/ default/ settings.php

To install a MySQL Server

  • On your Amazon EC2 instance, at a command prompt, use the following command to install MySQL Server:

sudo yum install mysql-server

When you are prompted, type ‘y’.

To start the web server and MySQL

  1. On your Amazon EC2 instance, at a command prompt, start the web server, and then configure it to start up automatically on reboot:

sudo chkconfig httpd on

sudo service httpd start

You’ll see a response like the following.

Starting httpd [OK]

  1. Start mysql, and configure it to start up automatically on reboot.

sudo chkconfig mysqld on

sudo service mysqld start

You’ll see a response like the following.

Starting mysqld [OK]

To configure a database

  1. On your Amazon EC2 instance, update the password for the ‘root’ user. In this example, you’ll use the password ‘root’.

mysqladmin -u root password root

  1. Create a database. In this example, you’ll use the database name ‘mydb’. mysqladmin -u root -p create mydb

When you are prompted for a password, type ‘root’.

  1. Sign in and set the access database rights.

mysql -u root -p

When you are prompted for a password, type ‘root’.

  1. At the MySQL prompt, set the permissions by using the following command. Replace < your public EC2 DNS address > with the public DNS address of the Amazon EC2 instance, which you recorded in Step 4: Launch an Instance.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON mydb.* TO ‘awsuser’@’ < your public EC2 DNS address >’ IDENTIFIED BY ‘mypassword’;

If successful, MySQL will reply with the following:

Query OK, 0 rows affected

  1. At the MySQL prompt, set the permissions by using the following command.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLE ON mydb. *TO ‘a ‘awsuser’@’%’ IDENTIFIED BY ‘mypassword’;

If successful, MySQL will reply with the following:

Query OK, 0 rows affected

  1. To activate the new permissions, enter the following command:

FLUSH PRIVILEGES;

If successful, MySQL will reply with the following:

Query OK, 0 rows affected

  1. Exit the MySQL prompt by typing the following:

exit

The server responds with the following:

Bye

To configure the application:

1) Open your web browser. In the Address box, type the public DNS address of the Amazon EC2 instance, which you have recorded during the process of Launching an Instance. The Choose profile page appears in the Drupal installation wizard.

2) On the Choose profile page, click Standard, and then click Save and continue.

 Screenshot_16

3) On the Choose language page, click English, and then click Save and continue. The Set up database page appears.

Screenshot_17

4) On the Set up database page, enter the following information.

  • Under Database type, click MySQL, MariaDB, or equivalent.
  • In the Database name box, type the name of your database. In this example, you’ll use mydb.
  • In the Database username box, type the user name for your database. In this example, you’ll use aws user.
  • In the Database password box, type the password for your database. In this example, you’ll use my password.

Screenshot_18

  • Click Advanced Options.
  • In the Database host box, type the public DNS address of your Amazon EC2 instance, which you recorded in process of Launch an Instance.

Screenshot_19

  • Click Save and continue.

5) On the Configure site page, enter the following information.

  • In the Site name box, type a name for your site.
  • In the Site e-mail address box, type your email address.
  • In the username box, type a user name.
  • In the password box, type a password that corresponds to the user name.
  • In the confirm password box, retype the password.

Screenshot_20

  • Click save and continue.

The installation is complete.

Screenshot_21

6) Click Visit your new site.

Screenshot_22

7) To add a new article to your site, click Add new content.

Congratulations! You have successfully deployed your web application with Amazon Web Services. In the future, if you ever decide to launch more instances, you won’t want to customize each one. Let’s create a custom AMI that incorporates all the configuration changes we’ve made.


Enroll for Instructor Led Live Amazon Web Services Training

0 Responses on How to Deploy Your Web Application into AWS"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.