This topic describes how to create and manage a Linux instance in the Elastic Compute Service (ECS) console. In this topic, Apache is deployed on an instance that runs an Alibaba Cloud Linux 2.1903 LTS 64-bit operating system.
Create an account and complete the account information.
(Optional) Alibaba Cloud provides default virtual private clouds (VPCs). If you do not want to use the default VPC in the region where you want to create an ECS instance, create a VPC and a vSwitch.
For more information, see Create a VPC with an IPv4 CIDR block.
(Optional) Alibaba Cloud provides default security groups. If you do not want to use the default security group in the region where you want to create an ECS instance, create a security group.
For more information, see Create a security group.
Step 1: Create an ECS instance
Go to the Custom Launch tab of the instance buy page in the ECS console.
On the Custom Launch tab, configure parameters.
The following table describes the parameters that are used in this topic. For parameters that are not described in this topic, use the default values.
The pay-as-you-go billing method provides more flexibility in operations. For more information, see Billing overview.
Region: China (Hangzhou)
You cannot change the region or zone after the instance is created. Proceed with caution.
Family: General-purpose Type g6
Instance Type: ecs.g6.large
Instance types that are available are determined by the region that you select and the resource inventory in the region.
You can go to the ECS Instance Types Available for Each Region page to view the instance types available in each region.
Type: Public Image
Version: Alibaba Cloud Linux 2.1903 LTS 64-bit
After the instance is started, the operating system and application data of the image are copied to the system disk.
Select an existing VPC. VPCs whose name contain the [Default] prefix are automatically created in the ECS console.
Public IP Address
Select Assign Public IPv4 Address
If you select Assign Public IPv4 Address, the system assigns a public IPv4 address to the instance.
If you select Pay-By-Traffic, you are charged based on the amount of traffic that is transmitted over the Internet. For more information, see Public bandwidth.
Select an existing security group. Security groups whose names contain the [Default] prefix are automatically created in the ECS console.
System Configurations (Optional)
In this topic, Password is selected. In this case, you must configure a password to use to connect to and log on to the instance.
If you set Logon Credentials to Password, you must configure the Logon Password and Confirm Password parameters. When you connect to the instance, you must use the
ecs-userusername and the password that you specify in this section.
In this topic, EcsQuickStart is used as the instance name.
If you create multiple instances, we recommend that you add tags to facilitate management.
Click Next. In the Preview step, confirm the configurations in the Configurations Selected section or click the icon to modify the configurations.
(Optional) Click Save as Launch Template. In the Save as Launch Template dialog box, enter a name and description for the launch template.Note
Save the instance configurations that you made as a launch template. Then, you can create instances by using the template without the need to make the configurations again.
Read and select ECS Terms of Service and Product Terms of Service. Then, click the Create Instance or Create Order.
In the Created message, click Console to go to the Instances page and view the instance creation progress.
If the instance is in the Running state, the instance is created. Copy the public IP address of the instance for use to connect to the instance.
Step 2: Add security group rules
If you did not add rules to the default security group or if you added the instance to a new security group when you create the instance, perform the following steps:
Click the instance ID to go to the Instance Details page.
On the Instance Details page, click the Security Groups tab. Click the ID of a security group to go to the Security Group Details page.
In the Access Rule section, click the Inbound tab.
Click Quick Add to add security group rules as described in the following table. For parameters that are not described in this topic, use the default values.
In the Port Range section, select the ports that must be open for the applications that run on the ECS instance. For example, if you want to use SSH and Apache in Step 4: Deploy Apache, select SSH (22) and HTTP (80). Otherwise, the instance does not respond in subsequent operations.
0.0.0.0/0 indicates all CIDR blocks. If you know the IP address of the requester, we recommend that you set Authorization Object to a specific IP address range that contains the IP address.
Step 3: Connect to the ECS instance
Go back to the Instances page and find the instance to which you want to connect. In this topic, the EcsQuickStart instance is used. In the Actions column, click Remote.
In the Remote connection dialog box, click Sign in now in the Workbench section.
In the Instance Login dialog box, configure parameters and click OK.
Username: Enter your username, such as root or ecs-user.
Password: Enter the value of the Logon Password parameter that you configured in the Logon Credentials section when you created the instance.
Step 4: Deploy Apache
yum install -y httpd
systemctl start httpd
Configure Apache to run on system startup.
systemctl enable httpd
Check whether Apache is running.
systemctl status httpd
If Apache is running,
active (running)is displayed in the command output.
http://<Public IP address of the instance>in the address bar of a browser and press the Enter key.
Step 5: (Optional) Resolve a domain name
Direct access to Apache by using the public IP address of the instance may compromise server security. If you already have a domain name or if you want to register a domain name for the Apache website, perform the following steps:
Register a domain name.
For more information, see Register a domain name on Alibaba Cloud.
Apply for an Internet Content Provider (ICP) filing for the domain name.
If the website to which the domain name points is hosted on an ECS instance in a region inside the Chinese mainland, you must apply for an ICP filing for the domain name.
Resolve the domain name to point to the public IP address of the instance.
Domain name resolution is a prerequisite for using domain names to access your website. For more information, see Get started with Alibaba Cloud DNS.
Use the resolved domain name to access Apache. Example: example.com.
Step 6: (Optional) Release the ECS instance
You can release the instance if you no longer need it. After the instance is released, billing for the instance stops, and data of the instance is lost and cannot be restored.
The operations in this section apply only to pay-as-you-go instances.
Go back to the Instances page and find the EcsQuickStart instance.
In the Actions column, choose .
Set Release Mode to Release Now and click Next.
In the Release message, verify the instance information and click OK.
Step 7: View bills
In the top navigation bar of the ECS console, choose .
In the left-side navigation pane, choose . Then, click the Billing Details tab.
Set Instance Name to EcsQuickStart and click Search.
What to do next
For more information about ECS instance families that are available for purchase, see Overview of instance families.
For more information about how to create an ECS instance, see Creation methods.
For information about images, see Image overview.
For information about security groups, see Overview.
For information about VPCs, see What is a VPC?
For information about the common operations of ECS, see Quick reference.
For information about the API operations that are provided by ECS, see List of operations by function.