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.
About LAMP
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.
Note: This guide applies only to unmanaged hosting packages. You must have root access to install Ubuntu and a LAMP stack.
Installing a LAMP stack on Ubuntu
The following steps assume Ubuntu is installed on your server.
-
Log in via SSH as the root user.
-
Update the system:
apt update
apt upgrade
-
Install and run
tasksel:
apt install tasksel
tasksel
The tasksel interface lists predefined software collections for installation.
-
Install the LAMP server:
-
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.
-
Verify the installation:
-
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.
-
Secure MySQL: Strengthen MySQL security by running:
mysql_secure_installation
Follow the prompts to configure additional security settings.