For New Users|How to Set Up Your First CentOS 6 & CentOS 7 Server on Alibaba Cloud

How to Set Up Your First CentOS 6 Server on Alibaba Cloud



Alibaba Cloud Elastic Compute Service (ECS) provides a faster and more powerful way to run your cloud applications as compared with traditional physical servers. You can achieve great results on your cloud needs. With ECS, you can achieve more with the latest generation of CPUs as well as protect your instance from DDoS and Trojan attacks.

In this guide, we will talk about the best practices for provisioning your CentOS 6 server hosted on an Alibaba Cloud Elastic Compute Service (ECS) instance.

Prerequisites
A valid Alibaba Cloud account. If you don't have one already, sign up to the Free Trial to enjoy up to $300 worth in Alibaba Cloud products.
An ECS instance running CentOS 6. You can select your preferred region and configurations; this will not affect the outcome of the server setup.
A root password for your server.
Step 1: Connect to your Alibaba Cloud CentOS 6 Server
Locate the Internet IP address (Public IP address) associated with your Alibaba Cloud ECS Instance.

If you are running Linux or Mac, use a terminal application to connect to the instance via SSH. If you are on Windows, you can use PuTTy (download here) to connect to your server. You will have to provide the IP address, username and password that you set up when creating your Alibaba Cloud ECS instance to log in via SSH.

There are other ways to connect to your ECS instance as well. Visit the official ECS documentation to learn more.

Step 2: Change the Hostname on Your CentOS 6 Server
The hostname is a default identifier when you communicate to a Linux server. It is like a computer name that is associated with your home PC or laptop. Naming your CentOS 6 server with a descriptive hostname helps you to differentiate your machines especially if you are running a bunch of them.

To begin, ensure your CentOS 6 system is up-to-date by typing the command below:

$ sudo yum update
To check your hostname, type the command below on a terminal window:

$ hostname
To change your hostname, we need to install nano text editor using the command below:

$ sudo yum install nano
Then, edit the /etc/cloud/cloud.cfg file and find the entry preserve_hostname. Change its value from false to true.

$ sudo nano /etc/cloud/cloud.cfg
preserve_hostname true
Press CTRL + X, Y then Enter to exit and save the changes.

Then, edit the /etc/sysconfig/network file using a nano editor by typing the command below:

$ sudo nano /etc/sysconfig/network
Find the HOSTNAME entry and overwrite its value with your preferred hostname. For instance, if your hostname is miami, the value should be entered as follows:

HOSTNAME=miami
Press CTRL + X, Y then Enter to save the changes.

You will also need to add some entries on the Linux hosts file. Open the file using a text editor:

$ sudo nano /etc/hosts
You will need to add two entries on this file just below the 127.0.0.1 localhost entry. The first entry you are adding uses the loopback interface address 127.0.1.1. Please note that this is different from the address 127.0.0.1 which have a 'localhost' value in the same file.

So assuming your server's public IP address is 111.111.111.111 and your hostname is miami, your /etc/hosts file should have the below entries at the very top:

127.0.0.1 localhost
127.0.1.1 miami
111.111.111.111 miami
Reboot your Alibaba Cloud ECS instance for the changes to take effect by typing the command below:

$ sudo reboot
Step 3: Configure Time Zone on Your CentOS 6 Server
You can check the default date and time zone on your Alibaba CentOS 6 server by typing the command below:

$ ls -l /etc/localtime
You will get an output like the one shown below:

4

You must set the correct time zone especially if you are running cron jobs on your CentOS 6 server because they rely heavily on date/time. To change the time zone, use the commands below:

$ sudo rm /etc/localtime
$ sudo ln -s /usr/share/zoneinfo/ /etc/localtime
In the above command, we are deleting the old symbolic link (address of the old time zone file name) using 'rm' command and creating another one (using 'ln' command ) depending on our new time zone.

CentOS 6 maintains all time zone files under the /usr/share/zoneinfo directory and we need to create symbolic link to the right file that contains our preferred time zone.

For instance, to set your CentOS 6 server time zone to London, use the commands below:

$ sudo rm /etc/localtime
$ sudo ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
You can run the date command to check if the changes were effected successfully:

$ date


Please check this blog for more operation.


How to Set Up Your First CentOS 7 Server on Alibaba Cloud



Alibaba Cloud Elastic Compute Service (ECS) provides a faster and more powerful way to run your cloud applications as compared with traditional physical servers. You can achieve great results on your cloud needs. With ECS, you can achieve more with the latest generation of CPUs as well as protect your instance from DDoS and Trojan attacks.

In this guide, we will talk about the best practices for provisioning your CentOS 7 server hosted on an Alibaba Cloud Elastic Compute Service (ECS) instance.

Prerequisites
A valid Alibaba Cloud account. If you don't have one already, sign up to the Free Trial to enjoy up to $300 worth in Alibaba Cloud products.
An ECS instance running CentOS 7. You can select your preferred region and configurations; this will not affect the outcome of the server setup.
A root password for your server.
Step 1: Connect to your Alibaba Cloud CentOS 7 Server
Locate the Internet IP address (Public IP address) associated with your Alibaba Cloud ECS Instance.

If you are running Linux or Mac, use a terminal application to connect to the instance via SSH. If you are on Windows, you can use PuTTy (download here) to connect to your server. You will have to provide the IP address, username and password that you set up when creating your Alibaba Cloud ECS instance to log in via SSH.

There are other ways to connect to your ECS instance as well. Visit the official ECS documentation to learn more.

Step 2: Change the Hostname on Your CentOS 7 Server
The hostname is a default identifier when you communicate to a Linux server. It is like a computer name that is associated with your home PC or laptop. Naming your CentOS 7 server with a descriptive hostname helps you to differentiate your machines especially if you are running a bunch of them.

To begin, ensure your CentOS 7 system is up-to-date by typing the command below:

$ sudo yum update
To check your hostname, type the command below on a terminal window:

$ hostname
To change your hostname, we need to install nano text editor using the command below:

$ sudo yum install nano
Then, edit the /etc/cloud/cloud.cfg file and find the entry preserve_hostname. Change its value from false to true.

$ sudo nano /etc/cloud/cloud.cfg
preserve_hostname true
Press CTRL + X, Y then Enter to exit and save the changes.

Then, edit the /etc/hostname file using a nano editor by typing the command below:

$ sudo nano /etc/hostname
Overwrite the current hostname written at the very top of the file and press CTRL + X, Y then Enter to save the changes.

You will also need to add some entries on the Linux hosts file. Open the file using a text editor:

$ sudo nano /etc/hosts
You will need to add two entries on this file just below the 127.0.0.1 localhost entry. The first entry you are adding uses the loopback interface address 127.0.1.1. Please note that this is different from the address 127.0.0.1 which have a 'localhost' value in the same file.

So assuming your server's public IP address is 111.111.111.111 and your hostname is miami, your /etc/hosts file should have the below entries at the very top:

127.0.0.1 localhost
127.0.1.1 miami
111.111.111.111 miami
Reboot your Alibaba Cloud ECS instance for the changes to take effect by typing the command below:

$ sudo reboot
Step 3: Configure Time Zone on Your CentOS 7 Server
You can check the default date and time zone on your Alibaba Cloud CentOS 7 server by typing the command below:

$ timedatectl
You must set the correct time zone especially if you are running cron jobs on your CentOS 7 server because they rely heavily on date/time. To change the time zone, use the command below:

$ sudo timedatectl set-timezone
For instance, to set your server time zone to London, use the command below:

$ sudo timedatectl set-timezone Europe/London
You can run the date command to check if the changes are successful:

$ date

Please check this blog for more operation.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00