All Products
Search
Document Center

Elastic Compute Service:use ROS to deploy an LNMP stack with a few clicks

Last Updated:Feb 22, 2024

LNMP is one of the most common web server architectures. It can be used to host large-scale, high-concurrency web applications, such as e-commerce websites, social networking services, and content management systems. LNMP is an acronym for the names of its original four open source components: the Linux operating system, NGINX web server, MySQL relational database management system, and PHP programming language. This topic describes how to use Alibaba Cloud Resource Orchestration Service (ROS) to deploy an LNMP stack.

Prerequisites

  • ROS is activated. The first time you use ROS, you are prompted to activate it. ROS is a free service. You can activate ROS free of charge.

Background information

In this topic, the Deploys the LNMP (Linux+Nginx+MySQL+PHP) environment template of ROS is used to demonstrate how to use ROS to create an Elastic Compute Service (ECS) instance that runs CentOS 7.9 and deploy an LNMP stack on the instance.

You can use the sample templates of ROS to build environments, such as Java web test environments, Node.js development and test environments, Ruby web development and test environments, and Hadoop and Spark distributed systems.

For more information about ROS, see the ROS documentation.

Procedure

  1. Log on to the ROS console.

  2. In the left-side navigation pane, choose Templates > Sample Templates.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. In the upper-right corner of the Sample Templates page, enter Deploys the LNMP in the search box.

  5. Find the Deploys the LNMP (Linux+Nginx+MySQL+PHP) environment template in the search results.

    adad6

  6. Click View Details to view the template file in the JSON format.

    The following table describes the top-level fields of the template file.

    Top-level field

    Description

    "ROSTemplateFormatVersion": "2015-09-01"

    The version of the template. In this example, 2015-09-01 is used.

    "Parameters": {...}

    The parameters of the template. In this example, this field specifies the image ID, instance type, software download URLs, and software configurations. Default values are accepted for some of the parameters.

    "Resources": {...}

    The Alibaba Cloud resources that you want to create based on the template. In this example, this field specifies that an ECS instance and a security group are to be created based on the template. The properties of the resources are specified in the Parameters field.

    "Outputs": {...}

    The resource information that the stack generates after the specified resources are created. In this example, the stack generates the IP address that is used to access NGINX.

    "Description": "Deploy LNMP(Linux+Nginx+MySQL+PHP) stack on 1 ECS instance. ***
                  WARNING *** Only support CentOS-7."

    The description of the template.

    "Metadata": {...}

    Divides parameters in the Parameters field into groups. You can configure labels for each group. In this example, parameters in the Parameters field are divided into different groups based on whether the parameters are instance-related or software-related.

    Note

    For more information about the sample templates of ROS, see Template structure.

  7. In the upper-left corner of the page, click Create Stack.

  8. Configure the parameters that are described in the following table and click Create.

    Parameter

    Description

    Stack Name

    The name of the stack.

    Available Zone ID

    Required. The ID of the zone in which you want to create the ECS instance.

    Image ID

    The ID of the image that you want to use to create the ECS instance.

    Instance Type

    Required. The instance type of the ECS instance.

    System Disk Category

    The system disk category of the ECS instance.

    Instance Password

    Required. The logon password of the ECS instance.

    DB Name

    The name of the MySQL database.

    DB Username

    The username of the MySQL database.

    DB Password

    Required. The password for the MySQL database.

    DB Root Password

    Required. The password for the MySQL administrator (root) user.

    Nginx Source

    The URL from which to download NGINX. We recommend that you use the default value.

    Note

    You can click Next to go to the Compliance Precheck (Optional) step and then to the Check and Confirm (Optional) step. For more information, see Create a stack. In this example, default values are accepted for the parameters in the Compliance Precheck (Optional) and Check and Confirm (Optional) steps.

    After the stack is created, you are redirected to the details page of the stack. You can view the status of the stack on the Stack Information tab.

    image.png

  9. Click the Outputs tab and view the URL in the Value column corresponding to NginxWebsiteURL.

    You can use the URL to connect to the LNMP stack that you created.

    image.png

    Note
    • On the Resources tab, you can view all resources in the stack.

    • On the Events tab, you can view the logs of the operations that ROS performed to create the stack.

References

You can use ROS to deploy an LNMP stack but cannot specify the NGINX, MySQL and PHP versions to install. For information about how to install specific NGINX, MySQL and PHP versions while deploying an LNMP stack, see Deploy an LNMP stack on a CentOS 7 instance and Manually build an LNMP environment on an Ubuntu 20 instance.