LNMP is an acronym for the names of the following 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.


  • 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

You do not need to download or install anything to use ROS. You can use ROS to create stack templates in the JSON format. You can also use a sample template in the ROS console to create a stack. For more information, visit the Sample Templates page of the ROS console.

You can use the sample templates provided by 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. In this topic, the Deploys the LNMP (Linux+Nginx+MySQL+PHP) environment template is used to demonstrate how to use ROS to create an Elastic Compute Service (ECS) instance and deploy an LNMP stack on the instance.

For more information about ROS, see the ROS documentation.


  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 a region.
  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.
  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 fieldDescription
    "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 declares 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 provided by ROS, see Template structure.
  7. In the upper-left corner of the page, click Create Stack.
  8. Configure the parameters described in the following table and click Create.
    Stack NameThe name of the stack.
    Available Zone IDRequired. The ID of the zone in which you want to create the ECS instance.
    Image IDThe ID of the image that you want to use for the ECS instance.
    Instance typeRequired. The instance type of the ECS instance.
    System Disk CategoryThe system disk category of the ECS instance.
    Instance PasswordRequired. The logon password of the ECS instance.
    DB NameThe name of the MySQL database.
    DB UsernameThe username of the MySQL database.
    DB PasswordRequired. The password of the MySQL database.
    DB Root PasswordRequired. The administrator (root) password of the MySQL database.
    Nginx SourceThe URL from which to download NGINX. We recommend that you use the default value.
    Note You can click Next to go to the Configure Stack (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 Configure Stack (Optional) step and the Check and Confirm (Optional) step.
    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. LNMP stack status
  9. Click the Outputs tab and view the URL in the Value column of NginxWebsiteURL.
    Use the URL to connect to the LNMP stack that you created.
    Nginx URL
    • 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.