(Split from Mod not writable) Migration from shared server to VPS

(Split from Mod not writable) Migration from shared server to VPS

by Piotr F -
Number of replies: 11
Actually, I have the same problem but with migration from shared server (install via Softaculous) to self-hosted VPS.
My guess (poor) is that some kind of web user/agent needs to be added to the group owning /mod/

(As I can see, this is how the problem has been solved. How to find out who is the user, to give to it right permissions? And what exact command should be?)

I compared permissions, and in the old one (shared server via Softac.) the user had a NAME and had 711 chmod, so I set the same recurs. on new VPS /mod/, and after that lost access to most if not all administration part of Moodle. So I changed back to 40755, now administration works as before, meaning can't install plugins again.

Any ideas?
Thank you for any kind of hints,
Piotr

(Edited by Mary Cooch - original submission Friday, 14 April 2023, 7:44 PM)

Average of ratings: -
In reply to Piotr F

Re: Odp: Mod is not writable

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
See https://moodle.org/mod/forum/discuss.php?d=445780#p1791740.

Other than that your enquiry has nothing in common with that thread. It is about a shared hosting, you have a VPS. Trying to piggy-back complicate things!
In reply to Visvanath Ratnaweera

Odp: Re: Odp: Mod is not writable

by Piotr F -
Thank you for the effort, sorry for the mistake, thought it is about setting correct permissions recurs. on /mod/ after moving from non-self-managed instance to anything with the root access.
Will check the link, thank you very much again.

[edit] I read your post before, as everything, before asking a question.

Hence, the problem persists, and I believe "/mod/ not writable" is the problem I have. Will get back here with the print of the shell.
In reply to Piotr F

Odp: Re: Odp: Mod is not writable

by Piotr F -
Here it is, and I believe it is missing www-data owner:

ls -ld /folder/moodle/mod
drwxr-xr-x 29 root root 4096 Mar 22 21:42 /folder/moodle/mod

Here it is for main moodle:

ls -ld /folder/moodle
drwxr-xr-x 60 root root 4096 Apr 7 21:16 /folder/moodle

And here for the /folder:

ls -ld /folder
drwxr-xr-x 6 1787731 1170173 4096 Mar 22 22:15 /folder

In the /folder there is also /openproject instance running. All goes out via Apache (Alias to /folder/moodle).

I tried to find a similar topic but seems this is the closest. If anybody could help or send me to the posts with the solution I will be very grateful.

Thank you,
Piotr
In reply to Piotr F

Re: Odp: Re: Odp: Mod is not writable

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Now it is clear. The key is this:
drwxr-xr-x 29 root root 4096 Mar 22 21:42 /folder/moodle/mod

Those are good permissions for a production Moodle - they don't allow hazardous things like the web server _writing_ (changing) the running Moodle code!

But the web based plug-in installation does exactly that. So you may make mod/ writable by all, rwxrwxrwx (777), install the plug-in on the web GUI and restore the permissions.

Note that you'll have more cleaning to do. The plug-in code mod/whatever will be owned by the web server, as a result writable by the web server.
In reply to Visvanath Ratnaweera

Odp: Re: Odp: Re: Odp: Mod is not writable

by Piotr F -
Thank you so much.

Would that
https://docs.moodle.org/401/en/Installing_plugins#Installing_manually_at_the_server
be a better solution then?
In reply to Piotr F

Re: Odp: Re: Odp: Re: Odp: Mod is not writable

by Ken Task -
Picture of Particularly helpful Moodlers

Yes... and No!  Depends upon the plugin.  Some plugins are part of a set and one has to install all the parts of the set - one finds that out in the description of the plugin via Moodle plugins web site or in the readme that appears in the first 'unzip'.  Some plugins are not packaged correctly (like sets) and you'll have to recognize that and adjust.

Because of the above, I have a practice of not trusting ... so I download the zip to my local machine or download the zip to a directory outside of Moodle code on server via wget and unzip it there to inspect/see first.

That's an extra step and well worth it if unzipping 'scatters' files/directories or you get a prompt asking if you want to replace what unzipping found is already there.

My 2 cents, of course.

'SoS', Ken


In reply to Ken Task

Odp: Re: Odp: Re: Odp: Re: Odp: Mod is not writable

by Piotr F -
Thanks a lot.

From lamer's perspective, installing and upgrading plugins via a shared server administration www seemed to be much easier and always working.
Now, with VPS and root access, a lot of fuss and unexpected problems.

Anyway, I followed the above manual, it worked for the theme, will check with the mod.
In reply to Piotr F

Re: Odp: Mod is not writable

by Ken Task -
Picture of Particularly helpful Moodlers

@Piotr

As it's already been suggested, but will repeat ... probably not a good idea to 'piggy-back' on someone else's posting even if the issue appears to be the same.  Leads to confusion for those seeking answers as well as those trying to help.

Have to use @poster to make sure a response is directed at a particular poster and not to both/all in thread.

Ownerships/permissions is common problem - especially when restoring a site backup from another server to your own server.   Well worth the time to get both ownerships/permissions right as soon as possible.

Hopefully, one has man on a VPS - online manual.  Contains everything you didn't really want to know about commands.   Example:

man chmod

or

man chown

For the second (change ownerships) would be important to know which Linux distro ... Ubuntu not same as CentOS/RedHat when it comes to ownerships.

Ubuntu/Debian - uses www-data or apache2 (user and group)

CentOS/RedHat - uses apache (user and group).

So to find out what distro:

uname -an

and you will see info about distro.

If you notice, didn't provide a specific answer for you blindly copy and paste cause that really won't be the right approach - give a fish vs how to fish! smile

'SoS', Ken


In reply to Ken Task

Odp: Re: Odp: Mod is not writable

by Piotr F -
Ken, thank you very much for taking the time to explain.

It is Ubuntu 22.04 LTS
output:
Linux user 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Cheers,
Piotr
In reply to Piotr F

Re: Odp: Re: Odp: Mod is not writable

by Ken Task -
Picture of Particularly helpful Moodlers

Try 2 more commands ... man is online manual.   If not installed, install it.

man chmod

man chown

Check config.php file for a line related.

'SoS', Ken