Start for free First AWS ② Start Linux virtual machine

Introduction

Last time, I proceeded to create an AWS account.

This time, I will proceed with the tutorial "Start Linux Virtual Machine" that can be viewed from the following URL.

What is Lightsail

It is explained as follows on the AWS official website.

The easy-to-use cloud platform Lightsail offers everything you need to build applications and websites, plus a cost-effective monthly plan. Whether you're new to the cloud or want to access the cloud right away using your trusted AWS infrastructure, we can help.

image.png

I understand that it is a platform, but it seems that it is quick to actually use it to know the details.

Create an instance

When you sign in to your AWS account on the tutorial page, you'll be taken to the Lightsail home page. image.png

Select "Linux / Unix" in "Select Instance Image", click "OS Only" in "Select Blueprint", and then select "Amazon Linux 2". image.png

Select Instance Plan. It seems that you can try the "3.50 USD" Lightsail plan for free for one month. image.png

Enter a name for your instance. image.png

Click Create Instance. image.png

The Instances tab on the Lightsail home page opens, displaying the instances you created. Click on the top right of the displayed instance and select Connect. image.png

A browser-based terminal window will appear where you can enter Linux commands to manage your instances without configuring an SSH client. image.png

Application installation

nginx installation

Install nginx with the following command.

sudo amazon-linux-extras install nginx1

image.png

Start nginx with the service command.

sudo service nginx start

Once you have installed and started nginx, you will be able to access your web server. Open a browser and enter the EIP of the instance (example: http://xxx.xxx.xxx.xxx/) to open it. If the following page is displayed in your browser, the installation of the web server is complete.

image.png

MySQL installation

Refer to the following article and change the password after installing MySQL.

Connect to MySQL with the changed password.

mysql -u root -p

After that, you will be asked for a password, which you can enter to access MySQL.

Next, let's get a list of databases. Execute the following command.

show databases;

If the following message is displayed, MySQL installation and startup is complete.

image.png

Web application placement

Finally, install the application. Here, we'll use Rails to run a simple CRUD application that works with the MySQL we just built. To use Rails, you need an environment where you can build, so install the package used for build.

sudo yum -y groupinstall 'Development Tools'

You will also need the Ruby and MySQL libraries, so perform the installation.

sudo yum -y install ruby-devel mysql-devel

Rails requires Node.js as the JavaScript runtime. (1) Enter the following on the command line to install the node version manager (nvm).

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

You can install multiple versions of Node.js with nvm, and you can switch between them, so use nvm to install Node.js.

(2) Enable nvm by entering the following on the command line.

. ~/.nvm/nvm.sh

③ At the command line, type the following and use nvm to install the latest version of Node.js.

nvm install node

④ Enter the following on the command line to test that Node.js is installed and running correctly.

node -e "console.log('Running Node.js ' + process.version)"

image.png

Recommended Posts

Start for free First AWS ② Start Linux virtual machine
Start Django for the first time
First Steps for Machine Learning (AI) Beginners
Let's try Linux for the first time
Create a Linux virtual machine on Windows
[Linux] Review of commands for deploying on AWS
pyenv for linux
“Learn Linux in 5 Days” (Download Linux Ebooks Here! For Free)
For the first time, I learned about Unix (Linux).
Preparing to start "Python machine learning programming" (for macOS)