How do I update my droplet ? mainly PHP and Mysql. I just run a simple website from it and would like it all update to most current.

Posted December 20, 2019 3.9k views

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @jefflamer,

Updating both PHP and MySQL is easy enough. I’ll guide you through the process, however I strongly suggest before updating MySQL to backup your droplet.


In this case rather than updating, you’ll just install a higher PHP version on your droplet.

Here are the steps, if you are on an Ubuntu.

Update Packages

Make sure your Ubuntu server is having the latest packages by running the following command.

sudo apt update
sudo apt upgrade

Add a repository for PHP 7.3

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update


If you are using Apache as your Web Service, you’ll need to install PHP like this

sudo apt install php7.3


If you are using Nginx however, you’ll need to perform the following

sudo apt install php7.3-fpm


PHP with it’s extensions is useless so you’ll need to install them regardless which Web Service you are using. The next command will include the most common extensions

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y 

If you need to add another one, just type in

sudo apt install php7.3-nameofextension

And you are ready, you now have the latest PHP version on your droplet.

  • Thanks for the guide :). I seem to be stuck installing php7.3. I wasn’t sure if my site was Nginx or Apache. I tried both with no luck.

    oot@jmlResultWordpress:~# sudo apt install php7.3
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package php7.3
    E: Couldn’t find any package by regex ‘php7.3’

    root@jmlResultWordpress:~# sudo apt install php7.3-fpm
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package php7.3-fpm
    E: Couldn’t find any package by regex 'php7.3-fpm’

    • Hi @jefflamer,

      Happy to be of help!

      In order to fix your problem please do run the following prior

      sudo apt-get install software-properties-common
      sudo add-apt-repository ppa:ondrej/php
      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install -y php7.3

      As for what Web Service you are using. You can type in

      netstat -tulpen | grep 80

      The above command will provide you with information as to what is listening on port 80. Port 80 is when you open your website via http. From there you should be able to proceed with the upgrade


Now let’s continue with updating MySQL.

Since you have decided to update it, I’ll strongly suggest going directly to MariaDB. Luckily, the process is indeed easy enough. Let’s start

The first and most important step is to backup your databases. You can do so by using the following command

mysqldump --all-databases --user=root --password --master-data > backupdb.sql

This will dump your database in a file called backupdb.sql in the directory you currently are.

Optionally you can create a backup of my.cnf file somewhere in your system as well

cp /etc/mysql/my.cnf /opt/my.cnf.bak

Remove MySQL

Like PHP, MySQL needs to be reinstalled to have a higher version.

service mysql stop

Now we can uninstall the MySql server, associated utilities amd MySql user.

apt-get remove mysql-server mysql-client mysql-common

deluser mysql

rm -rf /var/lib/mysql

MySQL has been removed from your droplet


Now, going to the fun part, adding the updated software, in this case MariaDB 10.3.

First you need to add MariaDB repository on your system in order to Install MariaDB.

apt-get install software-properties-common

apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8

add-apt-repository 'deb [arch=amd64] bionic main'

Once this has been covered, just in case run an update on your droplet and then continue with the installation

apt update

apt -y install mariadb-server mariadb-client

cp /opt/my.cnf /etc/mysql/

Once this has been completed, just start your MariaDB service like so

service mysqld start

If this doesn’t work, try with

service mariadb start

Ready for work

Finally, we have to import the previously exported databases back to MariaDB server as follows.

mysql -u root -p < backupdb.sql

You are ready to go!


  • Hi KDSys

    I have just come across this post and it is exactly what I need, however I am getting errors, pls will you be so kind to assist.

    I am using Centos 7.9 with Plesk and it is a new droplet with no websites loaded

    You can change this message by editing the file /etc/motd.
    [root@adoring-kare ~]# service mysql stop
    Redirecting to /bin/systemctl stop mysql.service
    Failed to stop mysql.service: Unit mysql.service not loaded.
    [root@adoring-kare ~]# apt-get remove mysql-server mysql-client mysql-common
    -bash: apt-get: command not found
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# deluser mysql
    -bash: deluser: command not found
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# rm -rf /var/lib/mysql
    [root@adoring-kare ~]# apt update
    -bash: apt: command not found
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# apt -y install mariadb-server mariadb-client
    -bash: apt: command not found
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# cp /opt/my.cnf /etc/mysql/apt-get install software-properties-common
    cp: target ‘software-properties-common’ is not a directory
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# apt-key adv –recv-keys –keyserver hkp:// 0xF1656F24C74CD1D8
    -bash: apt-key: command not found
    [root@adoring-kare ~]#
    [root@adoring-kare ~]# add-apt-repository ‘deb [arch=amd64] bionic main’


    • Hi @AndreDT,

      The above commands are for Ubuntu, if you are using CentOS then you need to replace apt-get with yum.

      So, instead of doing :

       apt update

      you’ll do

      yum update

      and so on.