How to Use Vultr’s LAMP Marketplace Application

Updated on 19 April, 2025
How to Use Vultr’s LAMP Marketplace Application header image

Vultr's LAMP Marketplace Application is a production-ready solution for building and deploying web applications. The LAMP (Linux, Apache, MySQL, PHP) stack includes all major components required to develop and serve web applications. Linux works as the base operating system, Apache as the web server for delivering web applications, while MySQL works as the database backend, and PHP as a dynamic application processor for server-side scripting functionalities.

Follow this guide to use Vultr's LAMP Marketplace Application. You will provision a new instance using the Vultr Marketplace Application for LAMP, set up a sample web application, and create databases to serve dynamic web applications.

Deploy Vultr's LAMP Marketplace Application

Follow the steps below to deploy the Vultr Marketplace Application for LAMP.

  1. Log in to the Vultr Customer Portal.

  2. Navigate to the Products and click Compute.

  3. Click Deploy Server.

  4. Select your desired instance type, such as Dedicated CPU.

  5. Choose a Vultr location to deploy the instance to.

  6. Select the instance specifications within the Server Plan section.

  7. Click Configure to set up the instance configuration.

  8. Navigate to the Marketplace tab and enter LAMP as the search term.

    Select LAMP Marketplace Application

  9. Optional: Select any additional features to enable on the instance, such as VPC Networks.

  10. Review your instance configuration and click Deploy to provision the instance.

    Review and Deploy

Vultr's LAMP Marketplace Application Features

Vultr's LAMP Marketplace Application includes the following features.

  • Open-source: Each component in the LAMP stack is open-source, making it a cost-effective solution for your web development and hosting needs.
  • Modular Architecture: Each component in LAMP is modular and can be replaced or upgraded independently.
  • Scalability: LAMP supports vertical and horizontal scaling, allowing you to serve small-scale and enterprise-level applications.
  • Stability and Reliability: The LAMP stack supports high amounts of traffic without compromising web application performance.
  • High Performance: Apache serves dynamic content with PHP, while MySQL is optimized as the database backend, ensuring high performance for hosted web applications.

Access and Use the LAMP Stack

Vultr's LAMP Marketplace Application is configured with the default instance IP address and firewall rules to accept incoming HTTP and HTTPS connections to the instance. Follow the steps below to access and use the LAMP stack on your instance.

  1. Visit your instance's IP address using a web browser such as Chrome and verify that the default web page displays.

    http://SERVER-IP

    Default LAMP Web Page

  2. Access the instance using SSH to verify the installed LAMP stack components.

    console
    $ ssh user@SERVER-IP
    
  3. Create a non-root user with a strong password. Replace exampleuser with your desired username.

    console
    # adduser exampleuser
    
  4. Grant the user sudo privileges.

    console
    # adduser exampleuser sudo
    
  5. Switch to the user.

    console
    # su - exampleuser
    
  6. Send a sample request to the localhost address and verify that Apache is the active web server.

    console
    $ curl --head http://localhost
    

    Output:

    HTTP/1.1 200 OK
    Date: Wed, 26 Mar 2025 11:53:26 GMT
    Server: Apache/2.4.58 (Ubuntu)
    Content-Type: text/html; charset=UTF-8
  7. View the Apache service status and verify that it's running.

    console
    $ sudo systemctl status apache2
    

    Your output should be similar to the one below.

    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
         Active: active (running) since Thu 2025-04-17 15:57:32 UTC; 1min 23s ago
           Docs: https://httpd.apache.org/docs/2.4/
        Process: 20587 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
       Main PID: 20591 (apache2)
          Tasks: 55 (limit: 9433)
         Memory: 7.5M (peak: 8.3M)
            CPU: 70ms
         CGroup: /system.slice/apache2.service
                 ├─20591 /usr/sbin/apache2 -k start
                 ├─20593 /usr/sbin/apache2 -k start
                 └─20594 /usr/sbin/apache2 -k start
  8. View the MySQL service status and verify that it's running.

    console
    $ sudo systemctl status mysql
    

    Output:

    ● mariadb.service - MariaDB 10.11.11 database server
         Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
         Active: active (running) since Wed 2025-04-09 15:53:49 UTC; 40min ago
           Docs: man:mariadbd(8)
                 https://mariadb.com/kb/en/library/systemd/
       Main PID: 3204 (mariadbd)
         Status: "Taking your SQL requests now..."
          Tasks: 10 (limit: 30379)
         Memory: 79.8M (peak: 82.3M)
            CPU: 579ms
         CGroup: /system.slice/mariadb.service
                 └─3204 /usr/sbin/mariadbd

Access MySQL and Set Up a Sample Database

Vultr's LAMP Marketplace Application includes MariaDB as the database backend. MariaDB is a drop-in replacement for MySQL that supports the SQL syntax with a higher query speed. Follow the steps below to verify the default MySQL database user information and create a sample database.

  1. View the .my.cnf contents in the root directory and verify the default MySQL user information.

    console
    $ sudo cat /root/.my.cnf
    

    Verify the root MySQL username and copy the default user password to use when logging in.

    [client]
    user=root
    password=TqqfzIUx5jcF5SJ
  2. Log in to MySQL as the root user and enter the default password when prompted.

    console
    $ sudo mysql -u root -p
    

    Verify that your prompt changes to the MariaDB shell when successful.

    sql
    MariaDB[none]>
    
  3. Create a new sampled database.

    sql
    MariaDB [none]> CREATE DATABASE sampledb;
    
  4. Switch to the sampledb database.

    sql
    MariaDB [none]> USE sampledb;
    
  5. Create a sample users table with two columns.

    sql
    MariaDB [sampledb]> CREATE TABLE users (
         id INT AUTO_INCREMENT PRIMARY KEY,
         name VARCHAR(100) NOT NULL
        );
    

    The above SQL query creates a new users table with the following columns.

    • id: Creates an id column that automatically increments integer values (INT) with each new entry and ensures unique values with a primary key.
    • name: Creates a name column that stores alphanumeric data with up to 100 characters, NOT NULL ensures the columnn cannot be empty.
  6. Insert a new Greetings from Vultr record into the users table.

    sql
    MariaDB [sampledb]> INSERT INTO users (name) VALUES ('Greetings from Vultr');
    
  7. Verify the table records.

    sql
    MariaDB [sampledb]> SELECT * FROM users;
    

    Output:

    +----+----------------------+
    | id | name                 |
    +----+----------------------+
    |  1 | Greetings from Vultr |
    +----+----------------------+
    1 row in set (0.000 sec)
  8. Create a new database user, such as user with a strong password.

    sql
    MariaDB [sampledb]> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
    
  9. Grant the user full privileges to the sampledb database.

    sql
    MariaDB [sampledb]> GRANT ALL PRIVILEGES ON sampledb.* TO 'user'@'localhost';
    
  10. Flush the MySQL privileges table to apply the changes.

    sql
    MariaDB [sampledb]> FLUSH PRIVILEGES;
    
  11. Exit the MySQL shell.

    sql
    MariaDB [sampledb]> EXIT;
    

Create a Virtual Host Configuration for Apache

Follow the steps below to create a new virtual host configuration for Apache to serve web applications using a domain such as app.example.com.

  1. Create a new domain A record pointing to your instance's public IP address. For example, app.example.com.

  2. Create a web root directory to store your web application files.

    console
    $ sudo mkdir /var/www/app.example.com
    
  3. Create a new index.php application file.

    console
    $ sudo nano /var/www/app.example.com/index.php
    
  4. Add the following contents to the file. Replace user, password, sampledb with your actual database information.

    php
    <?php
    $servername = "localhost";
    $username   = "user";
    $password   = "password";
    $database   = "sampledb";
    
    // Create a connection
    $conn = new mysqli($servername, $username, $password, $database);
    
    // Check connection
    if ($conn->connect_error) {
        die("Database connection failed: " . $conn->connect_error);
    }
    
    // Run a query
    $sql    = "SELECT name FROM users";
    $result = $conn->query($sql);
    
    // Display result
    if ($result && $row = $result->fetch_assoc()) {
        echo "<h1 align='center'>" . htmlspecialchars($row["name"]) . "</h1>";
    } else {
        echo "No matching record found in the database or query error.";
    }
    
    // Close connection
    $conn->close();
    ?>
    

    Save and close the file.

    The above PHP application connects to the MySQL database server and queries the users table to output a Greetings from Vultr message from the database.

  5. Grant the Apache www-data user and group ownership privileges to the app.example.com directory.

    console
    $ sudo chown -R www-data:www-data /var/www/app.example.com
    
  6. Change the web root directory permissions mode to 775 to grant read, write, and execute privileges to the www-data user and group.

    console
    $ sudo chmod -R 775 /var/www/app.example.com
    
  7. Navigate to the sites-available Apache virtual host configurations directory.

    console
    $ cd /etc/apache2/sites-available
    
  8. Create a new app.example.com.conf virtual host configuration.

    console
    $ sudo nano app.example.com.conf
    
  9. Add the following configurations to the file. Replace app.example.com with your actual domain.

    ini
    <VirtualHost *:80>
        ServerAdmin admin@example.com
        ServerName app.example.com
        ServerAlias www.app.example.com
    
        DocumentRoot /var/www/app.example.com
    
        ErrorLog ${APACHE_LOG_DIR}/app.example.com_error.log
        CustomLog ${APACHE_LOG_DIR}/app.example.com_access.log combined
    
        <FilesMatch \.php$>
            SetHandler "proxy:fcgi://127.0.0.1:9000"
        </FilesMatch>
    </VirtualHost>
    

    Save and close the file.

    The above Apache virtual host configuration listens for HTTP requests on port 80 using the app.example.com domain to serve web application files from the /var/www/app.example.com directory.

  10. Link the app.example.com.conf configuration to the sites-enabled directory to enable it.

    console
    $ sudo ln -s /etc/apache2/sites-available/app.example.com.conf /etc/apache2/sites-enabled/app.example.com.conf
    
  11. Navigate to the sites-enabled directory.

    console
    $ cd /etc/apache2/sites-enabled
    
  12. Unlink the http and https virtual host file.

    console
    $ sudo unlink http.conf && sudo unlink https.conf
    
  13. Restart Apache to apply the changes.

    console
    $ sudo systemctl restart apache2
    
  14. Access your app.example.com domain in a new web browser window and verify that your PHP application displays.

    http://app.example.com

    Test the Virtual Host Web Application

Secure Web Applications with Trusted SSL Certificates

Follow the steps below to secure the Apache virtual host configuration with trusted Let's Encrypt SSL certificates to enable HTTPS connections to your web applications.

  1. Install the Certbot Let's Encrypt plugin for Apache.

    console
    $ sudo apt install python3-certbot-apache -y
    
  2. Generate an SSL certificate for your virtual host domain. Replace app.example.com with your actual, and admin@example.com with your email address.

    console
    $ sudo certbot --apache --redirect -d app.example.com  -m admin@example.com --agree-tos
    

    Your output should be similar to the one below when the SSL certificate request is successful.

    ...............
    Deploying certificate
    Successfully deployed certificate for app.example.com to /etc/apache2/sites-available/app.example.com-le-ssl.conf
    Congratulations! You have successfully enabled HTTPS on https://app.example.com.
    .........................
  3. Restart Apache to apply the SSL configuration changes.

    console
    $ sudo systemctl restart apache2
    
  4. Access your domain using the HTTPS scheme in a new web browser window and verify that the connection is secure.

    https://app.example.com

    Secure Web Application

Conclusion

You have deployed and used Vultr's LAMP marketplace application, explored its components, and deployed a sample application using a virtual host configuration for Apache. You can use the LAMP stack to develop and manage your web applications without setting up each component manually after installation. In addition, you can integrate backend services to integrate the LAMP stack and enable additional features in your applications with API requests.

Comments

No comments yet.