hestiacp / hestiacp

Hestia Control Panel | A lightweight and powerful control panel for the modern web.
https://hestiacp.com
GNU General Public License v3.0
3.4k stars 680 forks source link

[BUG] v-delete-web-php x.x - does not remove all php packages for specified version #1794

Open johnnyq opened 3 years ago

johnnyq commented 3 years ago

Describe the bug Attempted to remove 5.6, 7.0, 7.1, 7.2, 7.3 php packages via command line using v-delete-web-php x.x where x.x is the version. It removes most packages but leaves some behind. When removing did not receive any errors. NOTE: Do not include any personal or sensitive information, such as email addresses or passwords.

To Reproduce What steps did you take when the issue occured?

  1. As root v-add-web-php 5.6
  2. v-delete-web-php 5.6
  3. apt list --installed | grep php5.6

Expected behavior Should remove all packages related to that PHP version

Screenshots Using php5.6 as one example

Packages installed after v-add-web-php 5.6

php5.6-bcmath/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-bz2/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-cli/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-common/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic] php5.6-curl/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-fpm/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-gd/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-imagick/focal,now 3.4.4+php8.0+3.4.4-7+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-imap/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-intl/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-json/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-ldap/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-mbstring/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-mcrypt/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-mysql/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-opcache/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic] php5.6-pgsql/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-pspell/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-readline/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic] php5.6-soap/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-xml/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-zip/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]

Packages left after Removing using v-delete-web-php 5.6

php5.6-common/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic] php5.6-imagick/focal,now 3.4.4+php8.0+3.4.4-7+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-imap/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-ldap/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-opcache/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic] php5.6-pgsql/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed] php5.6-readline/focal,now 5.6.40-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,auto-removable]

Operating system: Ubuntu 20.04.2

Hestia Control Panel version: 1.3.5

Additional context Seems to happen on two instances, not sure if its affecting anyone else. Also in the meantime would it be okay to remove them manually using the command apt remove --purge php5.6*

johnnyq commented 3 years ago

I tryed this on my test platform as well using Ubuntu 20.04.2 and Hestia 1.4Beta and get the same result

ScIT-Raphael commented 3 years ago

Whats the output of apt autoremove? Probaly left over dependcies.

johnnyq commented 3 years ago

Hi @ScIT-Raphael I will try on both Hestia platforms and return shortly with the output

johnnyq commented 3 years ago

Here is the output for the command apt autoremove

root@web01:~# apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  php5.6-readline
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 69.6 kB disk space will be freed.
Do you want to continue? [Y/n]

it looks like it only found 1 leftover dependency

johnnyq commented 3 years ago

Here is example for php7.0 on my hestia 1.4beta platform

Install php 7.0

v-add-web-php 7.0

List Installed php7.0 packages

apt list --installed | grep php7.0-*

php7.0-bcmath/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-bz2/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-cli/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-common/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-curl/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-fpm/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-gd/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-imagick/focal,now 3.4.4+php8.0+3.4.4-7+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-imap/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-intl/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-json/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-ldap/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-mbstring/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-mcrypt/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-mysql/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-opcache/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-pspell/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-readline/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-soap/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-xml/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-zip/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]

Remove php 7.0

v-delete-web-php 7.0

List packages for php 7.0 (Note these were not removed)

apt list --installed | grep php7.0-*

php7.0-common/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-imagick/focal,now 3.4.4+php8.0+3.4.4-7+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-imap/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-ldap/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php7.0-opcache/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-readline/focal,now 7.0.33-50+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,auto-removable]

apt autoremove Output

root@web01:~# apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  php7.0-readline
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 139 kB disk space will be freed.
Do you want to continue? [Y/n]

maybe phpx.x-readline package might be holding up the script causing it not to remove all php dependencies

ScIT-Raphael commented 3 years ago

Sounds like dependencies: Currently we remove the packages, we also install over v-add-web-php. What happens if you run apt remove php5.6*?

We could replace the removal part with that string, so we would prevent leftover packages.

johnnyq commented 3 years ago

good idea @ScIT-Raphael , although should a --purge be added to the apt remove command so it removes the config files too?

ScIT-Raphael commented 3 years ago

Purge could be added aswell, yes.

johnnyq commented 3 years ago

that did the trick no problems after

The following packages will be REMOVED:
  php5.6-common php5.6-imagick php5.6-imap php5.6-ldap php5.6-opcache php5.6-readline
0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
After this operation, 5764 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 42718 files and directories currently installed.)
Removing php5.6-readline (5.6.40-50+ubuntu20.04.1+deb.sury.org+1) ...
Removing php5.6-opcache (5.6.40-50+ubuntu20.04.1+deb.sury.org+1) ...
Removing php5.6-imagick (3.4.4+php8.0+3.4.4-7+ubuntu20.04.1+deb.sury.org+1) ...
Removing php5.6-imap (5.6.40-50+ubuntu20.04.1+deb.sury.org+1) ...
Removing php5.6-ldap (5.6.40-50+ubuntu20.04.1+deb.sury.org+1) ...
Removing php5.6-common (5.6.40-50+ubuntu20.04.1+deb.sury.org+1) ...
johnnyq commented 3 years ago

I attempted this on one of my production platforms thats running 20.04.2 and Hestia 1.3.5 The removal via apt purge phpx.x worked well for

but 7.3 it threw some red flags so I chose not to continue

apt purge php7.3-* Output

The following packages were automatically installed and are no longer required:
  dbconfig-common dbconfig-mysql icc-profiles-free libjs-openlayers libjs-sphinxdoc libjs-underscore php-google-recaptcha php-phpmyadmin-motranslator
  php-phpmyadmin-shapefile php-phpmyadmin-sql-parser php-phpseclib php-psr-cache php-psr-container php-psr-log php-symfony-cache php-symfony-cache-contracts
  php-symfony-expression-language php-symfony-service-contracts php-symfony-var-exporter php-tcpdf php-twig php-twig-extensions php7.4-imagick
  php7.4-opcache
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser ufw
The following packages will be REMOVED:
  php7.3* php7.3-apcu* php7.3-apcu-bc* php7.3-bcmath* php7.3-bz2* php7.3-cli* php7.3-common* php7.3-curl* php7.3-fpm* php7.3-gd* php7.3-imagick*
  php7.3-imap* php7.3-intl* php7.3-json* php7.3-ldap* php7.3-mbstring* php7.3-mysql* php7.3-opcache* php7.3-pgsql* php7.3-pspell* php7.3-readline*
  php7.3-soap* php7.3-xml* php7.3-zip* phpmyadmin*
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
0 upgraded, 10 newly installed, 25 to remove and 0 not upgraded.
Need to get 0 B/1848 kB of archives.
After this operation, 41.5 MB disk space will be freed.
Do you want to continue? [Y/n]

it looks like it was going to remove phpmyadmin and apache2 and remove some php7.4 extensions so I aborted

This may need some further research I don't want to do it on a production machine so i'll install 7.3 on my beta 1.4 and then try the removal and see if I get the same result.

johnnyq commented 3 years ago

Okay the beta hestia machine was fine although one note is on my production platform was upgraded to 20.04 from 18.04 about a year ago. Im wondering if that's why im getting some red flags on my production machine when attempting to purge php7.3-*. Ill do a snapshot of my production machine and just give it a whirl I could always revert the snapshot. I will attempt this tonight and report back,

jaapmarcus commented 3 years ago

1.4 Beta does not run phpmyadmin and roundcube from atp any more. That might be an difference

johnnyq commented 3 years ago

@jaapmarcus that makes sense. Although this particular Hestia production machine only runs Nginx with php fpm with no apache. It seems like it wants to also install apache if I remove php 7.3 in which I do not want.

See here

The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0

jaapmarcus commented 3 years ago

Does the server run with modphp enabled. Or did you install the server before 1.1?

johnnyq commented 3 years ago

@jaapmarcus I'm not sure but I do know it was before 1.1

here is my hestia.conf file

root@cloud01:/usr/local/hestia/conf# cat hestia.conf 
WEB_SYSTEM='nginx'
WEB_PORT='80'
WEB_SSL_PORT='443'
WEB_SSL='openssl'
WEB_BACKEND='php-fpm'
STATS_SYSTEM='awstats'
CRON_SYSTEM='cron'
BACKUP_SYSTEM=''
LANGUAGE='en'
RELEASE_BRANCH='release'
API='yes'
DB_SYSTEM='pgsql,mysql'
BACKEND_PORT='8083'
DISK_QUOTA='no'
THEME='dark'
BACKUP_GZIP='9'
UPDATE_HOSTNAME_SSL='yes'
FILE_MANAGER='true'
DB_PMA_ALIAS='phpmyadmin'
UPGRADE_SEND_EMAIL='true'
UPGRADE_SEND_EMAIL_LOG='false'
BACKUP_MODE='zstd'
LOGIN_STYLE='default'
VERSION='1.3.5'
johnnyq commented 3 years ago

Doing some time matching it looks like the server was originally built with 1.0.1 and initial install date for hestia was 2019-06-29. Beyond this time we have just upgraded every single release then eventually we did an ubuntu 18.04 to 20.04 upgrade.

johnnyq commented 3 years ago

I think my issue is an odd case as my other 4 hestia servers do not have this problem when I remove using apt purge php7.3-* the only difference is

johnnyq commented 3 years ago

So I took a snapshot and ran apt purge php7.3- and it installed apache, I rebooted and nginx could not start as apache was runnign so I did a apt purge apache and now websites are working. But it looks like it has removed phppgadmin and phpmyadmin. So I tried to do a apt install --reinstall hestia to get it back but no luck. I may just backup all the sites and create a new VM then restore on the new VM, on the new VM ill keep to close as default as possible

jaapmarcus commented 3 years ago

HestiaCP has no dependencies that require Apache2 or even Nginx so it willl not supprise me that it will no reinstall

johnnyq commented 3 years ago

So disregarding my particular issue which I believe is a one off. The issue that this thread is intended for is to fix the issue with v-delete-web-php X.X not deleting all of the packages associated with that php version and based of @ScIT-Raphael idea of issuing an apt purge phpx.x-* would be the best solution in which I tested on 4 of my other servers and worked flawlessly.

ghost commented 1 year ago

@johnnyq,

Can I get you to please spin up a clean installation of v1.8 and report back what the status is on this issue? Thanks.

jaapmarcus commented 1 year ago

Still present...

It still leaves the user installed one behind...

https://github.com/hestiacp/hestiacp/blob/31aa282c7c90251046d87b7b0a9e46a6e3d73022/bin/v-delete-web-php#L61-L65

johnnyq commented 1 year ago

@krismkenn @jaapmarcus I can confirm still same result