Moodle folders - which ones are written to?

Moodle folders - which ones are written to?

by M Ghazaly Abdul Rahman -
Number of replies: 10

Hi all,

I am trying to identify and confirm which of the folders in the Moodle's file structure (not including moodledata) can be written to during normal operations, by way of Admin installing or configuring something on the site.

Please let me know if these are correct: auth, blocks, lang (not frequently), mod, pix (not sure), theme

Are the above the only ones? i.e. all the other folders (which I haven't listed) are purely PHP code for execution/running of the site.

Thanks!


Average of ratings: -
In reply to M Ghazaly Abdul Rahman

Re: Moodle folders - which ones are written to?

by Randy Thornton -
Picture of Documentation writers

When installing non-core plugins, each type of plugin installs in a particular directory depending on what type of plugin it is.

There are many more types than on your list, such as availability, calendar types, enrol, filters, H5P libraries, local, report, repository and so forth. You should take a look at the documentation for full list of plugin types.
Average of ratings: Useful (2)
In reply to Randy Thornton

Re: Moodle folders - which ones are written to?

by M Ghazaly Abdul Rahman -
OK, thank you Randy for your reply.

What if I were to reverse the question and ask for a list of folders which are just mainly PHP code for execution/running Moodle and will not be written into or modified throughout the running/operation of the Moodle site? I am sure this list will be shorter right?
In reply to M Ghazaly Abdul Rahman

Re: Moodle folders - which ones are written to?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There are NO folders that are routinely written to in the Moodle code. I would not describe adding new plugins as a "normal operation". I would never compromise the security of a live site by making any folders writeable. I would never, ever use the admin interface to add new plugins on a live Moodle site. It would be a crazy security risk.

I hope I'm reasonably clear big grin
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Moodle folders - which ones are written to?

by Randy Thornton -
Picture of Documentation writers

Yes, as Howard says. "Normally" no code ever needs to be written to the code base and should always be read only by the web server user account, as per the security documentation.

When you install a plugin, you need to know what type it is since that will tell you into what directory it will be installed. The user installing it has to have the permission to write to the directory to install it.

If you do this from the command line as sudo or some other privileged user, that user needs to be able to write to the files and to also make sure afterwards that whatever permissions the files ends up with will work for the webserver user to read and use them.

If you do this from the admin interface, in which case it is as the web server user who is actually performing the plugin install, you will need to make the directory for the plugin writable temporarily, then install the plugin, then immediately make the directory and the new subdirectories and files read only again.

Howard says he would "never, ever" use the admin interface to do this, however the fact is some hosting solutions do not allow any command line or privileged user access to shared servers, and that case your only way to do plugin installs would be via CPanel or some other tool to set the various proper permissions. (This is also the case in some organizations I work with that self host where Moodle admins are not allowed command line access to servers.)

Aside from plugin installs, the web server user does not need write access to the Moodle code.





In reply to Randy Thornton

Re: Moodle folders - which ones are written to?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
On top of that... with very few exceptions would you install a plugin written by some random dude that hasn't been through Moodle QA on your critical, live site anyway?

My dev site has the whole lot 'chmod 0777' and I use the plugin interface with abandon (it's really handy) but... if it all goes horribly wrong it's no worse than an inconvenience. This is the thing that worries me about the plugin installer. It takes you through an update process without even suggesting that you might want to take a backup of everything first (which you should).

I know Randy knows all this but it bears repeating. If your Moodle site matters to you, get yourself a test site and do all this there.

Before anybody asks... my version(s) of Moodle with plugins installed that have all been nicely checked and tested are written to Github and I deploy from there.
In reply to Howard Miller

Re: Moodle folders - which ones are written to?

by M Ghazaly Abdul Rahman -
Thank you guys for your concern and advice. Rest assured I'm doing all this on a test site. Let me explain why I'm trying to get the list of Moodle's core, "never written to during plugin/theme/mod installs", folders. I think I can guess which ones are those, but it's just reassuring to confirm it with some of the experts here.

Currently I have an AWS Auto Scaling Group with the moodle & moodledata folders stored in FSx for Lustre - so that no matter how many instances are spawned by the ASG, they all point to the same moodle & moodledata folders.

However, we know that running the code from EBS, which is in a way more directly connected to the instance, would always be much faster. So I'm thinking of putting those "static" folders back into EBS to see whether it would improve the overall performance.

Currently the site is already configured with ElastiCache for Redis, so I'm quite satisified with the current performance even though all the files are running off FSx for Lustre. Just wanted to see whether I could squeeze that little bit of extra performance out (from the EBS vs FSx for Lustre speed difference).
In reply to M Ghazaly Abdul Rahman

Re: Moodle folders - which ones are written to?

by Ken Task -
Picture of Particularly helpful Moodlers

2 cent contribution which may or may not be anything serious ... Site Admin -> Server -> Environment -> click update component.

That will acquire a new environment.php and environment.xml which resides in code directory.

Discovered that on a system using a load balancer where admin person was on node 3 of 5 nodes ... the files were acquired to node 3 only.

If same admin person logged off and then later re-connected, this time admin was on node 5, the checks there omitted the updated information in environment.xml which caused some confusion on part of that admin person.

Again - 2 cents worth.

'SoS', Ken

In reply to M Ghazaly Abdul Rahman

Re: Moodle folders - which ones are written to?

by Randy Thornton -
Picture of Documentation writers
"So I'm thinking of putting those "static" folders back into EBS to see whether it would improve the overall performance"

That's a very interesting idea. So, as long as you are not actually installing plugins or doing updates to the core ore plugin code, the whole moodle code folder would essentially be static.

And for any possible install or update of third party plugins, that list from the dev page lists all the potential plugin types and their folders. So, any other folders not on the list are core only and would only be updated when you update the release.
In reply to M Ghazaly Abdul Rahman

Re: Moodle folders - which ones are written to?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't use AWS - you've just started speaking in a language I don't understand. I suspect I'm not going to be any help.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Moodle folders - which ones are written to?

by Randy Thornton -
Picture of Documentation writers
Well said, Howard. There are old pilots and bold pilots, but no old, bold pilots. There are seasoned admins and plugin-addicted admins, but no seasoned, plugin-addicted admins.
Average of ratings: Useful (2)