Danilo's picture

Hello friends, I need to give a command in nextcloud , but it doesn't work! File upload is very slow in windows app, and this command seems to solve. But on turnkey image does not work. Any idea? Thanks


sudo -u www-data php occ config:app:set files max_chunk_size --value 0
Jeremy Davis's picture

As of v16.1 TurnKey Nextcloud includes a 'turnkey-occ' command (a simple wrapper around 'occ'). If you aren't on v16.1, then you can download it (and make it executable) like this:

wget -O /$FILE $URL/$FILE
chmod +x /$FILE

Then you can use it instead of 'occ'. I.e to run the command you noted, this should work:

turnkey-occ config:app:set files max_chunk_size --value 0

Alternatively, if you'd rather use occ directly, you can use 'su', like this:

cd /var/www/nextcloud
su - www-data -s /bin/bash -c "php occ config:app:set files max_chunk_size --value 0"

Or finally, if you'd rather use 'sudo', install it first:

apt update
apt install -y sudo

Then you should be able to use it as per your original post.

If you continue to have issues, please post the appliance version you are using (if unsure, post the output of 'turnkey-version'), where it's running and any error messages you are seeing.

Chris_A's picture

If you face issues with turnkey-occ reporting :

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

this most probably comes from the nextcloud apache2 server using php8.1 whereas the php command points to the 8.2 version. Both versions configs can be seen under /etc/php/[8.1,8.2]. It turns out that the 8.1 version includes an apache2 subdirectory containing some php init files that happen to have differences with the standard php.ini of the 8.2 version (I could not find what was the exact issue though...).

In order to get occ to be launched using the same config and version of php as for the nexcloud sever, it is necessary to edit (nano) the turnkey-occ script under /usr/local/bin and just change php command:

#COMMAND="/usr/bin/php $OCC $@"
COMMAND="/usr/bin/php8.1 $OCC $@"

This will allow running the occ command with the same config as the nextcloud/apache2 server and get rid of this driver not found issue.

Hope this helps as it took me several hours to understand this while I was dumb enough to lose my login passwords for both the nextcloud admin and user accounts...

Jeremy Davis's picture

Hi Chris. Thanks for posting.

BTW, if you want to sign up for an account (so you don't need to wait for me to approve your future posts) please do so. Then let me know that you are waiting for approval. Do that either by noting it in a reply here, or over on the relevant thread, or shoot me an email to support AT turnkeylinux.org.

Whilst what you did obviously works and strictly speaking, there's absolutely nothing wrong with it, probably the "proper" way to resolve that is to update the version of PHP that /usr/bin/php points to. As you're using php8.1 as the PHP version for Apache, I would argue that the default /usr/bin/php should also be php8.1!

In Debian, whilst many system executables are binary files (i.e. actual programs/commands located in /usr/bin), many of them are actually just symlinks to other (often version specific) commands that provide the same or similar functionality. Which specific command these "generic" commands point to is managed by the "alternatives" system. php (or more correctly /usr/bin/php) is one of those. To view all the real executables available for php (aka /usr/bin/php) on your system, run this:

update-alternatives --list php

And then set the desired one like this (e.g. php8.1):

update-alternatives --set php /usr/bin/php8.1

Or if you'd rather do it interactively, run this:

update-alternatives --config php

Then double check that it worked:

php -v

It should show that it's now php8.1! :)

Add new comment