I hope somebody in the community can help me because I have hit a brick wall. Is there anyway the command below can be written in a different way that does not involve using the OCC portion?
I cannot move my Nextcloud v25.0.4 root data folder to my secondary 8TB data drive due to how the OCC portion of the command above generates the Memchache PHP error shown below:
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?)
I am a newbie. So I do not have the needed advanced skills to fix this problem. I would appreciate it a lot if anybody in the community can share step by step instructions on how to fix this specific problem. I am running PHP 8.1.2 and Nextcloud v25.0.4 and Ubuntu Server 22.
Vincent,
I have looked at the link you provided which provides a link to a second website. I read through the various posts and I found none to be helpful due to how none provide a step by step explanation on how to implement the correct fix.
Moreover, to quote your Nov '22 post you say:
"this time set it systemwide in /etc/php/8.1/mods-available/apcu.ini "
Can you elaborate on this with more steps? Is what you say the correct fix I need to follow to fix my Memcache PHP problem? Additionally, do I need to install “php-apcu” onto my Ubuntu Server? Are the “Install php-apcu Using apt-get” steps listed in the link below the correct course of action I should take to fixing my Memcache PHP problem?
Lastly, is there a script I can run that can fix this Memcache PHP problem? Any advice will be greatly appreciated because as I said in the beginning I have hit a brick wall. Thank you for your time.
Kerasit, thank you for your post. To answer you question I used the command shown below to learn what version of Apache I am running:
me@mysrvr:~$ apache2 -v
Server version: Apache/2.4.52 (Ubuntu)
Server built: 2023-03-08T17:32:01
As for CRON it seems I do not need to worry about it because I am running Apache version 2.4.52. Additionally, I am running PHP 8.1.2 and Nextcloud v25.0.4 and Ubuntu Server 22.
Just to confirm, by adding the code below to my php.ini file:
apc.enable_cli = 1
My Ubuntu server should be able to run the Linux command below with no longer generating a Memcache PHP handling error:
In short, if the command above is successful I will finally be allowed to move my NextCloud root data folder to my secondary 8TBdata folder. I will try it out and let everybody know the results I get. Thank you for the advice.
Vincent, thank you for your post. I am going to give Kerasit’s approach a try. If it does not work I will try your approach relating to editing my config.php by changing the ‘maintenance’ => ‘false’, to true.
Thanks for the help. And on a closing note, I am totally perplexed by how complex this task to move my NextCloud root data folder to my secondary 8TBdata drive has become due to these conflicts in the software. The way I understand it the Apache2 and/or PHP software is preventing the OCC maintenance mode command to work. Is this assessment correct?
OCC is a command line tool. It executes on the local host (on the machine where the command is executed) independant on any webserver or not. In fact you could execute OCC commands with no webserver on that machine at all. Apache2 is not blocking you from this.
OCC is a nextcloud library, so it will also be dependant on the nextcloud php files and settings. So yes, you needs to add apc.enable_cli = 1 to the php ini file relevant for handling the machine command line stuff. This USUALLY is the standard php librabry /etc/php/8.1/cli/, but can ALSO be set on the global settings for the PHP engine itself in the master php.ini file. There are in fact several places this can be set. Setting it in /etc/php/8.1/mods-avaiable/apcu.ini ensures that any PHP engine (php system interpretor, PHP-FPM or PHP-CLI - which all uses the same PHP modules installed) will always allow this setting regardless. There is security issues with allowing CLI execution from the PHP engine used by your webserver, as in a rare case there is a vulnerability in nextcloud, it can execute commandline commands in the context of the webserver user. So I highly recommends to set this value ONLY in the CLI php.ini file, as that one is never used by the webserver, but will definately be used by systemcron when setting that up. This, however, is independant on Nextcloud itself, but as a result of Linux+PHP and would be the same issue and case regardless of PHP app.
Try do run this to see what happens: sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --on
To explain:
You asks the Linux host itself to run that OCC command using the default PHP engine it knows based on default environment settings, and you also tells it to - regardless of php.ini files - add the apc.enable_cli=1 in the config it loads. Essentially this enables APCu with that command.
If this is a success, then yes. You will have to add apc.enable_cli=1 at the bottom of the correct .ini file.
Kerasit,
Thank you for your post. Below is the result I got after i executed your posted command line.
me@mysrvr:/$ sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --on
Console has to be executed with the user that owns the file config/config.php
Current user id: 33
Owner id of config.php: 0
Try adding 'sudo -u #0' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u 0' to the docker command (without the single quotes)
Below is the result I got: sudo: option requires an argument -- 'u'
I then Googled the problem and tried the modified command below based on the post below: sudo -u 'www-data' php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --on
My skills are not advanced enough to see what the problem is but here is what does not make sense to me. The command above is defining sudo -u 'www-data' as a user. Isn’t the ‘www-data’ user the correct user to integrate into the command line? Why is it rejecting the use of the ‘www-data’ user?
Below are the steps as I understand them so far:
Step#1: Run command line below. sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --on
Step#2: Add apc.enable_cli = 1 to php ini file located at /etc/php/8.1/cli/. And you also say to addapc.enable_cli=1 at the bottom of the correct .ini file. Can you tell me which one is the correct .ini file?
Step#3: Copy the existing data to it’s new location
sudo -u www-data cp -r /var/www/nextcloud/data/. /mnt/8TBdata/
Step#4: Set your new data location
sudo -u www-data php /var/www/nextcloud/occ config:system:set datadirectory --value=/mnt/8TBdata
Any advice anybody in this forum can offer about this new problem relating to my manually installed Nextcloud will be greatly appreciated. Thank you for your time.
Hold on here. There is something that does not make sense.
Which user runs your webserver? root or www-data?
Try do:
ls -l /var/www/nextcloud
Who owns the Nextcloud library?
Then try do:
ps -aux | grep apache
There should be a couple of processes. But is ANY of them running as www-data?
Are you using php-fpm then you needs to also do:
ps -aux | grep php-fpm
Which user does this run as?
The user who owns the entire Nexctloud library - AND all subfolders and files - HAS to be the one that also executes PHP. If NOT running php-fpm, it most likely is an apache module, hence apache user (usually this is www-data) needs to be the owner. If running php-fpm, it is the user running the php-fpm process. These does not HAVE to be the same, but it is easier (and theorethically only raises risk a fraction) to have it running by the same user.
Kerasit,
Thank you for your post. Below I have posted all three results I got after running your three command lines. I hope the results below helps you in determining what what is preventing me from running the two command line variations shown below which do not work:
You ask which user runs my entire Nexctloud library - AND all subfolders and files? Does the information shown above answer this question for you?
I can tell you the “me” user is my normal Ubuntu Server user account. If I want to access to something at the ROOT level I need to use a special ADMIN password.
I hope you can clarify what you think is the problem with the information I have posted. Thank you for your time.
I forgot to mention i ran Vincent’s commands shown below he previosly posted. So maybe that changed the user owner? However, his OCC command never worked due to a handling error.
setting the user we use
sudo chown www-data:www-data /mnt/8TBdata
setting the file we use
sudo chmod 750 /mnt/8TBdata
But i don’t follow how the config.php file got changed because i have not changed it using NANO txt editor.
Never the less your system reported that the nextcloud config file is not owned på www-data but is owned by root. This has to be changed. My command makes sure that all files in Nextcloud and underneath, is owned by correct user.
www-data also needs to own the data folder and below.
Kerasit,
Sorry, I did not include the following in my last post. Below is the result I got after running the command line you specified which is the ls -l command line
to the NextCloud config folder path below: /var/www/nextcloud/config/
me@mysrvr:~$ ls -l /var/www/nextcloud/config/
total 76
-rw-rw---- 1 root www-data 837 Mar 20 02:02 config.php
-rw-r--r-- 1 www-data www-data 72711 Feb 23 10:30 config.sample.php
It clearly shows the config.php file is owned by “root” user and not “www-data” user. So this is a problem.
If I understand you correctly, running the command line below should change the “root” owner to “www-data” owner. sudo chown -R www-data:www-data /var/www/nextcloud
After that is done your command line below should work without a problem:
This is the issue. In fact the owner and chmod settings is not accordingly to recommended for Nextcloud. But they will be fixed with an update - if ownership is correct.
Kerasit,
Thank you for your post. Here is my update.
Step #1:
I successfully changed the “root” ownership to “www-data” ownership as shown in command lines below:
me@mysrvr:~$ sudo chown -R www-data:www-data /var/www/nextcloud
[sudo] password for me:
me@mysrvr:~$ ls -l /var/www/nextcloud/config/
total 80
-rw-rw---- 1 www-data www-data 838 Apr 1 17:33 config.php
-rw-r--r-- 1 www-data www-data 74456 Mar 21 09:20 config.sample.php
Step #2:
I then was able to successfully change to maintenance mode as shown in command line result below. This was not possible before due to a unhandled error. But now it works and thank you for your help with this command line.
Step #3:
I then used the command line below to copy the existing data to it’s new location: me@mysrvr:~$ sudo -u www-data cp -r /var/www/nextcloud/data/. /mnt/8TBdata/
Step #4:
I then used the command line below to set my new data location and I got the unhandled error shown below:
me@mysrvr:~$ sudo -u www-data php /var/www/nextcloud/occ config:system:set datadirectory --value=/mnt/8TBdata
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?)
Step #5:
I disabled maintenance mode using the command line shown below:
My new problem is at Step #4. Do you or anybody in the forum have any advice on what is the correct command line I need to use to set my new data location successfully? Any information will be greatly appreciated. Thank you for your time.