DEV Community

neoan
neoan

Posted on • Originally published at blua.blue

7 1

Install PHP 7.4 on Ubuntu

What's new?

There are countless articles about the changes php7.4 brings. Feel free to get an overview here.

Installation

Regardless of whether you want to upgrade or install, let's first adhere to the general recommendation you will find anywhere. Namely, make sure we are up to date: sudo apt-get update.

Then, we want to add Ondrej Sury's repository:

sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Now we are ready to install php 7.4.

sudo apt -y install php7.4
Enter fullscreen mode Exit fullscreen mode

You might want to test the success with php -v, which will give you an output about the version.

Extensions

I don't know which extensions you might need, but the format is very intuitive and with the example of mbstring looks like this:

sudo apt-get install php7.4-mbstring
Enter fullscreen mode Exit fullscreen mode

Tip: you can install multiple extensions with the following format:

sudo apt-get install -y php7.4-{mbstring,mysql}
Enter fullscreen mode Exit fullscreen mode

NOTE: We are happy with the shipped Apache here, but be sure to install php7.4-fpm if you are aiming for NGINX after stopping apache sudo systemctl disable --now apache2

Old installations

In the case of former installations, you will want to purge the old version of php (assuming php 7.3):

sudo apt purge php7.3 libapache2-mod-php7.3

Image of Wix Studio

2025: Your year to build apps that sell

Dive into hands-on resources and actionable strategies designed to help you build and sell apps on the Wix App Market.

Get started

Top comments (1)

Collapse
 
devugur profile image
Ugur CELIK • Edited

For install all important php 7.4 extensions

apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay