E: Couldn't find any package by glob 'php-7.4'

May 2024 ยท 1 minute read

I am using Ubuntu 22.04.1 I am having issues with php version's installation Specially php7.4. enter image description here

I have tried with these reference but it did't work for me.

https://www.linuxcapable.com/how-to-install-php-7-4-on-ubuntu-20-04-lts/

How can I install php7.4 on Ubuntu 19.04?

https://www.codegrepper.com/code-examples/php/%3A+Unable+to+locate+package+php7.4-fpm

Please help !!! Thanks.

4

2 Answers

Hit the following commands to install php at any version (replace php7.4 with your required version) in Linux OS:

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

Check PHP Version :

php -v 

You may need some other packages to install. You can do so by following the commands :

sudo apt-get install -y 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 sudo apt install php7.4-fpm 

Start FPM and check status :

systemctl restart php7.4-fpm systemctl status php7.4-fpm 

The above-mentioned actions resolved the problem.

If Still You are Facing below Error (Then Try tricky solution) its not official but worked for me.

Error: Unable to locate package php7.4

Scenario: I was using Ubuntu 20 in azure after trying all documents and efforts but couldn't install PHP.

Solution: I just replaced /etc/apt/source.list file content with fresh Ubuntu 20 /etc/apt/source.list file content and then It worked :-)

Reference Docs : https://tech2towards.blogspot.com/2021/12/install-php-older-version-in-ubuntu-16.html

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmxvaGt%2FeH6OnmScp6Whsa%2FAjJ%2Bgp5xdlru6ec%2BamqSZl5p6o8WMoKOoml2ltbF5lmZr