Skip to content
Live $300 credit for new accounts Valid for 60 days from account creation 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.3
PHP extensionscli, mysql, curl, gd, mbstring, xml, zip, bcmath, intl
Ubuntu24.04 LTS
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.3/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