package apache2 2.4.52-1ubuntu4.7 failed to install/upgrade: installed apache2 package post-installation script subprocess returned error exit status 1 - Crash on "do-release-upgrade" from Ubuntu 20.04 to Ubuntu 22.04

Bug #2056662 reported by Dan Ran

This bug report will be marked for expiration in 15 days if no further activity occurs. (find out why)

This bug affects 1 person
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)

Bug Description

I am upgrading my Ubuntu 20.04 LEMP server, that DOES NOT have apache2 installed. Instead it uses Nginx Mainline from the official Nginx Repository. After running the command "do-release-upgrade" on Ubuntu 20.04 Server, somehow the upgrade seemed to try to install the apache2 package, but the upgrade was broken.

Here is my server information:
Hardware: Raspberry Pi 4 (aarch64)
OS: Ubuntu 20.04 Server, currently upgrading to Ubuntu 22.04 Server
Software: Linux, Nginx Mainline, MariaDB 10.10.7, PHP7.4-fpm, Postfix, Dovecot

sudo service --status-all

 [ + ] amavis
 [ - ] amavis-mc
 [ - ] amavisd-snmp-subagent
 [ - ] amplify-agent
 [ + ] apparmor
 [ + ] apport
 [ + ] atd
 [ + ] binfmt-support
 [ + ] clamav-daemon
 [ + ] clamav-freshclam
 [ - ]
 [ + ] cron
 [ - ] cryptdisks
 [ - ] cryptdisks-early
 [ + ] dbus
 [ + ] dovecot
 [ - ] dphys-swapfile
 [ + ] fail2ban
 [ - ] gdomap
 [ - ]
 [ + ] irqbalance
 [ - ] iscsid
 [ - ]
 [ + ] kmod
 [ - ] lvm2
 [ - ] lvm2-lvmpolld
 [ + ] mariadb
 [ + ] mono-xsp4
 [ + ] multipath-tools
 [ + ] mysql
 [ + ] network-manager
 [ - ] nginx
 [ - ] nginx-debug
 [ - ] open-iscsi
 [ + ] opendkim
 [ + ] opendmarc
 [ + ] php7.4-fpm
 [ - ] plymouth
 [ - ] plymouth-log
 [ + ] policyd-rate-limit
 [ + ] postfix
 [ + ] postgrey
 [ - ] pppd-dns
 [ + ] procps
 [ + ] redis-server
 [ - ] resolvconf
 [ - ] rsync
 [ + ] rsyslog
 [ + ] spamass-milter
 [ + ] spamassassin
 [ + ] ssh
 [ + ] tlp
 [ + ] udev
 [ + ] ufw
 [ + ] unattended-upgrades
 [ + ] unbound
 [ - ] uuidd
 [ - ] x11-common

DISABLE EVERYTHING and SET UP in one command:
sudo systemctl disable cron \
sudo systemctl disable amavis \
sudo systemctl disable amplify-agent \
sudo systemctl disable atd \
sudo systemctl disable clamav-daemon \
sudo systemctl disable clamav-freshclam \
sudo systemctl disable dovecot \
sudo systemctl disable fail2ban \
sudo systemctl disable irqbalance \
sudo systemctl disable kmod \
sudo systemctl disable mono-xsp4 \
sudo systemctl disable nginx \
sudo systemctl disable opendkim \
sudo systemctl disable opendmarc \
sudo systemctl disable php7.4-fpm \
sudo systemctl disable postfix \
sudo systemctl disable postgrey \
sudo systemctl disable redis-server \
sudo systemctl disable smbd \
sudo systemctl disable nmbd \
sudo systemctl disable spamass-milter \
sudo systemctl disable spamassassin \
sudo systemctl disable tlp \
sudo systemctl disable unbound \
sudo systemctl disable create-cacheram-folders.service \
sudo systemctl disable webmin.service \
sudo systemctl disable <email address hidden> \
sudo systemctl disable dphys-swapfile \
sudo systemctl disable netdata \
sudo systemctl disable policyd-rate-limit \
sudo systemctl restart sshd \
sudo service ssh restart \
sudo apt purge phpmyadmin mono-xsp4 nginx-agent \
sudo apt autoremove \
sudo apt-mark unhold nginx \
sudo apt install screen \
screen \
sudo apt update \
sudo apt dist-upgrade \
sudo apt install update-manager-core \

Below is all of the rest of the information that I have on this error.

Files have not changed, Decompression not needed
Exception during pm.DoInstall(): E:Sub-process /usr/bin/dpkg returned an error code (1)

*** Send problem report to the developers?

After the problem report has been sent, please fill out the form in the
automatically opened web browser.

What would you like to do? Your options are:
  S: Send report (836.5 KB)
  V: View report
  K: Keep report file for sending later or copying to somewhere else
  I: Cancel and ignore future crashes of this program version
  C: Cancel
Please choose (S/V/K/I/C): S

*** Collecting problem information

The collected information can be sent to the developers to improve the
application. This might take a few minutes.
*** The contents of your /etc/apache2/sites-enabled/ directory may help developers diagnose your bug more quickly. However, it may contain sensitive information. Do you want to include it in your bug report?

What would you like to do? Your options are:
  Y: Yes
  N: No
  C: Cancel
Please choose (Y/N/C): Y

The collected information is being sent to the bug tracking system.
This might take a few minutes.

*** To continue, you must visit the following URL:

That is all I've got.

ProblemType: Package
DistroRelease: Ubuntu 22.04
Package: apache2 2.4.52-1ubuntu4.7
ProcVersionSignature: Ubuntu 5.4.0-1104.116-raspi 5.4.265
Uname: Linux 5.4.0-1104-raspi aarch64
000-default.conf: Error: [Errno 40] Too many levels of symbolic links: '/etc/apache2/sites-enabled/000-default.conf'
Apache2ConfdDirListing: False

ApportVersion: 2.20.11-0ubuntu82.5
Architecture: arm64
CasperMD5CheckResult: unknown
CloudArchitecture: aarch64
CloudID: nocloud
CloudName: unknown
CloudPlatform: nocloud
CloudSubPlatform: config-disk (/dev/sda1)
Date: Sat Mar 9 23:53:15 2024
ErrorMessage: installed apache2 package post-installation script subprocess returned error exit status 1
Python3Details: /usr/bin/python3.10, Python 3.10.12, python3-minimal, 3.10.6-1~22.04
PythonDetails: N/A
RebootRequiredPkgs: Error: path contained symlinks.
 dpkg 1.21.1ubuntu2.3
 apt 2.4.11
SourcePackage: apache2
Title: package apache2 2.4.52-1ubuntu4.7 failed to install/upgrade: installed apache2 package post-installation script subprocess returned error exit status 1
UpgradeStatus: Upgraded to jammy on 2024-03-10 (0 days ago)

Revision history for this message
Dan Ran (danrancan) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Dan Ran (danrancan) wrote :

I forgot one thing. Before I did the release upgrade, I also stopped all of the services that I disabled with the following one liner:

sudo systemctl stop cron \
sudo systemctl stop amavis \
sudo systemctl stop amplify-agent \
sudo systemctl stop atd \
sudo systemctl stop clamav-daemon \
sudo systemctl stop clamav-freshclam \
sudo systemctl stop dovecot \
sudo systemctl stop fail2ban \
sudo systemctl stop irqbalance \
sudo systemctl stop kmod \
sudo systemctl stop mono-xsp4 \
sudo systemctl stop nginx \
sudo systemctl stop opendkim \
sudo systemctl stop opendmarc \
sudo systemctl stop php7.4-fpm \
sudo systemctl stop postfix \
sudo systemctl stop postgrey \
sudo systemctl stop redis-server \
sudo systemctl stop smbd \
sudo systemctl stop nmbd \
sudo systemctl stop spamass-milter \
sudo systemctl stop spamassassin \
sudo systemctl stop tlp \
sudo systemctl stop unbound \
sudo systemctl stop create-cacheram-folders.service \
sudo systemctl stop webmin.service \
sudo systemctl stop <email address hidden> \
sudo systemctl stop dphys-swapfile \
sudo systemctl stop netdata \
sudo systemctl stop policyd-rate-limit

Then I proceeded with the Release upgrade.

Revision history for this message
Dan Ran (danrancan) wrote :

Not sure why apache2 is getting installed on a LEMP server by default when Nginx is already installed. Can anyone explain this?

Revision history for this message
Dan Ran (danrancan) wrote :

Finally after hitting Cancel on the "Open a browser in terminal" option (since I already filed the bug report in my desktop browser), I get the following message/errors:

The upgrade has aborted. Your system could be in an unusable state. A
recovery will run now (dpkg --configure -a).

Setting up apache2 (2.4.52-1ubuntu4.7) ...
info: Executing deferred 'a2enconf javascript-common' for package javascript-common
ERROR: Conf javascript-common does not exist!
dpkg: error processing package apache2 (--configure):
 installed apache2 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
Starting upgrade of Ubuntu Pro service configuration
Finished upgrade of Ubuntu Pro service configuration

Upgrade complete

The upgrade has completed but there were errors during the upgrade

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Hi Dan,

Thanks for reporting this issue and help making Ubuntu better.

I could you give us more details on your nginx installation?

Is that a deb package? If so, could you provide more details on that package (e.g., apt info output, where did you get the package, etc)?

I am interested in understanding if that package also
Provides: httpd, httpd-cgi.

Do note that using nginx from a third party is not a supported use case here, but it would be nice to fully understand what is pulling apache2 there and why (my first guess would be that something is requiring httpd and that nginx package you are installing does not provide it).

I am setting the status of this bug to incomplete. Please, move it back to new once you provide the requested information.

Changed in apache2 (Ubuntu):
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.