OCC doesn't work

[EDIT: Fixed typo]

Nextcloud version (eg, 20.0.5): 25.0.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04 (Snap free)
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.1.2

The issue you are facing:
When I try and run an OCC command, I get this error:

sudo -u www-data php occ -V

An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

The manual says to run occ as the http user so I ran
sudo -u www-data /usr/bin/php /var/www/html/nextcloud/occ
and got:

Could not open input file: /var/www/html/nextcloud/occ

I also tried
sudo -u www-data /usr/bin/php8.1 /var/www/html/nextcloud/occ
to the same effect.

I must be missing something here.

Thanks in advance!


Is this the first time you’ve seen this error? (Y/N): It’s been there since I installed nextcloud, and was there on previous installations too.

Shouldn’t it be /var/www/html/nextcloud/occ ?

1 Like

Did you resolve the error it reported? And did you run it from the Nextcloud web root folder?

You have a typo in the path.

2 Likes

I had the same issue

solutution is found in the docs Memory caching — Nextcloud latest Administration Manual latest documentation

add apc.enable_cli = 1 to your /etc/php/8.1/cli/php.ini

solves this php cli mssg

1 Like

Yes it should, thanks!

Thanks, I just tried and it got me nowhere, unfortunately

EDIT: Actually, it did take care of that issue. I just had to look again! So at least it got me part of the way :smiley:

user@nextcloud:~$ cd /var/www/
user@nextcloud:/var/www$ sudo -u www-data /usr/bin/php /var/www/html/nextcloud/occ

[sudo] password for user:
Could not open input file: /var/www/html/nextcloud/occ

And thanks for spotting the typo!

Update: I found a web app for OCC so I went ahead and installed it.

I was perfectly able to run commands through the interface (which is a terminal-like interface that runs inside of NC). The only issue I had was that I had to edit the .conf file to exit out of maintenance mode.

So I guess the problem of not being able to run OCC commands has been partially solved. Frankly, I’d rather run them in my own terminal, so if anyone has an idea of why this is happening, I’d be happy to hear about it.

EDIT: Turns out the web app isn’t happy about running db:convert-filecache-bigint which is one reason I’m trying to make occ work, in the first place :-/

Thanks for your replies so far!

If the web OCC works (can execute the OCC command) you have errors in your CLI.

I could execute some commands, while others returned something like: “[Object] [Object]”.

If you have an idea of how to fix the CLI, I’d be happy to hear it.

if you are using php7.x-fpm add apc.enable_cli=1 to /etc/php/7.x/mods-available/apcu.ini

solved it for me you can see if it works for 8.1

source Memcache \OC\Memcache\APCu not available for local cache · Issue #2039 · nextcloud/vm · GitHub

Yeah, I’m on 8.1, and your suggestion did remove the MemCache APCu error message, but didn’t solve the overall issue of not being able to use occ commands from the command line.

Notice i’m pointing to another file then the earlier post.

this time set it systemwide in /etc/php/8.1/mods-available/apcu.ini

sorry i see now you have another issue

Do you have any idea how to identify the errors or fix them?

Thanks!

You will need to config memcache for PHP CLI aswell as the one used by your webserver. For example: I am using PHP8.1-FPM but for CLI, the “normal” PHP (PHP8.1) Library is needed. So I has to maintain two different php.ini config files.

OCC runs and executes PHP command Line and not by an application server (like Apache2).

1 Like

Thanks, I’ll give it a go.