E unable to locate package php cli

Continue on error when apt-get encounters an install unable to locate package issue

I want it to install vim and even if there is an error on abcde just continue to install php5-cli package. Meaning I want apt-get to continue down the list, even if it can not find some of the packages. I’ve tried:

sudo apt-get install --ignore-missing vim abcde php5-cli 

4 Answers 4

Short answer: It is possible that you actually do not want to do this.

Why is that? There has been a lot of discussion on this particular functionality. One such is in this (duplicate)bug report and the one it is linked to.

Discussion at the bug report also explains that «—ignore-missing» only applies if the there is an issue downloading a package that should otherwise exist by the information your ´apt-get´ has. This is also explained here and in the documentation.

Is there a workaround?

If after reading the previous sources you are still very sure you want to do this then, on the other hand, there are (suboptimal but rather safe) options like the one specified by user «Aleksandr Levchuk» here:

for i in package1 package2 package3; do sudo apt-get install $i done 

Or if you prefer then a one-liner with minimal modification:

for i in package1 package2 package3; do sudo apt-get install $i; done 

If there’re a lot of packages, you can add -y so it won’t ask for confirmation repeatedly:

for i in package1 package2 package3; do sudo apt-get install -y $i done 
for i in package1 package2 package3; do sudo apt-get install -y $i; done 

By the way, if you’re someone like me who uses Fish instead of Bash, you’ll first need to type «bash» to switch shells. Then copy and paste the command since for some reason it will not work the Fish shell. Works fine with Bash.

While the other answers do work, performing a separate install call per package has a few issues:

  • It removes a lot of the points/strength of apt and its ability to determine which packages would share dependencies or clash ahead of time
  • If sudo is required (usually), then the sudo timeout can be reached before all packages are installed

Recently I came across this issue as I was moving a personal machine over from one Ubuntu 18.04 (Bionic) install to another newer clean version of Ubuntu 20.04 (Focal), but wanted to install the same packages on the new machine. and I came up with a nice solution:

I started with a file containing a list generated from the old machine, which had each package name on its own separate line, easily generated by the following:

apt list --installed 2>/dev/null | sed 's/\/.*//g > packages' 

I then ran the file list through apt to filter the list down to all packages that were available on the newer machine/repo and that weren’t virtual, while piping the results to another file, echoing the progress, and the ultimately installing the resulting packages:

# Filter packages for those available while read package; do apt show "$package" 2>/dev/null | grep -qvz 'State:.*(virtual)' && echo "$package" >>packages-valid && echo -ne "\r\033[K$package"; done  

Hopefully this finds someone else well. 🙂

One of the best answers, that finally eliminates the extreme overhead of all the other answers saying "just spam the apt install command, repeatedly".

One way to circumvent this is to invoke apt-get once for each package:

echo package1 package2 package3 | xargs -n 1 sudo apt-get install -y 
function install_ignore_fail < echo "$*" | xargs -n 1 sudo apt-get install -y; >install_ignore_fail package1 package2 package3 

I've come up with a function that allows to install a bunch of packages and leave out the ones that are not available and could break the complete install.

install_aval_package() < for i in $1 do if [ -z "$(apt-cache madison $i 2>/dev/null)" ]; then echo " > Package $i not available on repo." else echo " > Add package $i to the install list" packages="$packages $i" fi done echo "$packages" #you could comment this. apt-get -y install $packages > 
install_aval_package "bmon curl dialog git htop language-pack-en-base molly-guard nano net-tools ntp openssh-server software-properties-common ssh sudo wget whiptail bmon curl dialog git htop language-pack-en-base molly-guard nano net-tools ntp openssh-server software-properties-common ssh sudo wget whiptail" 
install_aval_package "bmon \ curl \ dialog \ git \ htop \ language-pack-en-base \ molly-guard \ nano \ net-tools \ ntp \ openssh-server \ software-properties-common \ ssh \ sudo \ wget \ whiptail" 

Where the output in this case have all the requested packages on the repositories,

 > Add package bmon to the install list > Add package curl to the install list > Add package dialog to the install list > Add package git to the install list > Add package htop to the install list > Add package language-pack-en-base to the install list > Add package molly-guard to the install list > Add package nano to the install list > Add package net-tools to the install list > Add package ntp to the install list > Add package openssh-server to the install list > Add package software-properties-common to the install list > Add package ssh to the install list > Add package sudo to the install list > Add package wget to the install list > Add package whiptail to the install list bmon curl dialog git htop language-pack-en-base molly-guard nano net-tools ntp openssh-server software-properties-common ssh sudo wget whiptail bmon curl dialog git htop language-pack-en-base molly-guard nano net-tools ntp openssh-server software-properties-common ssh sudo wget whiptail Reading package lists. Done Building dependency tree Reading state information. Done etc. 

Источник

How install php7.4.11 in ubuntu

I downloaded php-7.4.11.tar.gz for the installation manual, but after extracting and entering make , the following message is displayed in the terminal:

appveyor buildconf config.nice docs libs Makefile.objects php.ini-production sapi TSRM Zend azure buildconf.bat configure ext LICENSE NEWS README.md scripts UPGRADING azure-pipelines.yml CODING_STANDARDS.md configure.ac EXTENSIONS main pear README.REDIST.BINS tests UPGRADING.INTERNALS build config.log CONTRIBUTING.md include Makefile.fragments php.ini-development run-tests.php travis win32 

When I open the php page‍‍ Your Composer dependencies require a PHP version "> = 7.4.11". You are running 7.4.3.

1 Answer 1

In order to have a version of PHP 7.4 greater than 7.4.3, you will need to use Ondřej Surý's PPA. This will give you 7.4.27 if you are running Ubuntu 18.04, 20.04, 21.04, or 21.10. Fortunately, it's not too difficult to do.

WARNING: You need to understand that by following these steps, the web server will be OFFLINE during the PHP version change. You will be uninstalling 7.4.3 and installing 7.4.27, which does take a couple of minutes. If you are doing this on a production machine that does not have any spare for maintenance, your visitors will need to understand the error(s) they see are temporary.

With that out of the way, let's get started.

If you are updating an existing workstation/server:

  1. Open Terminal or connect to the server where you need 7.4.27
  2. Stop Apache:
sudo service apache2 stop 
sudo apt purge `dpkg -l | grep php| awk '' |tr "\n" " "` 

Now that PHP has been removed from the system, let's continue.

Installing Ondřej Surý's version of PHP:

  1. Open Terminal or connect to the server where you need 7.4.27
  2. Ensure Apache is not running:
sudo service apache2 stop 
sudo add-apt-repository ppa:ondrej/php 

Note: While the package states 7.4 , this will give you 7.4.27-1+ubuntu20.04.1+deb.sury.org+1 on 20.04 (as of this writing). Of course, feel free to add any other PHP packages that you may need, but keep in mind that you must specifically specify the major and minor versions for every additional package. For example:

sudo apt install php7.4 php7.4-json php7.4-xml php7.4-mbstring . 
$ php -v PHP 7.4.27 (cli) (built: Nov 25 2021 23:16:22) ( NTS ) Copyright (c) The PHP Group . 
sudo service apache2 start 

Now you're using a fully up-to-date version of PHP 7.4.x, which will receive security updates until November 28, 2022. Hopefully by then there will be a plan for you to upgrade to PHP 8.0 or 8.1.

Источник

I'm unable to install PHP packages for Apache configuration

Sorry about that,this is what I'm getting when attempting to install the following packages, any inputs will be much appreciated.

yael@ypa-ubuntu-server:~$ sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php-apcu php-smbclient php7.2-ldap php-redis php7.2-gd php7.2-xml php7.2-intl php7.2-json php-imagick php7.2-mysql php7.2-cli php7.2-ldap php7.2-zip php7.2-curl [sudo] password for yael: Reading package lists. Done Building dependency tree. Done Reading state information. Done Package libapache2-mod-php7.2 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source Package php-smbclient is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source Package php7.2-common is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Unable to locate package php7.2 E: Couldn't find any package by glob 'php7.2' E: Package 'libapache2-mod-php7.2' has no installation candidate E: Package 'php7.2-common' has no installation candidate E: Unable to locate package php7.2-mbstring E: Couldn't find any package by glob 'php7.2-mbstring' E: Unable to locate package php7.2-xmlrpc E: Couldn't find any package by glob 'php7.2-xmlrpc' E: Unable to locate package php7.2-soap E: Couldn't find any package by glob 'php7.2-soap' E: Package 'php-smbclient' has no installation candidate E: Unable to locate package php7.2-ldap E: Couldn't find any package by glob 'php7.2-ldap' E: Unable to locate package php7.2-gd E: Couldn't find any package by glob 'php7.2-gd' E: Unable to locate package php7.2-xml E: Couldn't find any package by glob 'php7.2-xml' E: Unable to locate package php7.2-intl E: Couldn't find any package by glob 'php7.2-intl' E: Unable to locate package php7.2-json E: Couldn't find any package by glob 'php7.2-json' E: Unable to locate package php7.2-mysql E: Couldn't find any package by glob 'php7.2-mysql' E: Unable to locate package php7.2-cli E: Couldn't find any package by glob 'php7.2-cli' E: Unable to locate package php7.2-ldap E: Couldn't find any package by glob 'php7.2-ldap' E: Unable to locate package php7.2-zip E: Couldn't find any package by glob 'php7.2-zip' E: Unable to locate package php7.2-curl E: Couldn't find any package by glob 'php7.2-curl' 
yael@ypa-ubuntu-server:~$ apt policy php7.2 N: Unable to locate package php7.2 N: Couldn't find any package by glob 'php7.2' yael@ypa-ubuntu-server:~$ apt policy php7.2 N: Unable to locate package php7.2 N: Couldn't find any package by glob 'php7.2' yael@ypa-ubuntu-server:~$ apt policy libapache2-mod-php7.2 libapache2-mod-php7.2: Installed: (none) Candidate: (none) Version table: yael@ypa-ubuntu-server:~$ apt policy php7.2-common php7.2-common: Installed: (none) Candidate: (none) Version table: yael@ypa-ubuntu-server:~$ apt policy php7.2-mbstring N: Unable to locate package php7.2-mbstring N: Couldn't find any package by glob 'php7.2-mbstring' 

Please edit your question and use code formatting, it's unreadable in its current state. Including the output of apt policy [one of the missing packages] would be helpful.

Which version of Ubuntu Server are you installing PHP on? If it’s a recent version, there is no need to specify 7.2. If you specifically need 7.2 and it’s not the default for that Ubuntu installation, that’s a different issue 😬

@OrganicMarble thanks a lot, first time user here if you couldn't tell. I just edited it with your recommendation.

Источник

Читайте также:  Сколько весит двухметровый питон
Оцените статью