Warning about the config.php file

Warning about the config.php file

by mimi nom -
Number of replies: 5

Hello,

I have a warning about the config.php file. I executed the command ls -l to check the permissions of the file and the Moodle directory, I got the following results:

drwxr-xr-x 45 www-data www-data for moodle directory

-rw-r--r-- 1 www-data www-data for the config.php file

According to the documentation, The owner and the group of moodle directory and its content must be the system administrator (root) and in my case it is the web server user (www-data). To change these permissions, I have to execute these two linux commands:

# chown -R root /path/to/moodle
# chmod -R 0755 /path/to/moodle
I want to know if I do that, Moodle will continue to operate normally.

I hope you will answer me soon, this is urgent


Attachment configphp.png
Average of ratings: -
In reply to mimi nom

Re: Warning about the config.php file

by mimi nom -

I mean, the config.php file is writable

Attachment writableconfigphp.png
In reply to mimi nom

Re: Warning about the config.php file

by Matt Bury -
Picture of Plugin developers

Hi Mimi,

There's some helpful information on how to harden Moodle installations here: https://docs.moodle.org/29/en/Installing_Moodle#Download_and_copy_files_into_place

I use 755 for directory permissions and 644 for files and everything works as expected for me. Some 3rd party modules may need to write files in their respective directories or make changes to core code; this is poor coding practice but is sometimes unavoidable. I recommend testing any 3rd party modules for this, e.g. on a development server, before making the changes on a production server.

I hope this helps smile

In reply to Matt Bury

Re: Warning about the config.php file

by mimi nom -

Ok, I will, thank you for your help

In reply to mimi nom

Re: Warning about the config.php file

by mimi nom -

It is fixed, I simply run the command

chown -R root:root /path/to/moodle
in order to change the owner and the group
Attachment configphpok.png
Average of ratings: Useful (1)
In reply to mimi nom

Re: Warning about the config.php file

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Nice that you got it repaired.

Yet I doubt whether your original
# chmod -R 0755 /path/to/moodle
was a good idea. It doesn't make a difference between regular files and directories. Now you have all files rwxr-xr-x. The x (executable) doesn't make sense for PHP files.

You need something like
# find /path/to/moodle -type f -print -exec chmod 644 {} \;
and
# find /path/to/moodle -type d -print -exec chmod 755 {} \;

(Didn't verify. Try first in a test directory tree.)