What is best way to install PHP 7.4 FPM on Ubuntu 18.04

570 Views Asked by At

I tried using below PPA repository below.

sudo add-apt-repository ppa:ondrej/php
sudo apt-get install -y php7.4 php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath

I am getting these errors.

E: Unable to locate package php7.4-cli
E: Couldn't find any package by glob 'php7.4-cli'
E: Couldn't find any package by regex 'php7.4-cli'
E: Unable to locate package php7.4-json
E: Couldn't find any package by glob 'php7.4-json'
E: Couldn't find any package by regex 'php7.4-json'

I am easily able to install it on newer versions of Ubuntu.

I tried installing php7.4 and php7.4-fpm and I am getting errors. I might a fix or another alternative solution.

1

There are 1 best solutions below

12
Ken Lee On BEST ANSWER

Please install software-properties-common first

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

After the above ,

then either execute

sudo apt-get install -y php7.4

or, if you wish

sudo apt-get install -y php7.4 php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath

Additional Comments

if your apt is out-of-date, please execute the following 2 lines first, before installing software-properties-common

$ sudo apt update
$ sudo apt upgrade

If unfortunatley the binaries are removed (it happens) you may need to either (1) compile it (the old software version) by yourself, or (2) upgrade your OS distribution; or (3) use the archive . See this post in Stack Exchange network and please also perform a web search such as PHP Ondrej Archive to find the archive resource you really need

One of the links will be

https://launchpad.net/~tomvlk/+archive/ubuntu/php-archive

Please note that it's not any kind of official repository so use it at the your own risk