# Purge and reinstall PHP

**URL:** <https://help.nextcloud.com/t/purge-and-reinstall-php/165479>\
**Category:** 📦 Appliances (Docker, Snappy, VM, NCP, AIO)\
**Tags:** php, ncp, raspberrypi\
**Created:** [July 4, 2023, 4:38am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479 "2023-07-04T04:38:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 4, 2023, 4:38am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/1 "2023-07-04T04:38:04Z")

</div>

Hi, after going through some troubles during the upgrade process from NC 25.0.3, probably partially caused by a defect sdcard, to NC26.0.1 i have now managed to do a fresh install of Nextcloud on a new card and restore my last Backup of NC 25.0.3 and then update it to NC 26.0.1 i have now a working instance except that cron.php is not working. I have read that i need to reinstall PHP and indeed i have now PHP 8.1 and 8.2 on the system. I would like to clean remove PHP and reinstall the version that comes with the latest NCP image.  
Any hint on how to do this? And what needs to be brought to the PHP NPM folder zo make Nextcloud run again?

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_22734026db12803ebb3e059622ac3534.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [July 5, 2023, 12:32am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/2 "2023-07-05T00:32:34Z")

</div>

If cron is failing, but Nextcloud is otherwise operating, than it’ s probably not because of your PHP version.

If you’re already upgraded to NC26 than you’re already using at least PHP 8.0 (v8.1 I believe if you’re using `ncp-update-nc`).

If you’re running NCP, you should be able to use NCP’s built in update process and not need to mess with upgrading PHP at all on your own unless something gets really messed up.

> [@Staying up to date](https://help.nextcloud.com/t/staying-up-to-date/126259):
>
> It is wise to keep your NCP instance up to date. We’ll explore the update options available from either: ncp-web on port :4443 ncp-config from the command line (cli) / Terminal-UI (TUI). Keep in mind that there are 4 separate parts of NextcloudPi that need updates; Debian (or Raspbian, etc.) - unattended-upgrades NextCloudPi - nc-update-ncp Nextcloud - nc-update-nc Appstore Apps - nc-update-nc-apps What needs updating? Debian Nextcloud NextcloudPi Appstore Apps R…

How did you do the NC26 upgrade?

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 4:28am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/3 "2023-07-05T04:28:59Z")

</div>

Hi, i had done a fresh install of ncp updated ncp, enabled automount, moved the data dir and db dir to the USBdrive then restored my backup, which took way longer than normal, but this might be related to the slower sdcard. After that i did update nc, which also took ages. After that the ncp status page tells me Nextcloud and hpb swrvice is in an error state and my cron.php is obviously not running because news does not get updates.

If i try to run cron php manually i see this:

```auto
Last login: Mon Jul 3 17:02:22 2023 from 10.0.0.154

Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.

gerd@FadeCloud:~ $ sudo -u www-data php -f /var/www/nextcloud/cron.php
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:142
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(264): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(976): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(729): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#21 /var/www/nextcloud/lib/private/Server.php(1110): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#27 /var/www/nextcloud/lib/private/Server.php(2065): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(464): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utilitgerd@FadeCloud:~ $ sudo -u www-data php -f /var/www/nextcloud/cron.php
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:142 Stack trace: #0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(264): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(976): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(729): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#21 /var/www/nextcloud/lib/private/Server.php(1110): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#27 /var/www/nextcloud/lib/private/Server.php(2065): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(464): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()#35 /var/www/nextcloud/lib/private/Server.php(1467): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(623): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1165): OC::init()
#38 /var/www/nextcloud/cron.php(43): require_once('...')
#39 {main}
gerd@FadeCloud:~ $

```

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 4:39am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/4 "2023-07-05T04:39:05Z")

</div>

However, i can use Nextcloud access data also via webdav, create shares and everything, althou uploads are quite slow, i suspect that it uses the sdcard as a temp dir althou the path in …/nextcloud/config/config.php is set to the USBdrive and the path exists.

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 4:44am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/5 "2023-07-05T04:44:31Z")

</div>

What i find strange is that i see a php8.1 and a php8.2 folder in /etc/php/

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 4:49am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/6 "2023-07-05T04:49:59Z")

</div>

Whst i probably did wrong, is to install ncp 1.51.3 and then update it to 1.52.0. My next try would be to do another run from scratch with a 1.53.0 image.

---

<div class="post-metadata">

**Author:** ![Kerasit](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kerasit/32/78080_2.png) [@Kerasit](https://help.nextcloud.com/u/Kerasit)\
**Post date:** [July 5, 2023, 8:51am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/7 "2023-07-05T08:51:59Z")

</div>

You seems to have the same issue as this one:

> [@Nextcloud Cron suddenly is giving an error](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/3):
>
> The only thing that happened on the system was a minor upgrade of PHP8.1x that happened with apt. In addition, I updated nextcloud using the web interface from 26.0.1 to 26.0.3. This happened without errors or issues. In most of the posts, they say it is a DB issue, but the MariaDB is running, and also, some other websites I have that use the DB are running fine. Also, PhpMyAdmin is working fine. I also restarted the system and SQL, and all is running fine. Other than this, I do not really f…

It could be a product thing when two different topics is created on the same issue, and all both has done is updating.

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 2:44pm UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/8 "2023-07-05T14:44:56Z")

</div>

Thanx for the Info, i will keep an eye on that. I had searched for that issue a few days ago and only thing i found was an nc16 related thread with one answer saying that php has to be reinstalled marked as solution…

> [@PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database](https://help.nextcloud.com/t/php-fatal-error-uncaught-doctrine-dbal-dbalexception-failed-to-connect-to-the-database/56782):
>
> I recently upgraded Ubuntu from 16.04 to 18.04LTS and then upgraded Nextcloud to 16.0.3. All the basics are working fine but I’m getting these PHP errors that I think are to do with the PHP version in the CRON job? Does this sound right and, if so, where can I find the hard coded PHP version so I can change it? Many thanks, Cliff PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver in /var/www/ownclo…

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 10, 2023, 10:32am UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/9 "2023-07-10T10:32:06Z")

</div>

Problem is fixed here:

> [@Nextcloud Cron suddenly is giving an error](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/12):
>
> Still i think there might be something wrong with opcache, i would loke to remove 8.2 completely, i wanted to try and install sudo apt install php8.1 php-opcache but this also installed stuff for php 8.2 probably i am holding it wrong? I woukd like to remove php8.2 completely from the system, but it claims php8.2 is not installed…

---

<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 14, 2024, 12:42pm UTC](https://help.nextcloud.com/t/purge-and-reinstall-php/165479/10 "2024-12-14T12:42:18Z")

</div>


