Home/Blog/How to Install LAMP Stack on Ubuntu VPS (Step by Step)
Netherlands VPS Guide

How to Install LAMP Stack on Ubuntu VPS (Step by Step)

Install Apache, MySQL, and PHP on Ubuntu VPS. Set up virtual hosts, secure MySQL, test PHP, and deploy your first web application.

2026-02-13 7 min read Amsterdam, Netherlands

What is a LAMP Stack?

LAMP stands for Linux, Apache, MySQL (or MariaDB), and PHP. It is the most widely deployed web server stack in the world and the foundation for millions of PHP applications including WordPress, Drupal, and Joomla.

Step 1: Install Apache

apt update && apt upgrade -y
apt install apache2 -y
systemctl enable apache2
systemctl start apache2
ufw allow 'Apache Full'

Step 2: Install MySQL / MariaDB

apt install mariadb-server -y
systemctl enable mariadb
mysql_secure_installation

Run mysql_secure_installation and answer: set root password (Yes), remove anonymous users (Yes), disallow root remote login (Yes), remove test database (Yes), reload privilege tables (Yes).

Step 3: Install PHP

apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-zip -y
systemctl restart apache2

# Test PHP
echo "<?php phpinfo(); ?>" > /var/www/html/info.php

Visit http://YOUR_VPS_IP/info.php to verify PHP is working. Delete this file after testing: rm /var/www/html/info.php

Step 4: Configure Virtual Host

mkdir -p /var/www/yourdomain.com
nano /etc/apache2/sites-available/yourdomain.com.conf

Paste:

<VirtualHost *:80>
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    DocumentRoot /var/www/yourdomain.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
a2ensite yourdomain.com.conf
a2dissite 000-default.conf
systemctl reload apache2

Step 5: Install Free SSL

apt install certbot python3-certbot-apache -y
certbot --apache -d yourdomain.com -d www.yourdomain.com

Certbot automatically configures Apache for HTTPS and sets up auto-renewal.

Deploy Your LAMP Stack VPS in Amsterdam

Linux VPS from $3/month — install LAMP in minutes

Deploy Netherlands VPS Now

Frequently Asked Questions

LEMP (Linux, Nginx, MySQL, PHP) is generally better for VPS because Nginx uses far less memory than Apache. For a VPS with limited RAM, LEMP handles more concurrent connections more efficiently. However, LAMP is simpler to configure for beginners and works perfectly for most applications.
Log into MySQL: mysql -u root -p. Then: CREATE DATABASE myapp; CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON myapp.* TO 'myuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
PHP 8.1 or 8.2 is recommended for new deployments. These versions are significantly faster than PHP 7.x and are supported with security updates. WordPress and most modern PHP applications support PHP 8.1+.
Create a test file: echo '

Hello

' > /var/www/html/index.html and visit your VPS IP in a browser. If you see the page, Apache is working. Also use: curl -I http://localhost to check from the command line.
Yes. You can run a native LAMP stack alongside Docker containers on the same VPS. Ensure they use different ports to avoid conflicts, or use Docker to containerise your entire LAMP stack for better portability.