Install Apache, MySQL and PHP 8 (LAMP) on Ubuntu 20.04 LTS
In this guide we’ll see how to install PHP , Apache, MySQL/MariaDB on Linux and Ubuntu 20.04.
Installing Apache on Ubuntu 20.04
Let’s get started by installing Apache on our Ubuntu 20.04 machine. Open a new terminal and run the following commands:
$ sudo apt install apache2 -y
$ sudo systemctl start apache2.service
Next, you need to enable Apache to start on boot using the following command:
$ sudo systemctl enable apache2.service
Installing MySQL/MariaDB
Next, let’s install MariaDB, a drop-in replacement for MySQL. In your command-line interface run the following command:
$ sudo apt install mariadb-server mariadb-client -y
Next, you need to rnable MariaDB to start on boot using the following command:
$ sudo systemctl enable mariadb.service
After that. it’s a best practice to secure the database. Run the following command:
$ sudo mysql_secure_installation
You’ll be prompted for a bunch of questions which you need to answer according to your security preferences.
Installing PHP 8 on Ubuntu 20.04
Now, let’s install PHP 8 and its common extensions as follows:
$ sudo apt install php php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
Next, you need to restart Apache to load PHP.
$ sudo systemctl restart apache2.service
Conclusion
In this guide, you have seen how to install a LAMP stack on your Ubuntu 20.04 LTS system. For more information about LAMP, see the official documentation: