Step 2: Configuring the Droplet and installing LAMP stack

In this article, we will explain how we can configure and install LAMP stack to host Wordpress.

As a disclaimer, this article has been put together reading and experimenting what's on the page on Digital Ocean documentation and many others like that. Feel free to jump on to the original documentation resources.

Let's start by accessing our Droplet via SSH since we have setup SSH authentication method when we were creating the droplet.

1.1.1.1 to replace with your droplet's public IP address

Once we have logged-in, we can start adding packages. Before that, let's issue update command first

sudo apt update

Let's install apache next

sudo apt install apache2

Once the apache2 is installed, next enable firewall and allow only two services i-e Apache and OpenSSH

sudo ufw app list
sudo ufw allow in "Apache"
sudo ufw allow in "OpenSSH"
sudo ufw enable
sudo ufw status

Let's install mysql server next by running following command

sudo apt install mysql-server

Once installed, lets run the post install script to secure the mysql server

mysql_secure_installation

Once the mysql server is secured, let's now install php. For me, since the website i will be hosting requires php7.4, so i will be added a ppa and installing the php7.4 from there. Feel free to install without specifying the version, so the version that is supported by OS is installed


sudo add-apt-repository ppa:ondrej/php
sudo update-locale LANG=en_US.UTF-8
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql
sudo apt install php7.4-gd php7.4-curl php7.4-json php7.4-xml php7.4-mysql php7.4-mysqli php7.4-pdo-mysql