[RUBY] Try deploying a Rails app on EC2-Part 1-

Assumptions about this article

Registered as a user on AWS Rails has already created some kind of application

Launch an instance

This time, I will select Amazon Linux 2 for free.

スクリーンショット 2020-11-09 13.26.42.png The instance type also adopts a free frame スクリーンショット 2020-11-09 13.26.56.png Finally, create a key pair. The key pair name can be decided arbitrarily. After deciding on a name, don't forget to "download the key pair". If you can, click "Create Instance" to "launch". スクリーンショット 2020-11-09 13.27.33.png Go to the launched instance and copy the instance ID in a memo. スクリーンショット 2020-11-09 13.40.27.png

Elastic IP creation & linking with instance

By associating an Elastic IP with an instance, you can access it regardless of whether the instance is started or stopped.

Click "Assign Elastic IP Address" as shown in the image. スクリーンショット 2020-11-09 13.49.15.png Make sure "IPv4 Address Pool" is selected and click Assign スクリーンショット 2020-11-09 13.49.22.png After creating the Elastic IP, we will link it with the instance. Click "Associate" in "Action" of Elastic IP. スクリーンショット 2020-11-09 13.50.21.png Paste the instance ID you copied and pasted into the "instance" item enclosed in red.

Instance security settings

Click the "Security Group" link for your instance to set up inbound rules. Security groups allow you to configure network settings for your instances all at once. Let's edit as follows. "" and ":: / 0" mean "allow all access". スクリーンショット 2020-11-09 14.05.17.png

For the time being, the settings on the web are now ready.

Log in to your EC2 instance

Now that the instance settings are complete, let's actually log in to the instance from the terminal.

% cd
% mkdir ~/.ssh
% mv Downloads/The name of the downloaded key.pem .ssh/
#Move the key you downloaded earlier to ssh.
% cd .ssh/
% ssh -i Downloaded key name.pem ec2-user@Elastic IP associated with the instance

If you execute the following command, you will be asked to select yes or no, so let's say yes.

% ssh -i Downloaded key name.pem ec2-user@Elastic IP associated with the instance

If the login is successful and the message "Amazon Linux 2 AMI" is returned, it is successful. And let's install software such as Ruby, yarn and node in the instance. After that, let's install the repository you want to deploy with git clone etc. This completes the preparation for the time being.

In the next sequel, we will start the database on the EC2 instance. After the second part is over, we will move on to the deployment part, so we plan to have three parts in total.

Recommended Posts

Try deploying a Rails app on EC2-Part 1-
Try deploying Rails app to EC2-Part 2 (Deploy)-
Try deploying Rails application to EC2-Part 2 (Server construction)-
[Introduction] Try to create a Ruby on Rails application
Post a video on rails
[Ruby on Rails] Read try (: [],: key)
Create a new app in Rails
Try to create a server-client app
Deploy your Rails app on Heroku
[Rails6] Create a new app with Rails [Beginner]
[Rails] Use validation on a specific controller
Try Health Check on Azure App Service.
Try building a GPU container on GCP.
Try making a calculator app in Java
Deploy a Java web app on Heroku
I made a calculator app on Android
[Rails 5] Create a new app with Rails [Beginner]
[Portfolio] Bookmark management app [Ruby on Rails]
Try App Clips
Tailwind on Rails
Publish the app made with ruby on rails
After deploying a Rails app on EC2, I can access it with a public IP address but not with a public DNS
Build a streaming server on your iOS app
Introducing Rspec, a Ruby on Rails test framework
[Ruby on Rails] A memorandum of layout templates
[Ruby on Rails] Try to create a service that makes local cats happy
(Ruby on Rails6) Creating data in a table
Recipe for deploying Rails apps on AWS EC2
I made a portfolio with Ruby On Rails
A story comparing front frameworks on existing Rails applications
Build a Ruby on Rails development environment on AWS Cloud9
Try running an app made with Quarkus on Heroku
Error encountered with notes when deploying docker on rails
A high bill from AWS during development on rails ...
How to get started with creating a Rails app
Try using the query attribute of Ruby on Rails
Try DisplayLink on Ubuntu 20.04
Launch Rails on EC2
Try OpenLiteSpeed on CentOS8
Test run on rails
Heroku app moving (rails)
Deploy RAILS on EC2
Ruby on Rails Elementary
Ruby on Rails basics
Yay! I'm on Rails!
Try actions on GitHub [actions]
Ruby On Rails Association
Try sending a notification.
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
Launch Nuxt.js + Rails API on Docker and try CRUD operation
[Rails] I tried to create a mini app with FullCalendar
How to deploy a simple Java Servlet app on Heroku
[Ruby on Rails] Add a column with a foreign key constraint
A note about the seed function of Ruby on Rails
Try launching a webAP server on the micro using Helidon
How to deploy a kotlin (java) app on AWS fargate
How to display a graph in Ruby on Rails (LazyHighChart)
Confirm public key ~ Register key on Github ~ Push Rails app to Github
Explanation of Ruby on rails for beginners ③ ~ Creating a database ~
Try Hello World using plain Java on a Docker container
Apply CSS to a specific View in Ruby on Rails