After Ubuntu 18.04 upgrade php7.2-curl cannot be installed - php

Upgraded to 18.04 from 16.04 today using do-release-upgrade -d
During the upgrade I was informed that some packages would be removed, these included:
Remove: libperl5.22 lxc-common perl-modules-5.22 php-imagick
php7.1-curl php7.2-curl python3-certbot-nginx
I could re-install imagick and certbot without issue, but if I try to install php7.2-curl I get the message:
# apt install php7.2-curl -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.2-curl : Depends: php7.2-common (= 7.2.3-1ubuntu1) but 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
How can I correct the situation?

This can save you:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Then sudo service apache2 restart

You don't need to add a new repo. Just do this and the 7.2 version will be installed. Remember to restart php and apache after. Also make sure (you've prob already done this though) to enable the new mod after:
sudo apt install php-curl
sudo a2enmod php7.2
You'll also notice probably that at the end of the install of php-curl (which installs php-curl and php7.2-curl) the following (Note that I have FPM setup, might look different if you're not using FPM):
NOTICE: Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
So do what it says:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
sudo systemctl restart apache2.service

Installing libcurl4 worked for me using
apt install libcurl4
Then installed php7.2-curl, restarted apache2 without an issue.

You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution

Related

While installing php7.3 it shows "Unable to locate package php7.3-fpm"

While installing php-fpm it shows an error:
E: Unable to locate package php7.3
E: Unable to locate package php7.3-fpm
Please tell me, how to solve this issue.
I am using Ubuntu 16.04 LTS server.
PHP 7.3 may not be available in Ubuntu 16.04 default repo, you need to add third party repo. I have used ondrej repo quiet often and it works great.
Run the below commands:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
You will need sudo permission to run the above commands.

How to add curl on php7.2 and ubuntu 14

I am trying to install curl on my ubunutu 14 server with php 7.2 installed. I run the following command:
sudo apt-get install php7.0-curl
but it gives error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.0-curl
E: Couldn't find any package by regex 'php7.0-curl'
I then tried to resolve this issue by running commands:
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
sudo apt install apache2 libapache2-mod-php7.0 php7.0
But that also end up with same "Couldn't find package" error.
Your Ubuntu distro trusty is too old and those packages aren't available. You will have to build the library from the source by yourself.
Here you can find solution your problem How do I install the ext-curl extension with PHP 7?
Shortly, try to execute
sudo apt-get install php-curl
Also you can use sudo apt-cache search curl which shows you available packages for installation.

Error while installing php 7.2 in ubuntu 17.04

I got this error when run below command
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
Reading state information... Done
E: Unable to locate package php7.2
E: Couldn't find any package by glob 'php7.2'
E: Couldn't find any package by regex 'php7.2'
E: Unable to locate package php7.2-common
E: Couldn't find any package by glob 'php7.2-common'
E: Couldn't find any package by regex 'php7.2-common'
E: Unable to locate package php7.2-cli
E: Couldn't find any package by glob 'php7.2-cli'
E: Couldn't find any package by regex 'php7.2-cli'
E: Unable to locate package php7.2-fpm
E: Couldn't find any package by glob 'php7.2-fpm'
E: Couldn't find any package by regex 'php7.2-fpm'
You need to manually add the ondrej PPA to be able to install PHP7.2 on Ubuntu 17.
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
Or, by compiling it from the source by cloning the git repository, checking out the version that you want, make & make install
For more informations about compiling PHP from the source check out how to build/compile PHP from the source.
I had a similar problem.
This page helped me resolve it.
https://tecadmin.net/install-php-debian-9-stretch/
specifically, running these commands prior to the php install
sudo apt install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
Completely remove ALL versions of PHP
sudo apt-get purge 'php*'
Force update from unsigned repository:
Add this option in your sources.list (located at /etc/apt/sources.list):
deb [trusted=yes] https://deb.sury.org/ stretch main
Upgrade the current packages to the latest version:
sudo apt update
sudo apt upgrade
Install the required packages first on your system:
sudo apt install ca-certificates apt-transport-https
Then import packages signing key:
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
After that configure PPA for the PHP packages on your system:
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
Lastly, use one of the below options to install PHP of your requirements:
For installing PHP 7.2
sudo apt install php7.2-cli
For installing PHP 7.1
sudo apt install php7.1-cli
In my case a newer php was installed (7.4), so i just replaced the command with the 7.4 versions
sudo apt install php7.4 php7.4-common php7.4-cli php7.4-fpm
to know the version of php installed, use:
php --version
If you getting error like php7.2 php7.2-curl doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution

Unable to locate package libapache2-mod-php7

I tried installing php in ubuntu 16.04 using following command:
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7
but it says
Unable to locate package libapache2-mod-php7
Should I skip this or install by an alternative way?
The name of the package is libapache2-mod-php7.0
Try again by having that .0 at the end and it should work.
On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.
sudo add-apt-repository ppa:ondrej/php
Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/
If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.
sudo apt-get install php7.1
At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version.
So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed.
In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.
sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server
It installed php 7.1 and all of the correct dependencies.
So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.
It is likely the case that your local package index is not updated; try
sudo apt-get update
and then run the previous command again.
As an aside, there is now a program apt that is supposedly more user-friendly than apt-get, apt-cache etc. (see this question on Ask Ubuntu). So your commands could have been replaced by
sudo apt update
sudo apt install <the packages>
to get a slightly nicer user interface.
Probably this question would have been better suited to the Ask Ubuntu community.
Apache server can't start because libapache2-mod-php7.0 is not installed:
by default aptitude or apt install php7.0-common version 7.8.13 which is not adaptable and libapache2-mod-php need 7.0.8
remove php-common
download http://packages.ubuntu.com/xenial/php7.0-common deb package and install it if it compains about php7.0-json, readline,cli,opache
then seatch in upper textbox about those library and install them in this manner
json
opach
cli
readline
install libapache2-mod-php7.0
RESTART APACHE 2
service apache2 restart
it must working probably
Good Luck!
Try for Ubuntu 16.04:
sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql <other packages>;
for Ubuntu 14.04:
sudo apt-get update;
sudo apt-get install php5-mysql php5-mysql <other packages>;
It should be:
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install libapache2-mod-php7.1
worked for me (16.04Ubuntu).
If you getting error like php7.2 php7.2-curl libapache2-mod-php doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution
Looks like we need to install the same version of libapache2-mod-php as the version of php present .I had php 7.4 installing libapache2-mod-php7.4 solved the problem.Thanks
just test upper versions of php
for example run:
sudo apt-get install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.0 libapache2-mod-php7.4

Ubuntu Server Installing PHP 7 WITHOUT Apache

I'm trying to get my server re-setup as a Lemp stack
The issue I am now running into is installing PHP 7 without Apache, since nGinx will be my webserver.
So, I've added ppa:ondrej/php. ran apt-get update, and tried to install just php7.0 via apt-get install php7.0
--nodeps flag does not work, as I am on Ubuntu 15.10
And I am presented with:
The following extra packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
Suggested packages:
apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear
php-user-cache
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
I do not want apache anywhere near my server, so how can I install php7 without it? Short of compiling from source (as this makes it difficult at best to keep it updated)
If you just request php7.0, it'll install Apache as default. Do apt-get install php7.0-fpm and it'll install as FPM instead, leaving something like nginx up to you.
Use the command:
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
It will require the php7.2 dependencies in strict mode (WITHOUT apache2).
On Ubuntu 18.04 I managed to do this successfully with:
sudo apt-get install php7.2-cli
In Ubuntu 20.04, php 7.4 is the default.
Thus, without adding any PPAs, all you need is
apt install php-fpm
This will bring in a few libraries, including php-cli, but NO apache-related things.
With the following steps you can install any PHP version you want, just replace 7.4 with your desired version.
Also I am suggesting to install the cli package because I assume you dont want to have fpm installed. Otherwise you can install php7.4-fpm instead.
Install ppa:ondrej/php repositories
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Install PHP
sudo apt install php7.4-cli
You will get the following:
The following additional packages will be installed:
php-common php7.4-common php7.4-json php7.4-opcache php7.4-readline

Categories