Creating an Nginx Server Using the CentOS Image
Nginx is a lightweight web server, reverse proxy server, and email (IMAP/POP3) proxy server. FlexusL provides mainstream Linux OS images for you to create a pure, secure, and stable runtime environment. This section uses the CentOS image as an example to describe how to create an Nginx server from an OS image.
Process Flow
Procedure |
Description |
---|---|
Sign up for a HUAWEI ID, enable Huawei Cloud services, and top up your account. |
|
Purchase a FlexusL instance using the CentOS image. |
|
Set the login password and log in to the server. |
|
Install Nginx and configure it to automatically start upon system startup. |
|
If you want your users to access the website through a domain name, add and resolve a domain name for the server. If the website is only used for personal development or testing, there is no need to add a domain name and you can skip this step. |
|
(Optional) Step 5: Apply for and Install an SSL Certificate for Your Instance |
Install an SSL certificate if you need to enable HTTPS on your server. |
Preparations
- Before purchasing a FlexusL instance, sign up for a HUAWEI ID and enable Huawei Cloud services. For details, see Signing Up a HUAWEI ID and Enabling Huawei Cloud Services and Completing Real-Name Authentication.
If you have enabled Huawei Cloud services and completed real-name authentication, skip this step.
- Ensure that your account has sufficient balance. If not, top up your account.
Step 1: Purchase a FlexusL Instance
- On the Flexus L Instance page, click Buy FlexusL and specify parameters required for purchasing a FlexusL instance.
For details, see Purchasing a FlexusL Instance.
Parameter
Example
Description
Region
CN-Hong Kong
For low network latency and quick resource access, select the region nearest to your target users. After a FlexusL instance is created, the region cannot be changed. Exercise caution when selecting a region.
NOTE:By default, all FlexusL instances created by the same account in the same region are located in the same VPC. They can communicate with each other over a private network. FlexusL instances that are created by different accounts or located in different regions cannot communicate with each other over a private network.
Image
CentOS 7.9
OS image: only includes the necessary OSs to launch servers, without any application data or environment configurations. After a server is created from an OS image, the server runs on an OS without any applications installed. You can install applications based on your service requirements.
For details, see Images Supported by FlexusL Instances.
Instance Specifications
2 vCPUs | 2 GiB memory and 60 GiB system disk
Select instance specifications based on your service requirements. Outbound traffic exceeding the traffic package is billed.
For details, see Billing.
(Optional) Instance Name
Nginx
You can customize your instance name.
If this parameter is left blank, the instance name is in the default format: image name-region-random number. In a batch creation, a hyphen followed by an incremental number is added to the end of each instance name by default.
(Optional) Associated Services
- Data disk: 10 GiB
- Host security
- Cloud backup vault: 70 GiB
You can associate other services (EVS, HSS, and CBR) with your FlexusL instance as needed.
Required Duration
- 1 month
- Auto-renew
The minimum duration of a purchase is one month and the maximum duration is three years.
Auto-renew is enabled by default, which means the purchased FlexusL instances will be automatically renewed before they expire. If you do not enable auto-renew during the purchase process, you can still enable it later after the instances are created. Monthly subscription allows you to renew the subscription for one month every time. The number of renewal times is not limited.
For more information about auto-renewal rules, see Auto-Renewal Rules.
Quantity
1
Set the number of FlexusL instances to be purchased. One instance is created by default. A maximum of five instances can be created in the same region.
To increase the quota, submit a service ticket.
- Click Buy Now.
On the displayed page, confirm the order details, read and select the agreement, and click Submit.
- Select a payment method and complete the payment.
- Go back to the FlexusL console and view the purchased FlexusL instance.
Step 2: Log In to the Cloud Server
- Locate the purchased instance and choose > Reset Password.
- Set and confirm a new password as prompted.
If you reset the password for a running server, the password change is applied only after the next restart. Auto Restart is selected by default.
- Click OK.
The server status is Restarting. Wait until the status changes to Running and go to the next step.
- Locate the purchased instance and click Remote Login.
- Enter the username and password as prompted to log in to the server.
The username is root, and the password is the one set in step 2.
Step 3: Configure the Nginx Server
- Add the Nginx yum repository of CentOS 7.
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
The command may fail to be executed because the Nginx version is continuously updated. In this case, obtain the latest Nginx software package from http://nginx.org/packages/centos/7/noarch/RPMS and use it to replace the nginx-release-centos-7-0.el7.ngx.noarch.rpm field.
- Install Nginx.
- Start Nginx.
- Configure automatic startup for Nginx.
- Obtain the EIP of the purchased instance.
- Enter the EIP in the address bar of a local browser to preview the default Nginx server page.
If the page can be previewed properly, the Nginx server is successfully deployed.
Figure 1 Default Nginx server page
(Optional) Step 4: Add and Resolve a Domain Name
If you want your users to access the website through a domain name, add and resolve a domain name for the server. If the website is only used for personal development or testing, there is no need to add a domain name and you can skip this step.
- In the navigation pane on the left, choose Cloud Servers and then click the server name.
- On the Server Details page, click the Domain Names tab and click Add Domain Name.
Parameter
Example Value
Description
Domain Name
wpwebsite.com
Enter a domain name that will be added for the instance,
NOTE:A domain name that is not registered can be added. After the domain name is added, it must be registered and licensed. To ensure that a domain name can be used normally, register the domain name and complete ICP licensing before adding the domain name.
Enterprise Project
default
Select an enterprise project from the drop-down list.
Enterprise projects are associated with public zones. You can manage public zones by enterprise project.
NOTE:This parameter is displayed only when your account is an enterprise account.
- Click OK.
- In the row containing the wpwebsite.com domain name, click Configure Record Set.
Parameter
Example Value
Description
Domain Name Prefix
www
If you enter a prefix, a subdomain is used for website access. Either the domain name or its subdomains can be resolved to the EIP of the instance.
Suppose the domain name is wpwebsite.com.
- If the domain name prefix is left empty, wpwebsite.com is resolved to the EIP.
- If the domain name prefix is www, the subdomain www.wpwebsite.com is mapped to the EIP.
EIP
Retain the default value.
The EIP bound to the instance is displayed here automatically.
- On the Domain Names tab, view the domain name resolution details.
- Apply for ICP licensing for the domain name.
To successfully access the server using a domain name, you must file the domain name. Domain name filing in the Huawei Cloud ICP license center is free of charge. For details, see ICP Filing Process.
(Optional) Step 5: Apply for and Install an SSL Certificate for Your Instance
Install an SSL certificate if you need to enable HTTPS on your server. For details, see About SCM and SSL Certificate Usage.
Related Information
When you set up the environment by referring to Setting Up Websites, ensure that the image version used by the FlexusL instance is the same as that in the tutorial to prevent command execution failures caused by version incompatibility.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot