
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.
Log in to the Vultr Customer Portal.
Navigate to the Products and click Compute.
Click Deploy Server.
Select your desired instance type, such as Dedicated CPU.
Choose a Vultr location to deploy the instance to.
Select the instance specifications within the Server Plan section.
Click Configure to set up the instance configuration.
Navigate to the Marketplace tab and enter
LAMP
as the search term.Optional: Select any additional features to enable on the instance, such as VPC Networks.
Review your instance configuration and click Deploy to provision the instance.
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.
Visit your instance's IP address using a web browser such as Chrome and verify that the default web page displays.
http://SERVER-IP
Access the instance using SSH to verify the installed LAMP stack components.
console$ ssh user@SERVER-IP
Create a non-root user with a strong password. Replace
exampleuser
with your desired username.console# adduser exampleuser
Grant the user sudo privileges.
console# adduser exampleuser sudo
Switch to the user.
console# su - exampleuser
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
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
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.
View the
.my.cnf
contents in theroot
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
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.
sqlMariaDB[none]>
Create a new
sampled
database.sqlMariaDB [none]> CREATE DATABASE sampledb;
Switch to the
sampledb
database.sqlMariaDB [none]> USE sampledb;
Create a sample
users
table with two columns.sqlMariaDB [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 anid
column that automatically increments integer values (INT
) with each new entry and ensures unique values with a primary key.name
: Creates aname
column that stores alphanumeric data with up to100
characters,NOT NULL
ensures the columnn cannot be empty.
Insert a new
Greetings from Vultr
record into theusers
table.sqlMariaDB [sampledb]> INSERT INTO users (name) VALUES ('Greetings from Vultr');
Verify the table records.
sqlMariaDB [sampledb]> SELECT * FROM users;
Output:
+----+----------------------+ | id | name | +----+----------------------+ | 1 | Greetings from Vultr | +----+----------------------+ 1 row in set (0.000 sec)
Create a new database user, such as
user
with a strong password.sqlMariaDB [sampledb]> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
Grant the user full privileges to the
sampledb
database.sqlMariaDB [sampledb]> GRANT ALL PRIVILEGES ON sampledb.* TO 'user'@'localhost';
Flush the MySQL privileges table to apply the changes.
sqlMariaDB [sampledb]> FLUSH PRIVILEGES;
Exit the MySQL shell.
sqlMariaDB [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
.
Create a new domain A record pointing to your instance's public IP address. For example,
app.example.com
.Create a web root directory to store your web application files.
console$ sudo mkdir /var/www/app.example.com
Create a new
index.php
application file.console$ sudo nano /var/www/app.example.com/index.php
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 aGreetings from Vultr
message from the database.Grant the Apache
www-data
user and group ownership privileges to theapp.example.com
directory.console$ sudo chown -R www-data:www-data /var/www/app.example.com
Change the web root directory permissions mode to
775
to grant read, write, and execute privileges to thewww-data
user and group.console$ sudo chmod -R 775 /var/www/app.example.com
Navigate to the
sites-available
Apache virtual host configurations directory.console$ cd /etc/apache2/sites-available
Create a new
app.example.com.conf
virtual host configuration.console$ sudo nano app.example.com.conf
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 theapp.example.com
domain to serve web application files from the/var/www/app.example.com
directory.Link the
app.example.com.conf
configuration to thesites-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
Navigate to the sites-enabled directory.
console$ cd /etc/apache2/sites-enabled
Unlink the http and https virtual host file.
console$ sudo unlink http.conf && sudo unlink https.conf
Restart Apache to apply the changes.
console$ sudo systemctl restart apache2
Access your
app.example.com
domain in a new web browser window and verify that your PHP application displays.http://app.example.com
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.
Install the Certbot Let's Encrypt plugin for Apache.
console$ sudo apt install python3-certbot-apache -y
Generate an SSL certificate for your virtual host domain. Replace
app.example.com
with your actual, andadmin@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. .........................
Restart Apache to apply the SSL configuration changes.
console$ sudo systemctl restart apache2
Access your domain using the HTTPS scheme in a new web browser window and verify that the connection is secure.
https://app.example.com
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.
No comments yet.