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

On the server buy page of the Simple Application Server console, configure parameters to create a simple application server.
For more information, see Create a simple application server by using the WordPress application image.

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. 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.
      You can find the FTP username and password as well as the administrator password of the database preset in the LAMP application 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.
  3. 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:
    • In the LAMP 7.4 application 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 <bound domain name>/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.

    • By default, the LAMP 6.1.0 application 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.
      If the PHP configuration details are displayed as shown in the following figure, the LAMP server is running normally. PHP server
    6. After the test is complete, we recommend that you run the following command to delete the phpinfo.php file from the website root directory to prevent data leaks:
      rm -rf /home/www/htdocs/phpinfo.php

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>
  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 Firewalls.
    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.
      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 /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:
    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