I accidentally terminate the EC2 instance for study instead of stopping it, and sometimes I recreate it, so I will keep a memorandum about what to do when launching the instance.
sudo yum update -y
In the case of an instance with a small memory such as t2micro, it will be dropped by a process that uses a lot of memory like Angular's prod build, so increase the swap memory to avoid it.
#Create a 4GB swap file (it will fail if there are a lot of bs because the memory is low)
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
#Grant read / write permission to swap file
sudo chmod 600 /swapfile
#Swap space setup
sudo mkswap /swapfile
#Enable swap space
sudo swapon /swapfile
#Check swap space
sudo swapon -s
Reference: https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-memory-swap-file/
When swapon, you can confirm that the file is created with the specified size as shown below
$ sudo swapon -s
Filename Type Size Used Priority
/swapfile file 4194300 0 -2
If you execute the free command, you can confirm that it is recognized as memory.
$ free
total used free shared buff/cache available
Mem: 1006940 82724 63424 404 860792 771392
Swap: 4194300 0 4194300
Edit / etc / fstab with vi
sudo vi /etc/fstab
Add the following line to the end and save
/swapfile swap swap defaults 0 0
sudo yum install git-all -y
Reference: https://git-scm.com/book/ja/v2/%E4%BD%BF%E3%81%84%E5%A7%8B%E3%82%81%E3%82%8B-Git % E3% 81% AE% E3% 82% A4% E3% 83% B3% E3% 82% B9% E3% 83% 88% E3% 83% BC% E3% 83% AB
git config --global user.name "username"
git config --global user.email [email protected]
Reference: https://git-scm.com/book/ja/v2/%E4%BD%BF%E3%81%84%E5%A7%8B%E3%82%81%E3%82%8B-% E6% 9C% 80% E5% 88% 9D% E3% 81% AEGit% E3% 81% AE% E6% A7% 8B% E6% 88% 90
#docker installation
sudo yum install docker -y
#docker service started
sudo service docker start
#Settings that allow docker commands to be used without sudo
sudo usermod -a -G docker ec2-user
#Set docker service to start automatically
sudo systemctl enable docker
Reference: https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/docker-basics.html http://docs.docker.jp/v1.11/engine/admin/systemd.html
#Binary download
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#Grant execute permission
sudo chmod +x /usr/local/bin/docker-compose
Reference: https://docs.docker.com/compose/install/
If this is left as it is, Permission Error: [Errno 13] Permission denied
will occur, so exit from EC2 and reconnect.
#Download installer&Run
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
# nvm.sh run
. ~/.nvm/nvm.sh
# Node.js installation
nvm install node
Reference: https://docs.aws.amazon.com/ja_jp/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Recommended Posts