← Back to VPS & Dedicated

How to Install a LAMP Stack

A LAMP stack (Linux, Apache, MySQL, PHP) is the classic web server setup for hosting PHP applications including WordPress. This guide covers installation on Ubuntu 22.04.

Install Apache

apt update\napt install apache2 -y\nsystemctl enable apache2\nsystemctl start apache2

Test by visiting your VPS IP in a browser β€” you should see the Apache default page.

Install MySQL

apt install mysql-server -y\nmysql_secure_installation

Run mysql_secure_installation to set the root password, remove anonymous users, and disable remote root login.

Install PHP

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

Verify PHP is working: php -v

Testing the Stack

Create a test PHP file:

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

Visit http://YOUR_VPS_IP/info.php to confirm PHP is working with Apache. Delete this file after testing β€” it exposes server configuration.

Was this article helpful?

On This Page