Hurry! 20% Off Ends SoonRegister Now

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 https:// java.com/ en/ download/ help/ index_installing.xml).
2. Enable Java in your web browser (see https:// java.com/ en/ download/ help/ enable_browser.xml).

MindMajix YouTube Channel

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 the 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.

connect to instance

10. If necessary, click Yes to trust the certificate.
11. Click Run to run the MindTerm client.
12. If you accept the license agreement, click Accept.
13. If this is your first time running MindTerm, a series of dialog boxes will ask you to confirm the setup for your home directory and other settings.
14. Confirm settings for MindTerm setup.
15. A screen similar to the below opens and you automatically get connected to your instance.

MindTerm setup
To gain in-depth knowledge and be on par with practical experience, then explore AWS SysOps Training Course.
 

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.
Putty key generator
  • 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.
putty configuration

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.
PuTTY Configuration window

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.
 stored session box

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

[Related Page: Creating An Elastic Load Balancer In AWS]

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

AMI is ec2-user
  • 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.
Explore AWS Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download Now!

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:

SSH fingerprint

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 https:// www.openssh.org.

For an in-depth understanding and practical experience, Explore AWS Architect Training.

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.

Related Article: What is AWS Cloudformation

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.

Checkout Amazon EC2 Interview Questions

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]

2. 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

2. 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’.

3. Sign in and set the access database rights.
mysql -u root -p

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

4. 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’;

Checkout AWS IoT Tutorial

If successful, MySQL will reply with the following:

Query OK, 0 rows affected

5. 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

6. To activate the new permissions, enter the following command:
FLUSH PRIVILEGES;

If successful, MySQL will reply with the following:

Query OK, 0 rows affected

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

Address box

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

Set up database page

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.
Set up database page 1
  • 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.
Database host box
  • 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.
Configure site page
  • Click save and continue.

The installation is complete.

installation is complete

6) Click Visit your new site.

welcome window

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.

Related Pages:
AWS TRAINING
AWS TUTORIAL

List Of AWS Courses Offered By Mindmajix:

 AWS Certified SysOps Administrator AWS Certified Solutions Architect / Professional
 AWS Certified Developer AWS Lambda 2016
 AWS Technical Essentials AWS Database Migration Service
 AWS Certified DevOps Engineer and many more...

If you interested to learn AWS and building a career in Cloud Computing?  Then check out our AWS Certification Training Course at your near Cities

AWS Course in Ahmedabad, AWS Course in Bangalore  AWS Course in Chennai,  AWS Course in Delhi, AWS Course in Dallas, AWS Course in Hyderabad, AWS Course in London, AWS Course in Mumbai, AWS Course in NewYork, AWS Course in Pune

These courses are incorporated with Live instructor-led training, Industry Use cases, and hands-on live projects. This training program will make you an expert in AWS and help you to achieve your dream job.

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
AWS TrainingDec 24 to Jan 08View Details
AWS TrainingDec 28 to Jan 12View Details
AWS TrainingDec 31 to Jan 15View Details
AWS TrainingJan 04 to Jan 19View Details
Last updated: 02 Jul 2024
About Author

Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for MindMajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS.

read less
  1. Share:
AWS Articles