AWS - Article 01 (Introduction to AWS and AWS EC2 instances and simple and practical)
1 Introduction
- What is AWS?
Okay, I'll just take this many screenshots, and search for more by yourself...
2. Create an AWS account
- The official website address is as follows:
https://aws.amazon.com/cn/ .
- When registering, if you have a Google mailbox, it is best to use Google mailbox, as follows:
- After successfully registering according to the prompts, you can log in to use it.
- Just click around and seem to see something.
Continue...
3. EC2
3.1 Start a new EC2 instance
3.1.1 Entrance
- as follows:
3.1.2 Set Name + Select Service
-
as follows:
3.1.3 Create key pair
- as follows:
- Click Create Key Pair to download it directly to your computer, and select the newly created key pair by default.
3.1.4 Network Settings - Security Group
3.1.4.1 Initial setup
- as follows:
3.1.4.2 Add security group rules (open new ports)
- [Edit Inbound Rules]–>[Add Rule]–>[Save Rule], as follows:
3.1.5 Configuration storage
3.1.6 Start an instance
- as follows:
3.1.7 View instances
-
as follows:
3.2 Connect to EC2 instance
3.2.1 Method 1——Instance Connect
- as follows:
3.2.2 Method 2 - SSH client
- Just follow the prompts, as follows:
- Mac computers should be able to connect using the terminal that comes with them, but there is no response after I command here. It seems that I can’t connect to the Internet. I have always had this problem when using ClashX locally, and it doesn’t work if I exit. But at least I can connect to the Internet without exiting ClashX. , what’s going on with this terminal, I don’t know why, forget it, let’s talk about this later.
- Therefore, instead of
SecureCRT
connecting, copy the key to another remote server, execute the installation steps, and you can connect, as follows:# 连接命令 ssh -i "自己的密钥文件" ec2-user@公有IPv4DNS # ec2-user 默认用户
3.3 Simple and practical
3.3.1 Simple commands
- To view the version, use the following command to view the version of Amazon Linux
cat /etc/system-release
- Switch to root user
sudo -s 或 sudo su
- Update software
yum update -y
3.3.2 Install application
3.3.2.1 Install git
- Install git as follows:
yum install git -y git --version
3.3.2.2 Install jdk
- Simply use the command to install it, as follows:
yum install java-17-amazon-corretto-devel.x86_64
3.3.2.3 Install tomcat
- Download tomcat as follows:
- Go to the official website first:
Official website address: https://tomcat.apache.org/download-10.cgi . - Copy download link
https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
- Then, download with the command
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
- Go to the official website first:
- Unzip and install tomcat as follows:
tar -zxvf apache-tomcat-10.1.11.tar.gz
- Start as follows:
./startup.sh
- Check operation status
ps -ef | grep java lsof -i:8080 netstat -na | grep 8080
- Browser access
- Before accessing, remember to open the port. For details, refer to: "3.1.4.2 Add security group rules (open new ports)》
http://公网IP:8080 或者 http://公有 IPv4 DNS:8080
3. Some configuration files
- Configure user information, etc.
cat /etc/cloud/cloud.cfg
4. About AMI
-
When viewing instance information, you can see the AMI, as follows
-
So try to launch the instance from the AMI as follows:
5. Attention
5.1 About amazon-linux-extras
- What is amazon-linux-extras?
- Amazon Linux Extras is a component of the Amazon Linux 2 distribution that allows users to install and manage additional software packages and services. Amazon Linux Extras allow users to easily obtain and install a variety of software packages that may not be included in the standard Amazon Linux 2 repositories.
- Namely: Amazon Linux Extras provide an easy way to extend the functionality of Amazon Linux 2.
- Depending on the version you are using, check whether this command is available, as follows
- Check the Amazon Linux version as follows:
cat /etc/system-release
- Check the Amazon Linux version as follows:
- View installable software
amazon-linux-extras -v
- Use
amazon-linux-extras
the command to installnginx
, as follows:- Install
sudo su amazon-linux-extras install -y nginx1 nginx -version
- Start nginx
systemctl start nginx
- Open port 80 and access nginx
- Install