Friday, 6 May 2022

Amazon WebService | AWS Tutorial

Install Tomcat using Yum Package Manager,Configure Tomcat Users,Deploy the WAR file in EC2 Instance?

🚀 Master the Cloud with Ease!

Subscribe to Ram N Java for professional AWS and Java guides that actually make sense!

YES, I WANT TO SUBSCRIBE!

The Ultimate Guide to Tomcat on AWS EC2

Deploying a Java application to the cloud is a major milestone for any developer. Apache Tomcat is the industry-standard web server for Java, and hosting it on an Amazon EC2 instance gives you incredible scale and control. This guide walks you through the entire process, from installation to deploying your first WAR file.

Step 1: Install Tomcat Using Yum

Using the Yum package manager is the fastest way to get Tomcat running on Amazon Linux. Connect to your EC2 instance via SSH and run the install command. This ensures all the necessary dependencies are handled automatically by the system.

Step 2: Configure Tomcat Users

To access the Tomcat Manager GUI, you need to set up user permissions. Navigate to the tomcat-users.xml file and add roles like "manager-gui" and "admin-gui." This allows you to upload and manage your web applications directly through your browser.

Step 3: Allow Remote Access

By default, Tomcat's Manager app is restricted to localhost. You'll need to modify the context.xml file within the Manager app folder to allow traffic from your specific IP address. Don't forget to also open Port 8080 in your AWS Security Group!

Step 4: Deploy Your WAR File

The "moment of truth" is deploying your application. You can either upload your .war file through the Tomcat Manager Dashboard or manually move it into the webapps directory on your server. Tomcat will automatically extract and start your application.

Step 5: Verify Your Deployment

Open your browser and enter your EC2 public IP followed by :8080/your-app-name. If everything is set up correctly, you should see your Java application live on the internet! Congratulations on your cloud deployment!

How to keep SSH connections alive in Linux and Mac OS X operating systems?

How do I stop PuTTY inactive? | How do you fix PuTTY inactive? | How to keep SSH connections alive?

How To Configure Apache Tomcat Users on Amazon EC2 Linux Server? | Apache Tomcat 9 Configuration

🚀 Master AWS and Java Configuration!

Join the Ram N Java community for more expert cloud server tutorials!

YES, I WANT TO SUBSCRIBE!

Setting Up Apache Tomcat Users on Amazon EC2

After installing Apache Tomcat on your Amazon EC2 Linux instance, the next essential step is configuring users. This allows you to access the Manager and Admin dashboards, which are critical for deploying and managing your Java applications. Without proper user roles, you'll find yourself locked out of these powerful GUI tools.

Step 1: Locate the Configuration File

All user management in Tomcat happens inside a file called tomcat-users.xml. On a standard Linux installation via Yum or Tarball, you'll typically find this in the conf directory of your Tomcat installation. Use a text editor like Vi or Nano to open it with administrative privileges.

Step 2: Defining Roles

Before you create a user, you must define what they can do. Tomcat uses "roles" to manage permissions. The most common roles you'll need are manager-gui (to access the application manager) and admin-gui (to access the host manager). Adding these tags is the first step toward gaining control.

Step 3: Creating Your User

Now, add a user tag between the <tomcat-users> elements. You will need to specify a username, a password, and assign the roles you defined in the previous step. Make sure to use a strong password, especially since your EC2 instance is likely accessible via the public internet!

Step 4: Restarting the Tomcat Service

Tomcat only reads the tomcat-users.xml file when it starts up. After saving your changes, you must restart the service for them to take effect. Use the command sudo systemctl restart tomcat or your specific startup script to refresh the configuration.

Step 5: Accessing the Dashboard

Open your browser and navigate to your-ec2-ip:8080. Click on "Manager App" and enter the credentials you just created. If configured correctly, you are now ready to deploy WAR files and manage your server with ease!

How To Install Apache Tomcat 9 on Amazon EC2 Linux Server? | Apache Tomcat 9 Installation Linux

🚀 Master Cloud Server Setup!

Subscribe to Ram N Java for more expert AWS and Java tutorials!

YES, I WANT TO SUBSCRIBE!

Installing Apache Tomcat 9 on Amazon EC2 Linux

Setting up a web server on the cloud is a fundamental skill for any modern developer. Apache Tomcat 9 is a reliable, powerful choice for hosting your Java applications. In this guide, we will walk through the exact steps to get Tomcat running on an Amazon EC2 Linux instance, even if you are just starting your cloud journey.

Step 1: Prepare Your EC2 Instance

First, log in to your Amazon EC2 instance using SSH. Ensure your system is up to date and that you have a Java Development Kit (JDK) installed, as Tomcat requires Java to run. Without Java, the server simply won't start!

Step 2: Download the Tomcat 9 Package

Navigate to the official Apache Tomcat website to find the download link for the latest version of Tomcat 9. Use the wget command in your Linux terminal to download the tarball directly to your server. This ensures you are getting the original, unmodified files.

Step 3: Extract and Set Permissions

Once the download is complete, use the tar -xvf command to extract the files. It's common practice to move the extracted folder to /opt/tomcat. Make sure to give your user permission to execute the scripts in the bin folder.

Step 4: Configure AWS Security Groups

By default, AWS blocks traffic on the ports Tomcat uses. You must go to the AWS Management Console and add an Inbound Rule to your Security Group to allow traffic on Port 8080. This is what allows you to access the server from your browser.

Step 5: Start Your Server

Navigate to the Tomcat bin directory and run ./startup.sh. To verify it's working, open your web browser and enter your EC2 instance's public IP address followed by :8080. If you see the Tomcat welcome page, you have succeeded!

How To Install MariaDB on Amazon EC2 Linux Server? | MariaDB Installation Linux | AWS EC2 Tutorial

🔥 Want to Master AWS & Java?

Subscribe to Ram N Java for more easy-to-follow technical tutorials!

SUBSCRIBE ON YOUTUBE

Introduction

MariaDB is one of the most popular open-source relational databases. In this guide, we will walk through the entire process of installing MariaDB on an Amazon EC2 Linux instance and show you how to set up a secure root password.

Step 1: Install MariaDB

First, connect to your EC2 instance via SSH. To check for available MariaDB packages and install the server, run these commands:

# Check available packages
sudo yum list mariadb*

# Install MariaDB Server
sudo yum install mariadb-server

Step 2: Start and Enable the Service

After installation, you need to start the MariaDB service and enable it so that it starts automatically when the server boots up.

# Start MariaDB
sudo systemctl start mariadb

# Enable MariaDB to start on boot
sudo systemctl enable mariadb

Step 3: Setting the Root Password

By default, MariaDB installs without a root password. To set a new password, follow these specialized steps:

  1. Stop the service: sudo systemctl stop mariadb
  2. Start in safe mode: sudo mysqld_safe --skip-grant-tables &
  3. Log in without a password: mysql -u root
  4. Update the password:
    UPDATE mysql.user SET password=PASSWORD('your_new_password') WHERE User='root';
    FLUSH PRIVILEGES;
    exit;

Step 4: Verify the Installation

Restart the service normally and log in using your new password:

# Log in with password
mysql -u root -p

# Once logged in, show databases
SHOW DATABASES;

Conclusion

You have successfully installed MariaDB on your AWS EC2 instance! You now have a robust database ready to power your applications. Stay tuned for more tutorials on how to connect your Java applications to this database.

How to Generate WAR file and deploy Our Web Service App on Apache Tomcat on Amazon EC2 Linux Server?

🔥 Want to Master Java & Cloud? 🔥

Join the Ram N Java community for the best step-by-step tech tutorials!

SUBSCRIBE TO CHANNEL

Deploying Your Web App to AWS EC2

Deploying a web application can seem scary, but it’s actually a very logical process. In this guide, we will walk through how to take your Java Web Service, package it into a WAR file, and get it running on a professional server like Apache Tomcat hosted on Amazon EC2.

Step 1: Generating the WAR File

A WAR (Web Application Archive) file is like a package that contains everything your web app needs to run. Using your favorite IDE (like Eclipse or IntelliJ) or Maven, you generate this file so it can be "dropped" into a server.

Step 2: Setting Up Amazon EC2

Amazon EC2 provides a virtual computer in the cloud. For this setup, we use a Linux-based instance. You'll need to:

  • Launch an EC2 instance.
  • Configure Security Groups to allow traffic on Port 8080 (where Tomcat lives).
  • Connect to your instance via SSH.

Step 3: Installing Apache Tomcat

Apache Tomcat is the engine that actually "runs" your Java code. We install Tomcat on the EC2 instance, making sure Java is also installed. Once Tomcat is running, you can access its management page through your EC2 instance's IP address.

Step 4: Deployment and Verification

Finally, we upload our WAR file to the Tomcat webapps folder. Tomcat automatically detects it and starts the application. You can then test your Web Service using the public DNS of your AWS instance!

How to Update Server Software Packages and Install JDK or Java in AWS EC2 Instance?

🚀 Become a Cloud Expert!

Subscribe to Ram N Java for the best AWS and Java tutorials.

SUBSCRIBE NOW

Overview

Setting up a new Amazon EC2 instance often requires two immediate steps: ensuring all system software is up to date and installing the Java Development Kit (JDK). In this tutorial, we will use the YUM package manager to update our Linux environment and install Java 8.

Step 1: Connect to Your EC2 Instance

Before running commands, you must connect to your instance. Use your terminal or a tool like PuTTY with your public IPv4 address and your private key (.pem file).

Step 2: Update Software Packages

It is crucial to start with the latest security and software patches. Run the following command to update your system:

sudo yum update

If your system is already up to date, the terminal will let you know. If not, press 'y' when prompted to proceed with the updates.

Step 3: Check for Existing Java Installation

To see if Java is already installed, run:

java -version

If you see a message saying "command not found," you are ready to install a new version.

Step 4: Search and Install Java (JDK 8)

First, list the available Java packages in the repository:

yum list java*

Once you see java-1.8.0 in the list, install it using:

sudo yum install java-1.8.0

Step 5: Verify the Installation

After the process completes, verify that Java is correctly configured:

java -version

You should now see output similar to openjdk version "1.8.0_xxx".

Conclusion

Your EC2 instance is now updated and equipped with Java 8. This provides a solid foundation for running Java applications or setting up a web server. Happy coding!

How to Connect to an EC2 instance on AWS using WinSCP? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Master AWS & Java Today!

Subscribe to Ram N Java for more easy-to-follow cloud deployment tutorials.

SUBSCRIBE ON YOUTUBE

Introduction

WinSCP is a popular, free SFTP and FTP client for Windows. It provides a powerful graphical interface for transferring files between your local computer and a remote server, such as an Amazon EC2 instance. In this guide, we'll walk through installing WinSCP and configuring it to securely access your AWS instance.

Step 1: Download and Install WinSCP

Visit the official WinSCP website and download the installer. Follow the setup instructions. During installation, if you are asked to import sessions from PuTTY, you can choose "No" to start with a fresh configuration.

Step 2: Get Your EC2 Connection Details

Log in to your AWS Management Console and navigate to the EC2 Dashboard. Select your running instance to find the following information:

  • Public IPv4 Address: (or Public DNS name) to be used as the Host Name.
  • User Name: Typically ec2-user for Amazon Linux or ubuntu for Ubuntu instances.

Step 3: Configure Authentication (PPK File)

WinSCP uses the SSH protocol, which requires your private key for authentication. If you have a .pem file from AWS, WinSCP can automatically convert it to a .ppk file:

  1. Open WinSCP and click on Advanced.
  2. Under the SSH section, click on Authentication.
  3. Browse and select your .pem file. WinSCP will offer to convert it; click "OK" and save the new .ppk file.

Step 4: Login and Transfer Files

With the Host Name, User Name, and Key file configured, click Login. Once connected, you will see your local files on the left and your EC2 server files on the right. You can now drag and drop files to transfer them instantly!

Conclusion

You have successfully connected to your AWS EC2 instance using WinSCP. This setup is essential for deploying applications, managing server configurations, and handling logs. Keep practicing and explore the advanced features of WinSCP to speed up your workflow!

How to Connect to an EC2 instance on AWS via SSH? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Mastering the Cloud?

Join the Ram N Java community for high-quality AWS and Spring Boot tutorials!

SUBSCRIBE TO THE CHANNEL

Introduction

Connecting to an Amazon EC2 instance via SSH is a critical skill for any developer or DevOps engineer. Whether you're deploying a Spring Boot application or managing a server, SSH allows you to securely access your Linux machine from anywhere. In this guide, we'll walk through the entire process using an intermediate Linux machine and a .pem key file.

Step 1: Prepare Your Key File (.pem)

When you first launch an EC2 instance, AWS provides a .pem file (private key). You must have this file to authenticate your connection. If you are using a Linux machine to jump into another EC2 instance, follow these steps:

  • Open WinSCP or any file transfer tool.
  • Upload your .pem file to the Linux machine you are currently logged into.
  • Verify the file exists by running the ls command in your terminal.

Step 2: Secure Your Key File

SSH requires that your private key file is not publicly viewable. If the permissions are too open, the connection will be rejected. Run the following command to set the correct permissions:

chmod 400 your-key-file.pem

Step 3: Get Connection Details from AWS

To connect, you need the Public DNS or IP address of your instance:

  1. Go to the AWS EC2 Console.
  2. Select your running instance and click Connect.
  3. Under the SSH Client tab, copy the example command provided by AWS.

Step 4: Execute the SSH Command

Using the details from AWS, run the SSH command in your terminal. The structure looks like this:

ssh -i "your-key-file.pem" ec2-user@your-public-dns-name

Once you hit Enter, you'll be securely logged into your Amazon EC2 instance!

Conclusion

Congratulations! You've successfully connected to your AWS EC2 instance via SSH. This foundation allows you to install software, manage files, and deploy applications like Spring Boot with ease. Remember to keep your .pem files secure and never share them publicly!

How to Connect to an EC2 instance on AWS using PUTTY? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Master Cloud Deployment!

Want more AWS and Spring Boot tutorials? Subscribe to Ram N Java today!

SUBSCRIBE ON YOUTUBE

Introduction

Connecting to an Amazon EC2 instance from a Windows machine typically requires a tool called PuTTY. Since AWS provides private keys in .pem format and PuTTY uses .ppk, you'll also need the PuTTY Key Generator (PuTTYgen). In this guide, we'll walk through the entire conversion and connection process.

Step 1: Install PuTTY and PuTTYgen

Download the PuTTY installer for Windows from the official website. This installer usually includes both the PuTTY client and PuTTYgen. Complete the installation before proceeding to the next step.

Step 2: Convert .pem to .ppk using PuTTYgen

AWS gives you a .pem file, but PuTTY needs a .ppk file. Here is how to convert it:

  1. Open PuTTYgen.
  2. Click Load and select your .pem file (ensure "All Files" is selected in the file browser).
  3. Once loaded, click Save private key.
  4. Give it a name and save it as a .ppk file.

Step 3: Get Your EC2 Connection Details

Log in to your AWS Console and go to the EC2 Dashboard:

  • Ensure your instance is Running.
  • Copy the Public IPv4 address or Public IPv4 DNS.
  • Note the default username (usually ec2-user for Amazon Linux).

Step 4: Configure the PuTTY Connection

  1. Open PuTTY.
  2. In the Host Name field, paste your IP address or DNS.
  3. Go to Connection > Data and enter your username (e.g., ec2-user) in the "Auto-login username" field.
  4. Go to Connection > SSH > Auth, click Browse, and select your .ppk file.
  5. Go back to Session, give it a name (like "My-EC2"), and click Save.

Step 5: Connect and Verify

Click Open. If a security alert pops up, click "Yes." You should now be logged into your AWS EC2 terminal!

Pro Tip: Remember that stopping and starting your instance changes its Public IP address unless you are using an Elastic IP!

Conclusion

You have successfully configured PuTTY to access your AWS environment. This setup is the gateway to deploying applications, managing databases, and exploring the power of the cloud. Stay tuned for more tutorials on Spring Boot deployment!

How to Create EC2 Instance in AWS? | What is Amazon EC2? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Ready to Launch Your Apps?

Master the cloud with Ram N Java. Subscribe for more expert AWS and Spring Boot tutorials!

SUBSCRIBE ON YOUTUBE

Introduction

Deploying a Spring Boot RESTful service in the cloud is a game-changer. Unlike a local setup, an Amazon EC2 (Elastic Compute Cloud) instance provides a public IP address, allowing your APIs to be accessed from anywhere in the world. In this tutorial, we will walk through the process of launching your own Linux server on AWS.

Step 1: Sign Up and Access EC2

First, create an AWS account at aws.amazon.com. Once logged in, search for EC2 under the "Compute" services category. Before launching, ensure you select the Region (e.g., US East N. Virginia) that is closest to your target audience for the best performance.

Step 2: Choose an Amazon Machine Image (AMI)

An AMI is a template that contains your operating system and software. For beginners, it is highly recommended to select the Amazon Linux 2 AMI. Look for the "Free Tier Eligible" label to avoid unnecessary costs during your first year.

Step 3: Choose Instance Type and Configure

  • Instance Type: Select t2.micro (1 vCPU, 1 GB Memory) to stay within the Free Tier.
  • Configure Details: Enable Termination Protection to prevent your server from being deleted by mistake.
  • Add Storage: The default is 8 GB, but Free Tier users can increase this up to 30 GB.
  • Add Tags: Add a "Name" tag (e.g., Spring-Boot-Server) to easily identify your instance.

Step 4: Configure Security Groups

Security groups act as a firewall. To run a Spring Boot application, you need to open specific ports:

  • SSH (Port 22): For remote access.
  • HTTP (Port 80) & HTTPS (Port 443): For web traffic.
  • Custom TCP (Port 8080): The default port for Spring Boot/Tomcat.

Step 5: Create a Key Pair & Launch

Before launching, AWS will ask you to create a Key Pair. Download the .pem file and keep it secure—you will need this to connect to your server from your computer. Click Launch Instances and wait for the status to change to "Running."

Managing Your Instance

You can Stop your instance when you're not using it to save on credits, or Terminate it if you want to delete the server entirely. Once running, you'll see a Public IPv4 Address—this is your gateway to the world!

Conclusion

You have successfully launched a Linux server in the cloud! This is the first step toward hosting powerful Java applications on AWS. In our next guide, we will connect to this instance and deploy our code. Happy cloud computing!

Tutorials