Install php 7.4 ubuntu 18.04 digitalocean

DigitalOcean update PHP 7.4 guide by our experts will make the entire process a cake in the walk. Read on to find out more. 

At Bobcares, we offer solutions for every query, big and small, as a part of our DigitalOcean Managed Services.

Let’s take a look at how our DO Support Team helped our customers with learning about updating DigitalOcean PHP 7.4.

Guide: DigitalOcean Update PHP 7.4

Today we will take a quick look at how to update PHP 7.4.

Install php 7.4 ubuntu 18.04 digitalocean

  1. To begin with, we have to check for updates to Ubuntu as well as the repositories at the root with the following command:
    $ sudo apt-get update && apt-get upgrade

    We have to enter Y when prompted.

  2. Similarly, enter Y when checking for installed programs and install the updates as required by running this command:
    $ sudo apt-get dist-upgrade
  3. Next, clean packages not in use with this command:
    $ sudo apt-get autoremove
  4. After that, save the list of current PHP settings to a text file via cat packages-first.txt. We will need these later when we install extensions for PHP 7.4.
    $ sudo dpkg -l | grep php | tee packages-first.txt
  5. Then we have to head to the DigitalOcean account and turn off the Droplet on which we plan to update PHP. Next, we must create a snapshot before turning the droplet back on.
  6. After that, we will add the repository for the new PHP version as seen here:
    $ sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
    $ sudo apt-get update
  7. Next, install the PHP 7.4 basic configuration with this command:
    $ sudo apt install php7.4 php7.4-common php7.4-cli
  8. Then, we will install the required extensions. For instance:
    $ sudo apt install php7.4-bcmath php7.4-bz2 php7.4-curl php7.4-intl php7.4-mbstring php7.4-mysql php7.4-readline php7.4-xml php7.4-zip
  9. Now, it is time to create a second file in order to view the installed extensions and compare it with the first file in step 4. Furthermore, both the files are available in the root of the Droplet via SFTP access. Then install the PHP 7.4 extensions we need:
    $ sudo dpkg -l | grep php | tee packages-second.txt
  10. After that, it is time to go ahead with web server integration with Apache:
    $ sudo apt install php7.4-fpm
    $ sudo a2enconf php7.4-fpm # For Apache only

After the above steps, our Support Team recommends removing all previous PHP versions except the most recent version.

[Need assistance with a different issue? We are available 24/7.]

Conclusion

In brief, our skilled DO Support Engineers at Bobcares demonstrated how to Update PHP 7.4 DigitalOcean. The process involves removing earlier PHP versions except for the latest version.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

I kept seeing a notice on WordPress Site Health about PHP needing an update. On Ubuntu, it was showing 7.4 as the PHP version but not in WordPress. I’m writing this post to show the steps I took and it will be a resource I can find quickly in the future.

At root, check for updates to Ubuntu and all repositories. Choose Y when asked.

$ sudo apt-get update && apt-get upgrade

At root, check for installed program updates and it will automatically install those that need updates. Choose Y when asked.

$ sudo apt-get dist-upgrade

At root, clean up any packages not being used. Choose Y when asked.

$ sudo apt-get autoremove

At root, save a list of the currently installed PHP settings to a text file that you can look at later with

$ sudo apt-get dist-upgrade
1 – you will need it later to know which extensions to install for PHP 7.4.

$ sudo dpkg -l | grep php | tee packages-first.txt

Now go into your Digital Ocean account, turn off the Droplet you are going to update PHP on, create a snapshot, then turn the droplet back on.

At root, add repository for latest PHP version.

$ sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
$ sudo apt-get update

At root, install the basic configuration of PHP 7.4.

$ sudo apt install php7.4 php7.4-common php7.4-cli

At root, install the extensions you need. Here are few from the article and you will need to install the extension you have in PHP 7.3 for 7.4 that you can find in packages-first.txt that you made above.

$ sudo apt install php7.4-bcmath php7.4-bz2 php7.4-curl php7.4-intl php7.4-mbstring php7.4-mysql php7.4-readline php7.4-xml php7.4-zip

At root, create a second file to see the currently installed extensions so you can compare it with the first file. You can find both of these in the root of your Droplet if you use SFTP access. Install PHP 7.4 extensions that you need.

$ sudo dpkg -l | grep php | tee packages-second.txt

At root, for web server integration with Apache.

$ sudo apt install php7.4-fpm
$ sudo a2enconf php7.4-fpm # For Apache only

At root, remove all versions of PHP except for the most recent version 7.3. I kept it while going through these steps as a safety blanket until I was sure that I had installed PHP 7.4 extensions of all the PHP 7.3 extensions found in packages-first.txt. I removed 7.0, 7.1, and 7.2. Add the names of the extensions for each older PHP version that are still installed to purge them too, found in packages-second.txt. You don’t want to purge the file names without a number as those are part of the server.

$ sudo apt purge php7.0 php7.0-common # Change 7.0 with all versions you want to purge.

At root, to disable PHP 7.3 and enable PHP 7.4 so that WordPress will see the correct version. Even if

$ sudo apt-get dist-upgrade
2 at root would show the latest version, WordPress would not. The bottom answer from this website helped me here.

How to install PHP 7.4 in Ubuntu 18.04 DigitalOcean?

You can use this command to install additional modules, replacing PACKAGE_NAME with the package you wish to install: sudo apt-get install php7. 4- PACKAGE_NAME.

How do I install PHP on Ubuntu 18.04 DigitalOcean?

Developer and author at DigitalOcean..
Step 1 — Setting Up PHP 8.1. ... .
Step 2 — Setting Up Composer for Dependency Management (Optional) ... .
Step 3 — Using Composer in a PHP Project. ... .
Step 3 — Testing the PHP Environment..

How to install PHP 7.4 27 on Ubuntu?

Installing Ondřej Surý's version of PHP:.
Open Terminal or connect to the server where you need 7.4.27..
Ensure Apache is not running: sudo service apache2 stop. ... .
Add the appropriate PPA: sudo add-apt-repository ppa:ondrej/php..
Update apt : sudo apt update..
Install PHP 7.4.27: sudo apt install php7.4..

How to downgrade PHP 8 to 7.4 in Ubuntu?

In short what you need to do is:.
Ensure the php packages for the version you want are installed..
Update any configuration for that PHP version..
Update your web server configuration to point to the correct PHP version..
Point PHP CLI to the correct PHP version..
Restart your web server and php-fpm..
Mask the old php-fpm daemon..