Skip to content
Live $100 credit at signup, up to $300 total Offer ends December 31, 2026 Get started →

LAMP Stack

The LAMP stack (Linux, Apache, MariaDB, and PHP) is the classic combination for hosting web applications and dynamic websites. This image ships all four components pre-installed and configured to work together, ready for you to deploy your application.

ComponentVersion
Apache2.4.x
MariaDBLatest stable
PHP8.4
PHP extensionscli, mysql, curl, gd, mbstring, xml, zip, bcmath, intl
Ubuntu24.04 LTS

This image takes no deploy-time variables. MariaDB is installed with socket authentication for root, and no application database is created. Create one after first boot:

sudo mariadb -e "CREATE DATABASE app;"
sudo mariadb -e "CREATE USER 'app'@'localhost' IDENTIFIED BY '<password>';"
sudo mariadb -e "GRANT ALL PRIVILEGES ON app.* TO 'app'@'localhost';"
ssh ubuntu@<your-vm-ip>

There is no first-boot configuration. All services start immediately.

systemctl status apache2
systemctl status mariadb
php --version

Open a browser and navigate to:

http://<your-vm-ip>

Place your application files in the web root:

sudo cp -r my-app/* /var/www/html/
sudo chown -R www-data:www-data /var/www/html/

On a fresh install, no password is required. Authentication uses the system socket. Connect as root:

sudo mariadb

Create a database and user for your application:

CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp'@'localhost' IDENTIFIED BY '<strong-password>';
GRANT ALL PRIVILEGES ON myapp.* TO 'myapp'@'localhost';
FLUSH PRIVILEGES;
EXIT;
# Restart Apache
sudo systemctl restart apache2
# Restart MariaDB
sudo systemctl restart mariadb
# View Apache logs
sudo tail -f /var/log/apache2/error.log
# View MariaDB logs
sudo journalctl -u mariadb -f

Key directories and files:

PathPurpose
/var/www/html/Default web root
/etc/apache2/sites-available/Apache virtual hosts
/etc/php/8.4/apache2/php.iniPHP configuration for Apache
/etc/mysql/mariadb.conf.d/MariaDB configuration

To create a virtual host for a domain, add a configuration file to /etc/apache2/sites-available/ and enable it:

sudo a2ensite myapp.conf
sudo systemctl reload apache2

Port 80 is open by default. UFW is enabled.

After setting up HTTPS, restrict HTTP traffic:

sudo ufw allow 443/tcp
sudo ufw delete allow 80/tcp