. Advertisement .
..3..
. Advertisement .
..4..
The error “Unable to install PHP 7.4 on ubantu 16.04 in apache2” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When Do You Get The Error: “Unable to install PHP 7.4 on ubantu 16.04 in apache2”?
When attempting to install PHP 7.4 in apache2 on Ubuntu 16.04 using the following command:
sudo apt install -y php7.4
You may ecounter this following error :
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.4
E: Couldn't find any package by glob 'php7.4'
E: Couldn't find any package by regex 'php7.4'
The issue is with your Ubuntu version. Actually, Ubuntu 16.04 (Xenial) seems to be too old, and the Hirsute (21.04), Groovy (20.10), Focal (20.04), and Bionic (18.04) operating systems are the only ones supported by the Ondrej PPA. That’s why you’re seeing a message that says “no package detected”. The workaround is to revert to your previous PHP version 7.3. We will show you how to install PHP 7.3 in Ubuntu.
How To Solve The Error: “Unable to install PHP 7.4 on ubantu 16.04 in apache2”?
Approach 1: Revert to your previous PHP version 7.3
The simplest solutionfor you to resolve the error “Unable to install PHP 7.4 on ubantu 16.04 in apache” is to revert to your previous PHP version 7.3.
Firstly, apache2 must be installed. Type the command below on your server to install the Apache web server:
apt install apache2
To begin the Apache service after installing Apache2, type the following command:
systemctl start apache2
This command can be used to examine the status of the Apache web service at any time:
systemctl status apache2
With the command below, you can install PHP 7.3:
apt install php7.3 php7.3-cli php7.3-common
Utilize this command to see if PHP 7.3 is installed on your server:
php -v
Approach 2: Utilize 3rd party repository
Utilizing 3rd party repository is also a great solution for your problem. You simply need to use the following command:
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
Next, run the command below:
sudo apt-get update
Approach 3: Upgrade the operating system to at least 18.04
Ubuntu 16.04 is no longer supported here. Ondrej PPA only accepts Ubuntu (and PHP) versions that are still supported. Standard Support for 16.04 expired in April 2021, and you have most likely not received any php7.3 upgrades since then. So long as you upgrade to at least 18.04, you should install any PHP version newer than 7.3.
Approach 4: Follow these steps
Excepting the solutions mentioned above, there is another solution for you to fix your error. Let’s follow these steps.
1. First, add the PHP PPA repository.
You have to add the PPA repository ppa:ondrej/php, which contains the most recent build packages of PHP.
2. Set up PHP 7.4 on Ubuntu 16.04.
Let’s do as the following command to install PHP 7.4 on Ubuntu 16.04:
sudo apt -y install php7.4
After that, look over the version which has just set up:
$ php -v
PHP 7.4.0beta4 (cli) (built: Aug 28 2019 11:41:49) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v7.4.0beta4, Copyright (c), by Zend Technologies
Then, to install additional packages, run the following command:
sudo apt-get install php7.4-xxx
For instance:
sudo apt install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip,common}
PHP configurations which is relavant with Apache is saved in /etc/php/7.4/apache2/php.ini.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “Unable to install PHP 7.4 on ubantu 16.04 in apache2” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Read more
Leave a comment