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 Build a WordPress blog.

    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 administrator password of the database that is preset in the image.
      [admin@iZj6cfztoffl5xdjtax**** ~]$ sudo cat /credentials/password.txt
      mysql administrator username:root
      mysql administrator password:w1gnxHCyKKB****
      
      ---
    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 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.
    Note By default, LAMP images do 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.
      • LAMP 7.4:
        vim /data/wwwroot/example/phpinfo.php
      • LAMP 6.1.0:
        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 http://<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, http://<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. In this example, FileZilla is used to upload the test.html file that is only for test purposes to the website root directory on the LAMP 7.4 server. 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 /data/wwwroot/example directory of the LAMP server.
      For more information, see Build an FTP server.
  2. On the server command line, run the following command to change the owner of the test file.
    In this example, the LAMP 7.4 sever is connected. The website root directory is and the test file is test.html, so the following command is run:
    sudo su root
    chmod 777 -R /data/wwwroot/example
    chown -R apache:apache /data/wwwroot/example/test.html
  3. On your computer, access http://<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