Install Apache, PHP, and MySQL in Debian 10 (Buster)
Debian Buster is currently the stable version of the GNU/Linux Debian operating system. If you are a web developer or you need to configure a project developed in PHP with Apache and MySQL, this tutorial is for you.
Installation
The first step is to install the packages that we already have available.
sudo apt-get install apache2 php gnupg
We download the configuration script of the repo directly from mysql and install it.
wget https://dev.mysql.com/get/mysql-apt-config_0.8.17-1_all.deb
sudo dpkg -i mysql-apt-config*
If you plan to connect MySQL with any programming language, make sure that the MySQL Tools & Conectors option is Enabled, which is usually the case. You select OK and everything will be configured. With this, we can already update the list of packages with the following command.
sudo apt-get update
If you plan to connect to a database instance on another server, for example, AWS, you only need to install the MySQL client.
sudo apt install mysql-client
If your goal is to host the database on the same application server, then we can directly install the mysql server that already includes the client.
sudo apt install mysql-server
The installation wizard will ask you for a password for the root user. Make sure this password is secure enough. It is also recommended to select the option of password encryption which provides greater security for your password.
The last step is to make the installation secure. This involves performing some configurations such as passwords being verified (length, special characters, upper and lower case), removing anonymous users, disabling remote login, and deleting test databases. For this, you can use the following command and follow the instructions.
sudo mysql_secure_installation
And that's it, you can log in now. Don't forget to check out our post Terminal Connection to MySQL to see the different options to connect.
Configuration
Once Apache, PHP, and MySQL are installed, it is advisable to make some configurations. To see a complete Apache configuration from scratch, you can follow the following link.
Configure Apache from Scratch in Linux