File Permissions question

File Permissions question

by Annie Price -
Number of replies: 8

Hi,

I am installing 2.2.3.  The instructions say that moodledata files must be 777.  However, the following message is on my hosting (heart internet) ....

Any permissions that would allow other users to write to the file such as 666 or 777 are blocked on our servers and can cause problems with opening the files. In general, directories and CGI scripts should have permissions of 755 and other files should have permissions of 644.

So, what should I set them to?

Can anyone help please?

Average of ratings: -
In reply to Annie Price

Re: File Permissions question

by Annie Price -

Hi,

Does no-one know the answer to this problem?  I have searched the forums but am still not sure what to do.

Please help

Annie

In reply to Annie Price

Re: File Permissions question

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Annie

You wrote:
> I am installing 2.2.3. The instructions say that moodledata files must be 777.

Can you show the instruction page and pin point the place where it says 777. The full set is here: http://docs.moodle.org/22/en/Category:Installation.
In reply to Visvanath Ratnaweera

Re: File Permissions question

by Annie Price -

Hi Visvanath,

Thank you so much for responding.  I am getting desperate as I have no idea what to set my files to.

The 'guilty' instructions are under 'create the (moodledata) data directory on http://docs.moodle.org/22/en/Installing_Moodle

I have uploaded the files to the server and they are set to 0777 but my hosting says ....

Any permissions that would allow other users to write to the file such as 666 or 777 are blocked on our servers and can cause problems with opening the files. In general, directories and CGI scripts should have permissions of 755 and other files should have permissions of 644.

So, what should I set them to?

Annie

In reply to Annie Price

Re: File Permissions question

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Annie

True. http://docs.moodle.org/22/en/Installing_Moodle#Create_the_.28moodledata.29_data_directory takes "chmod 0777 /path/to/moodledata" as an example. But it also says, "Here is an example (Unix/Linux) of creating the directory and setting the permissions for anyone on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for other scenarios..." And your server has spoken.
wink

This whole confusion arises because people just talk of the (octal) file and directory permissions without mentioning who the owner is! In the case of uploading Moodle files and creating moodledata, there are two users involved: you and Apache. How the Apache user is called depends on the distribuion: in Debian it is "www-data", in RedHat/CentOS it's simply "apache".

- The Moodle files, the moodle directory, is owned by you. You give Apache read-only permissions to these files. The result is octal permission 755 for directories and 644 for files.

- moodledata directory should be writable to Apache. But making it 777 is a cheap solution, it simply gives everybody write permission. What you must do is to make Apache the owner of moodledata and give only Apache write permission, i.e. 700.

See http://en.wikipedia.org/wiki/File_system_permissions#Octal_notation for an explanation.



Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: File Permissions question

by Annie Price -

Hi Visvanath,

Thank you so very much for your response.  That is the first time that I have understood what I must do and have now done so.

I truly appreciate your help and it has gotten me one step nearer to finally moving to 2.3

I know its going to be a long haul and I am doing lots of research and searching help files but I'm sure I will get there in the end, especially with help from people as giving with their time as yourself.

Again, many thanks

In reply to Annie Price

Re: File Permissions question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Annie,

Are you on a shared server or your own dedicated server?

If you are on a shared hosting  server, you probably will need to stay with 0777 to be able to get Moodle to work. In fact, the Moodle config.php file has a line in it that will set permissions to 0777. ($CFG->directorypermissions = 0777;)

If you run or have your own dedicated server 0755 is perfectly okay...in fact it is more secure because it lets only the owner (usually Apache if it is Linux) write files. On my own server that is what I set all my Moodle sites to. I then comment out the line (//$CFG->directorypermissions = 0777;) in the Moodle config.php file that sets permissions to 777. It is only needed if your server is NOT set up correctly to begin with.

 

HTH,

AL

In reply to AL Rachels

Re: File Permissions question

by Annie Price -

Hi Al,

Thank you so much for replying.

I am on shared hosting with heart internet.

Moodle files are in public_hmtl/moodle and there is no problem with the permissions for these files.

However the moodle_data files are above public_html (not accessible by users) but heart internet states that the files cannot be 0777 and have blocked them until I change the permissions.

I have no idea what to set them to so that heart internet will be satisfied and moodle will still run.

Annie

In reply to Annie Price

Re: File Permissions question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Annie,

You can actually put those data files just about anywhere and set the permissions to 755 or 777 (whichever works for you), if your hosting provider allows .htacces files.

For instance you could put the Moodle web files in/public_html/moodle. Then you could put the data files in /public_html/moodledata.

Since you don't have access to the the httpd config file you will need to set up a .htaccess file that controls access to the files in the data folders.

Here is the content of one .htaccess that I am using in one of my play around Moodle's data folder.

deny from all
AllowOverride None
AddType x-mapp-php5 .php

The first line prevents anyone from browsing the data folder but scrips will still work. The second stops any over rides. The third line is telling it to use php 5 because my provider has multiple versions of php available.

And in the corresponding web folder I have an .htaccess telling it which php to use.


AddType x-mapp-php5 .php

Further reading at http://www.freewebmasterhelp.com/tutorials/htaccess/1 is one place that will tell you more about .htaccess files.

HTH,

AL