(2) Purchase an EC2 server on AWS, install Docker and docker-compose
根据前面两章,当把前后端的资源包都准备好后就需要去AWS购买EC2服务器了.
一、Access AWS EC2
1、Open the AWS official website and log in to AWS. Then enter EC2
in the search bar and click on EC2
.
2、After entering EC2
, click on Launch instance
3、Select server
3.1、Enter your server name
3.2、Choosing the Server Type
Here, we are using the free server, but the free server has less memory, smaller disk space, and during peak usage periods, Amazon may reclaim resources, forcing your service to be terminated.
(Friends with conditions can choose paid servers, which will provide a much better deployment experience later on.)
3.3、Selecting the Key Pair for Logging into the Server
If you have created a key pair before, you can directly select one. If not, you need to create a new one.
create key pair, remember this key pair and download this key pair file name ec2-test.pem
to your local computer after create. You will need it later when you use ssh to log in to the EC2 server.
**3.4、 Selecting the Security Group **
If you don’t have a security group yet, you need to create a new one.
The security group is used to define the open ports and network access for your server.
Therefore, you must set your security group according to the port number on which your project is deployed.
3.5、create security group
If you have no security group, you should create one.
If your service is deployed on port 3000, you should open port 3000, but your security group does not have port 3000 open, then the external network will not be able to access your service.
After completing the above basic information, you can click Launch instance
to create the server.
**3.6、Accessing the EC2 Instance **
3.7、view instance
Click on an instance ID to view details
**3.8、Connecting to Your Server via SSH **
Click on Connect
in the top-right corner, and follow the steps shown in the image below to log into your server via SSH.
Note: You need to download your ec2-test.pem
key file to a folder beforehand, then open a new terminal in that folder, and then execute the commands in the following steps.
The next article will introduce how to connect to the server using an SSH client, as well as how to install Docker on the server, and how to deploy your entire web application using docker-compose.
Thanks.