Blog post

How To Set Up a LAMP Stack on Ubuntu/Debian Linux Server

LAMP is an archetypal model of a set of web services, named as an abbreviation of the names of its original four open components: the Linux operating system, the Apache HTTP server, the MySQL relational database management system (RDBMS), and the PHP programming language.

What Is LAMP

LAMP is an archetypal model of a set of web services, named as an abbreviation of the names of its original four open components: the Linux operating system, the Apache HTTP server, the MySQL relational database management system (RDBMS), and the PHP programming language.

LAMP is the most common environment for popular PHP applications such as WordPress, Joomla, Drupal, Magento, Laravel, and many others.

Let’s Set Up a LAMP Stack

Install Apache and customize the firewall to enable web traffic:

sudo apt update
sudo apt install apache2
sudo ufw allow in "Apache Full"

Install MySQL

sudo apt install mysql-server
sudo mysql_secure_installation
sudo mysql

Configure root accounts for password authentication, don’t forget to change the 'password' in your password

SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
exit

Install PHP:

sudo apt install php libapache2-mod-php php-mysql

Tip: On modern Debian/Ubuntu releases, the default PHP is PHP 8.x — significantly faster than PHP 7.x and with better JIT compilation. For running popular CMS applications like WordPress or Joomla, also install these commonly needed extensions:

sudo apt install php-curl php-xml php-mbstring php-zip php-gd php-intl

Don’t forget to check your firewall: sudo ufw status should show “Apache Full” active. If UFW is disabled, enable it with sudo ufw --force enable && sudo ufw allow Apache Full.

Firewall and modules

Ensure your firewall allows HTTP traffic:

sudo ufw allow Apache
sudo ufw reload

For WordPress, Joomla, or Laravel, install common PHP extensions:

sudo apt install php-curl php-xml php-mbstring php-zip php-gd php-intl

Modern PHP 8.x (default on Debian 13 and Ubuntu 24.04) runs roughly 2–3x faster than PHP 7.4 for most applications.

Related What I Do

These What I Do pages are matched from the subject matter of this article, creating a cleaner path from educational content to implementation work.

Continue reading

Based on shared categories first, then the strongest overlap in tags.