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
Section titled “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.
Installing a LAMP stack on Ubuntu
Section titled “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
Section titled “Update the system”
apt updateapt upgrade-
Install and run tasksel
Section titled “Install and run tasksel”
apt install taskseltaskselThe tasksel interface lists predefined software collections for installation.
-
Install the LAMP server
Section titled “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
Section titled “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 --versionTip: 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_installationFollow the prompts to configure additional security settings.