LAMP is a popular environment for building web applications. LAMP is an acronym made up of the names of its four base components: the Linux operating system, Apache HTTP Server, MySQL relational database management system, and PHP programming language. This topic describes how to use a LAMP application image provided by Simple Application Server to build a development environment.

Background information

In the examples, the LAMP 7.4 application image is used to create a simple application server. The image contains the following operating system and software versions:
  • Operating system: CentOS 7.9
  • Apache: Apache 2.4
  • MySQL: MySQL 5.7
  • PHP: PHP 7.4

Step 1: Create a simple application server

  1. Log on to the Simple Application Server console.
  2. In the left-side navigation pane, click Servers.
  3. In the upper-right corner of the Servers page, click Create Server.
  4. On the server buy page of the Simple Application Server console, configure parameters to create a simple application server.
    For more information, see Use an application image to create a server.

    In the Image section, select the LAMP 7.4 application image on the Apps Image tab.

    After the server is created, go back to the Servers page. You can find the card of the created LAMP server. LAMP server card

Step 2: View application information

  1. On the Servers page, click the LAMP server card.
  2. In the left-side navigation pane, choose Applications > Application Details.
  3. View the usernames and passwords of software preset in the LAMP application image.
    1. In the LAMP Information section, click Copy and then click Connect.
    2. In the server command line window that appears, right-click anywhere and select Paste to paste the copied command, and then press the Enter key. View application information in the command output.
      The application information are slightly different based on the version of the LAMP application image. The LAMP 7.4 application image is used in the example. You can find the FTP username and password as well as the administrator password of the database that are preset in the image. Information of software preset in LAMP
    3. Select and right-click the application information. Select Copy to copy the information and paste it to your computer for use in subsequent deployments of websites.
      Keep the password information confidential.
  4. Optional: View the PHP configuration details.
    If you want to use the phpinfo function to view the PHP configuration details or check whether the server is running normally, perform this step.
    The LAMP 6.1.0 and 7.4 application images differ in the following ways:
    • LAMP 7.4 application image: In the LAMP 7.4 image, the phpinfo.php file that contains the phpinfo function is preconfigured and stored in /data/wwwroot/default. /data/wwwroot/default is the website root path. You can access <public IP address of the simple application server>/phpinfo.php by using a browser on your computer to view the PHP configuration details. If a domain name is bound to the simple application server, you can access <domain name of the simple application server>/phpinfo.php by using the browser to view the PHP configuration details. In this example, the LAMP 7.4 application image is used. You can directly use the preceding methods to view the PHP configuration details.
      To view the public IP address and domain name of the simple application server, perform the following steps:
      1. Go back to the Simple Application Server console.
      2. On the Servers page, click the server to go to the Overview page.
      3. In the Server Information section, view the public IP address of the simple application server. adasda
      4. In the Application Setup section, view the domain name of the simple application server. adadada
    • LAMP 6.1.0 application image: By default, the LAMP 6.1.0 image does not contain the phpinfo.php file. Before you can view the PHP configuration details, you must perform the following steps to create the phpinfo.php file and add the phpinfo function to the file:
      1. On the server command line, run the following command to switch to the root user:
        sudo su root
      2. Run the following command to create the phpinfo.php file in the website root directory. This file is used to store the code of the phpinfo function.
        vim /home/www/htdocs/phpinfo.php
      3. Press the I key to enter the edit mode. Add the following code to the file:
        <?php
        phpinfo();
        ?>
      4. Press the Esc key, enter :wq, and then press the Enter key to save and close the file.
      5. On your computer, access <public IP address of the LAMP server/phpinfo.php by using a browser.

        If a domain name is bound to the server, you can access <bound domain name>/phpinfo.php by using the browser.

        In this example, <the public IP address of the LAMP server>/phpinfo.php is accessed by using a browser. The following figure shows the PHP configuration details, which indicate that the LAMP server is running normally. adada

Step 3: Test access to a website

Upload the web project file that you want to deploy to the website root directory on the LAMP server, and change the owner of the web project file to www. In this example, FileZilla is used to upload the test.html file that is only for test purposes. The file contains the following content:
<head>
<meta charset="utf-8">
<title>Test Environment</title>
</head>

<body>
Test123456789
</body>

</html>
Perform the following operations:
  1. Upload the website code stored on your computer to the website root directory on the LAMP server.
    1. Add a firewall rule on the LAMP server to allow traffic on port 21 and ports in the range of 20000 to 30000.
      Port 21 is the default FTP port. Ports in the range of 20000 to 30000 may be used by FTP in passive mode on the LAMP server. For information about how to add a firewall rule, see Add a firewall rule.
    2. Use the stored FTP username and password to connect to the LAMP server. Then, use FileZilla to upload the test.html file to the server.
  2. On the server command line, run the following command to change the owner of the test file.
    In this example, the /data/wwwroot/default website root path and the test.html test file are used. Run the following command to change the owner of the file:
    sudo su root
    chown -R www:www /data/wwwroot/default/test.html
  3. On your computer, access <public IP address of the LAMP server>/test.html by using a browser.
    If a domain name is bound to the server, you can access <bound domain name>/test.html by using the browser.
    A page similar to the following figure indicates that the website is accessed. Test access to a website