How to publish an application using AWS (3) EC2 instance environment construction

Introduction

I will describe the procedure to publish the application using AWS. In this article, we will build an environment for EC2 instances.

Installation of necessary tools

Install various tools to build the environment of EC2 instance.

Change to the ".ssh" directory

Execute the following command to move to the ".ssh" directory.

cd ~/.ssh/

ssh connection

Execute the following command to access the EC2 instance with ssh. (When the downloaded pem file name is "xxx.pem" and the Elastic IP is 12.345.67.890)

ssh -i xxx.pem [email protected]

Run the yum command to update the package

Run the following command to update the package.

sudo yum -y update

What is a package?

--A package is a collection of various programs and files required for the operation of the Linux OS. --Consists of a binary program and documents such as libraries, configuration files, and procedure manuals required to operate the program.

What is the yum command?

--In Linux distributions such as CentOS, a package management system called RPM (Red Hat Package Manager) is basically used. RPM packages can be easily installed, updated or uninstalled with the "rpm" command. ――YUM (Yellowdog Updater Modified) makes it possible to use RPM more conveniently by checking dependencies such as "This software is required to use certain software" and automatically installing the necessary software. YUM package operations are performed with the yum command. --There are various commands and options that can be used with the yum command, and the "yum -y update" performed above is a command that responds to all inquiries with "yes" and updates the system package.

Execute the yum command to install various packages

Execute the following command to install various other packages required for environment construction.

sudo yum -y install git make gcc-c++ patch libyaml-devel libffi-devel
sudo yum -y install libicu-devel zlib-devel readline-devel libxml2-devel
sudo yum -y install libxslt-devel ImageMagick ImageMagick-devel
sudo yum -y install openssl-devel libcurl libcurl-devel curl

Install Node.js

Node.js is for running Javascript on the server side. I would like to summarize the details in another article. Install to compress css and images in future work.

Execute the following command to install Node.js.

sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum -y install nodejs

What is the curl command?

A command that exchanges data with the server. The frequently used options are as follows. I would like to summarize this in detail later.

-L --If there is a redirect, get the redirect destination information
-s --Do not output extra
-o --Specify the output destination of the response body

What is a bash command?

Bash is a type of shell that conveys user input to a computer. Here, bash is running.

Install rbenv and ruby-build

The following is done when implementing the server side using Ruby.

Execute the following command to clone rbenv from git.

#Install rbenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv 

Execute the following command to pass the path. Passing the path means making the application callable from any directory.

#Pass through
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile 

#Description for calling rbenv
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Execute the following command to read the set path.

#.bash_Load profile
source .bash_profile

Execute the following command to clone ruby-build from git.

#ruby-install build
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Execute the following command to rehash. In other words, commands that can be used by installing ruby and gem (irb, gem, rake, rails, ruby, etc.) are sorted by version so that they can be used.

#Do rehash
rbenv rehash 

Install Ruby

This time install version 2.5.1.

Execute the following command to install the 2.5.1 version of Ruby.

rbenv install 2.5.1

Execute the following command to determine the version of Ruby to use in the EC2 instance.

rbenv global 2.5.1

Execute the following command to perform side rehash.

#Do rehash
rbenv rehash

Finally, check if the installation is done properly with the following command.

#Check version
ruby -v

reference

What is the yum command What is a package Node.js official Node.js explanation curl command

Related article

Procedure to publish application using AWS (1) Create AWS account Procedure to publish application using AWS (2) Create EC2 instance [Procedure to publish application using AWS (4) Create database] (https://qiita.com/osawa4017/items/7dba25f4fa30ab0b1246) [Procedure to publish application using AWS (5) Publish application] (https://qiita.com/osawa4017/items/6f3125fcc21f73024311) [Procedure to publish application using AWS (6) Install Nginx] (https://qiita.com/osawa4017/items/9b707baf6ddde623068c)

Recommended Posts

How to publish an application using AWS (3) EC2 instance environment construction
How to install Ruby on an EC2 instance on AWS
[Rails] AWS EC2 instance environment construction
How to publish an application on Heroku
How to create a web server on an EC2 instance on AWS
How to create an application
How to handle an instance
[For beginners] Laravel Docker AWS (EC2) How to easily deploy Web application (PHP) from 0 (free) ②-Docker development environment construction-
Deploy SpringBoot application to AWS EC2
[Note] Update to production environment (AWS EC2)
How to build an environment for any version of Ruby using rbenv
How to migrate a web application created in a local docker environment to AWS
Deploy a Node.js application to an ECS instance using the Cloud Toolkit
How to link Rails6 Vue (from environment construction)
Build a Laravel environment on an AWS instance
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to build an environment with Docker
Memo to build a Servlet environment on AWS EC2
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
How to make an oleore generator using swagger codegen
Procedure for publishing an application using AWS (6) Introduce Nginx
I tried to build an environment using Docker (beginner)
How to set environment variables when using Payjp with Rails
[AWS] Link memory usage of Ubuntu EC2 instance to CloudWatch
Procedure for publishing an application using AWS (4) Creating a database
What happened in "Java 8 to Java 11" and how to build an environment
How to set and describe environment variables using Rails zsh
[2020 version] How to send an email using Android Studio Javamail
How to make an app using Tensorflow with Android Studio
How to monitor application information in real time using JConsole
How to deploy a Rails application on AWS (article summary)
Introduction to Metabase ~ Environment Construction ~
How to authorize using graphql-ruby
How to make an application with ruby on rails (assuming that the environment has been built)
How to build an environment with Docker, which is the minimum required to start a Rails application
After learning Progate, I tried to make an SNS application using Rails in the local environment
Access S3 buckets using SSE-KMS encryption in an EC2 IAM Role environment (AWS SDK for Java)
How to install and use Composer on an ECS instance on Ubuntu 16.04
Ruby on Rails --From environment construction to simple application development on WSL2
[Rails] How to upload images to AWS S3 using Carrierwave and fog-aws
How to build an Apache Flink application from scratch in 5 minutes
[Rails] How to upload images to AWS S3 using refile and refile-s3
AWS Cloud9 environment construction Update Ruby to the latest stable version
[For beginners] Laravel Docker AWS (EC2) How to easily deploy a web application (PHP) from 0 (free) ①-Overview-
Environment construction for Servlet application development
[AWS SDK] EC2 automatic construction script
How to build CloudStack using Docker
How to deploy to AWS using NUXTJS official S3 and CloudFront? With docker-compose
How to build a Ruby on Rails environment using Docker (for Docker beginners)
How to solve the local environment construction of Ruby on Rails (MAC)!
[Swift] How to set an image in the background without using UIImageView.
How to apply Rails environment variables to Docker container (aws :: Sigv4 :: Errors solution)
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]