Skip to content

Installing a LAMP stack on an Ubuntu server

Learn how to quickly install a complete LAMP (Linux, Apache, MySQL, PHP) stack on an Ubuntu server.

A LAMP stack is an open-source software bundle used for hosting web applications. It includes:

  • Linux – the operating system (already installed on your server)
  • Apache – the web server
  • MySQL – the database management system
  • PHP – the server-side programming language

Many popular web applications, like WordPress, run on a LAMP stack.

The following steps assume Ubuntu is installed on your server.

  1. Log in via SSH as the root user.
apt update
apt upgrade
apt install tasksel
tasksel

The tasksel interface lists predefined software collections for installation.

  • Use the arrow keys to highlight LAMP server.
  • Press Spacebar to select it, then Enter to start the installation.
  • When prompted, set a password for the MySQL root user.
  • Test Apache: Open your web browser and visit your server’s domain or IP address. You should see the default Apache page.
  • Test PHP: Run the following command:
php --version

Tip: To confirm PHP is integrated with Apache, create a web page containing phpinfo() and load it in your browser. This displays PHP configuration details.

  1. Secure MySQL: Strengthen MySQL security by running:
mysql_secure_installation

Follow the prompts to configure additional security settings.