# Broken Nextcloud after Ubuntu LTS upgrade to php8.1

**URL:** <https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355>\
**Category:** ℹ️ Support\
**Tags:** php8, php81\
**Created:** [April 30, 2022, 8:11am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355 "2022-04-30T08:11:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![egglestn](https://help.nextcloud.com/letter_avatar/egglestn/32/6_22734026db12803ebb3e059622ac3534.png) [@egglestn](https://help.nextcloud.com/u/egglestn)\
**Post date:** [April 30, 2022, 8:11am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/1 "2022-04-30T08:11:30Z")

</div>

Hi  
I have a working Nextcloud 23.0.0.4 on Ubuntu 21.10, However I was recently nagged into upgrading to Ubuntu LTS 22.04 LTS  
Upgrade went smoothly, but it appears that php8.1 has been installed, and 8.0 is required. I have tried to manually downgrade to 8.0, Google is all worked out, but I keep hitting dependency problems.  
Does anyone know of a step by step downgrade tutorial that can help me downgrade php8.1 to 8.0… I have tried grepping 8.1 removing each package, and replacing with the same 8.0 package…but this feels inelegant, and frankly isn’t working and I am afraid i am going to end up with a system littered with junk  
Any help would be valuable  
Cheers  
Richard

---

<div class="post-metadata">

**Author:** ![anon75456558](https://help.nextcloud.com/letter_avatar/anon75456558/32/6_22734026db12803ebb3e059622ac3534.png) [@anon75456558](https://help.nextcloud.com/u/anon75456558)\
**Post date:** [April 30, 2022, 2:23pm UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/2 "2022-04-30T14:23:19Z")

</div>

> [@egglestn](#):
>
> Does anyone know of a step by step downgrade tutorial that can help me downgrade php8.1 to 8.0…

Yes, try searching for how to do this on the forum. You’ll find the answer.

[You are missing the required support template. Please fill this form out](https://help.nextcloud.com/t/support-template-please-use-this-when-you-request-support/137402) and edit into your post.

This will give us the technical info and logs needed to help you! Thanks.

---

<div class="post-metadata">

**Author:** ![egglestn](https://help.nextcloud.com/letter_avatar/egglestn/32/6_22734026db12803ebb3e059622ac3534.png) [@egglestn](https://help.nextcloud.com/u/egglestn)\
**Post date:** [May 1, 2022, 9:41am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/3 "2022-05-01T09:41:56Z")

</div>

I have struggled to find a step by step way of doing this, however having taken ages I have managed it. For any other newbies this is how I did it, and got a working system.  
Is it perfect? No  
Is it Elegant? No  
Did it work for me? Yes  
If you have updated Ubuntu 21.10 to 22.4 without realising it will break nextcloud I hope this helps  
Obviously YMMV and I have no idea what will happen with the next upgrade, but lets cross that bridge when we get there 😀  
Regards  
Richard

Remove PHP 8.1  
`sudo apt-get purge php8.1-apcu php8.1-bcmath php8.1-cli php8.1-common php8.1-curl php8.1-fpm php8.1-gd php8.1-gmp php8.1-igbinary php8.1-imagick php8.1-intl php8.1-ldap php8.1-mbstring php8.1-memcached php8.1-msgpack php8.1-mysql php8.1-opcache php8.1-phpdbg php8.1-readline php8.1-redis php8.1-xml php8.1-zip`  
Clean up any odds & sods missed  
`sudo apt-get purge php8.1 && sudo apt-get autoclean && sudo apt-get autoremove`  
Add Repository for PHP 8.0 and update packages

```auto
sudo add-apt-repository ppa:ondrej/php
sudo apt update

```

Install PHP 8.0  
`sudo apt-get install php8.0`  
Install required modules (done in two steps, some duplication)

```auto
sudo apt install php8.0 libapache2-mod-php8.0 php8.0-mysql php-common php8.0-cli php8.0-common php8.0-json php8.0-opcache php8.0-readline
sudo apt install imagemagick php-imagick libapache2-mod-php8.0 php8.0-common php8.0-mysql php8.0-fpm php8.0-gd php8.0-curl php8.0-zip php8.0-xml php8.0-mbstring php8.0-bz2 php8.0-intl php8.0-bcmath php8.0-gmp

```

Start Apache2  
`sudo systemctl start apache2`  
Viola

---

<div class="post-metadata">

**Author:** ![Vincent\_Stans](https://help.nextcloud.com/user_avatar/help.nextcloud.com/vincent_stans/32/17415_2.png) [@Vincent\_Stans](https://help.nextcloud.com/u/Vincent_Stans)\
**Post date:** [May 1, 2022, 9:52am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/4 "2022-05-01T09:52:43Z")

</div>

There is no need to remove php 8.1 you can have multiple php versions installed side by side.

php requirements [https://docs.nextcloud.com/server/latest/admin\_manual/installation/source\_installation.html#prerequisites-label](https://docs.nextcloud.com/server/latest/admin_manual/installation/source_installation.html#prerequisites-label)  
after you have installed libapache2-mod-php8.0 and all php8.0 modules you want you can set your preferred php version like so

`sudo update-alternatives --config php`  
`sudo a2dismod php8.1`  
`sudo a2enmod php8.0`

---

<div class="post-metadata">

**Author:** ![egglestn](https://help.nextcloud.com/letter_avatar/egglestn/32/6_22734026db12803ebb3e059622ac3534.png) [@egglestn](https://help.nextcloud.com/u/egglestn)\
**Post date:** [May 1, 2022, 10:25am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/5 "2022-05-01T10:25:14Z")

</div>

Thank you for that clarification… I am not an IT professional, and this makes things much more elegant.  
Can I assume that I could reinstall 8.1, set as per the code and when Nextcloud 24 comes along switch to 8.1 seamlessly, or is there a gotcha?

---

<div class="post-metadata">

**Author:** ![Vincent\_Stans](https://help.nextcloud.com/user_avatar/help.nextcloud.com/vincent_stans/32/17415_2.png) [@Vincent\_Stans](https://help.nextcloud.com/u/Vincent_Stans)\
**Post date:** [May 2, 2022, 1:53am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/6 "2022-05-02T01:53:02Z")

</div>

yes you can have 8.1 installed ready for NC24

just do

```auto
sudo update-alternatives --config php
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo apache2ctl restart

```

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [May 2, 2022, 6:55am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/7 "2022-05-02T06:55:12Z")

</div>

NC 24 is about to be release this week and is compatible with php 8.1. I wouldn’t fiddle around installing other versions, if you want to start right now, there is already the release candidate that can be installed, it should be similar or very similar to the final release and you can easily upgrade.

---

<div class="post-metadata">

**Author:** ![thomaslp](https://help.nextcloud.com/user_avatar/help.nextcloud.com/thomaslp/32/2012_2.png) [@thomaslp](https://help.nextcloud.com/u/thomaslp)\
**Post date:** [August 22, 2022, 5:38am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/8 "2022-08-22T05:38:34Z")

</div>

when upgraded from the previous LTS to ubuntu LTS 22.04 my nc server stopped working. i assume i was on nc 24 (latest stable as of last week).

this is the error i get:

```auto
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.4.load: Can't locate API module structure `php7_module' in file /usr/lib/apache2/modules/libphp8.0.so: /usr/lib/apache2/modules/libphp8.0.so: undefined symbol: php7_module
Action 'restart' failed.
The Apache error log may have more information.

```

any clues as to where i should start? it seems i have both 7.4.load and 8.1.load in …/mods-enabled/  
i may be totally off here, but does apache somewhere still search for 7.4 instead of 8.1, and that’s the file that needs to be updated?

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [August 22, 2022, 6:33am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/9 "2022-08-22T06:33:48Z")

</div>

> [@thomaslp](#):
>
> both 7.4.load and 8.1.load

The 7.4 version is probably from the previous version. Remove the 7.4 version from mods-enabled.

```auto
sudo a2dismod php7.4

```

---

<div class="post-metadata">

**Author:** ![thomaslp](https://help.nextcloud.com/user_avatar/help.nextcloud.com/thomaslp/32/2012_2.png) [@thomaslp](https://help.nextcloud.com/u/thomaslp)\
**Post date:** [August 22, 2022, 2:24pm UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/10 "2022-08-22T14:24:58Z")

</div>

thank you. that simple command solved it for me and nextcloud is up and running again.

- ubuntu LTS 22.04, upgraded from ubuntu LTS 20.4.
- php version 8.1.

---

<div class="post-metadata">

**Author:** ![koala3439](https://help.nextcloud.com/letter_avatar/koala3439/32/6_22734026db12803ebb3e059622ac3534.png) [@koala3439](https://help.nextcloud.com/u/koala3439)\
**Post date:** [October 27, 2022, 2:53am UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/11 "2022-10-27T02:53:29Z")

</div>

Thanks, this fixed my issue with nextcloud 25 after upgrading to Ubuntu 22.04 LTS

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 13, 2024, 2:11pm UTC](https://help.nextcloud.com/t/broken-nextcloud-after-ubuntu-lts-upgrade-to-php8-1/138355/12 "2024-12-13T14:11:16Z")

</div>


