1

I have installed PHP on Ubuntu 22.04 using the command: apt-get install php libapache2-mod-php

When I tried to install a Composer package, I got a message saying

The zip extension and unzip command are both missing, skipping

I took the advice of the top answer to an SO question (PHP error: "The zip extension and unzip command are both missing, skipping.") and ran: apt install zip unzip php-zip. The result of that is shown below:

ubuntu@ip<..>:/var/www/html$ sudo apt install zip unzip php-zip
Reading package lists... Done
Building dependency tree... Done
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:
 php8.1-zip : Depends: php8.1-common (= 8.1.2-1ubuntu2.2) but 8.1.2-1ubuntu2.3 is to be installed
E: Unable to correct problems, you have held broken packages.
ubuntu@ip-<...>:/var/www/html$ php -v
PHP 8.1.2 (cli) (built: Aug 15 2022 12:24:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies
ubuntu@ip-<...>:/var/www/html$

I really have no idea how to react to this. Is there some way I can install php-zip without these dependency related problems?

user3425506
  • 1,285
  • 1
  • 16
  • 26
  • 1
    What does `php -v` says? AKA, what PHP version are you usging? – 0stone0 Sep 06 '22 at 12:28
  • @0stone0 ```PHP 8.1.2 (cli) (built: Aug 15 2022 12:24:10) (NTS) ... ``` – user3425506 Sep 06 '22 at 12:33
  • 1
    It looks like `php8.1-common` is corrupt or missing. – Markus Zeller Sep 06 '22 at 15:22
  • @MarkusZeller I just tried `sudo apt-get install php8.1-common` which resulted in `php8.1-common is already the newest version (8.1.2-1ubuntu2.3)` and `php8.1-common set to manually installed` and `0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded` in the output. I tried --reinstall option but it said php8.1-common could not be downloaded. – user3425506 Sep 06 '22 at 15:35
  • 1
    I would suggest, you look which extensions are already installed and then remove them all by `sudo apt remove "php-8*"` and then reinstall via `sudo apt install php`. – Markus Zeller Sep 06 '22 at 15:38
  • @MarkusZeller At the moment it is quite easy to just provision a new server which I did and this time when I ran `sudo apt install zip unzip php-zip` there were no complaints and I was then able to use Composer to install PHPMailer without any problem. So, I never found out if php8.1-common as you suggested but it sounds quite likely. Thanks for your help – user3425506 Sep 07 '22 at 09:59

0 Answers0