Changing the Nextcloud server user

I wanted to share some knowlege that I was able to change the user used by Nextcloud by changing the apache default user.

This is something that Ive been wanting to try because I use Unraid for NAS and the www-data user:group has a default ID of 33. In Unraid the 33 id is used for the sshd user and I feel like there is a permission issue persisting in my setup.

These are the steps I followed to accomplish the change and I have seen no negative effects… yet.

Part1: Nextcloud CLI

create user www-nc
create group www-nc
Change id's to 5555
Add www-nc to www-nc group
Add www-nc to redis group
Usermod default home directory of the www-nc user to /var/www
Usermod shell to /usr/sbin/nologin

administrator@nextcloud:~$ cat /etc/group | grep www

administrator@nextcloud:~$ cat /etc/passwd | grep www-nc

Part2: Unraid CLI

create user www-nc
create group www-nc
Change both id's to 5555
Add www-nc to www-nc group

root@NAS:~# cat /etc/group | grep www

root@NAS:~# cat /etc/passwd | grep www

Part3: Nextcloud CLI

Put nextcloud into maintenance mode
Stop Apache service
Stop MySql service
Change Apache default user to www-nc
Change ownership of /var/www -R to www-nc:www-nc
CHnage cron job from www-data to www-nc

Part4: Unraid CLI

(GUI) Change NFS share to private and add the rule ",rw,sync,no_root_squash)"
Change ownership of Nextcloud storage to www-nc:www-nc
Chnage file permissions "find /mnt/user/nextcloud/ -type f -print0 | xargs -0 chmod 640"
Change folder permissions "find /mnt/user/nextcloud/ -type d -print0 | xargs -0 chmod 750"

Part5: Nextcloud CLI

Start MySql service
Start Apache service
Take nextcloud out of maintenance mode
Test filesystem access from nextcloud to NAS storage

Id also like to report that even after all the work the permission issues that prompted me to do this did not change unfortunately. But it was fun trying it out.

Id love to hear some feedback from a developer on this.