Migrated to new server, can no longer access course files

Migrated to new server, can no longer access course files

by Philip Widdowson -
Number of replies: 9

I have just finished migrating my moodle (2.5.6) install to a new server (php 5.4.16,  MySQL 5.5.37, Apache 2.4.6)

I backed up and imported the SQL db - no problems

rsync -avi the moodle web root across, that works fine

rsync -avi the moodledata folder across and that doesn't work...

The folder is there, the files that appear in the Apache error_log exists in /extra/moodledata/filedir/... but Moodle just returns a 404 when trying to access them (error_log says:

"Can not read file, either frile does not exist or there are permission problems [...] Error code: storedfilecannotread [...]


I tried permissions as stated in the documentation (nobody:apache 0770) and also other forms such as apache:apache 777, but I never get access to those files.


Would changing from lighttpd to Apache have anything to do with it? I'm sort of lost for solutions at the moment as the rest of my Moodle migration is working perfectly well

Average of ratings: -
In reply to Philip Widdowson

Re: Migrated to new server, can no longer access course files

by Ken Task -
Picture of Particularly helpful Moodlers

Am assuming migrating from a Linux server to a Linux server but it would help to know what flavor of Linux to be specific but .... given what info shared ...

is the location of moodledata (the extra directory) also readable by user apache?  On linux boxen, the httpd.conf (or apache2.conf - depending upon flavor) has a variable for document root.  On a CentOS box (RH flavored) that typically is /var/www/html.   Apache user/group has access to that directory and is typically where one would install the moodle code.   The data directory is usually one level up from that (because it's still owned and accessible to apache server/user in /var/www/moodledata.

If there is to be a directory accessible to apache user/group outside of /var/www one might need to define it in httpd.conf as an alias.  For example, in a typically configured RH/CentOS server there is an /icons/ directory and it's defined as an alias in httpd.conf thusly:

Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Anyone with a browser can http://server/icons/ to view.   That does NOT mean, however, you should grant that sort of access to moodledata.

What is your config.php file have for paths to moodledata?   And what are the ownership/permissions on /extra/?  Questions for investigation, not necessarily posting here.

OR, you could compare the config file for apache on old server with the config on new server.

Plus ... check the ownership/permissions on /extra ... remember that ownerships/permissions are from top down.   Does moodledata and all files/folders contained there in belong to apache:apache? (CentOS/RH example - adjust for your flavor).

'spirit of sharing', Ken

In reply to Ken Task

Re: Migrated to new server, can no longer access course files

by Philip Widdowson -

Oops, missed the OS bit out. Migrated from CentOS 6.5 to CentOS7.

I used chown/chmod -R on /extra, so everything under that (and including), that I looked at was owned by the user/group I set it to.


To cut down (in theory...) on the reconfig, the file structure etc was maintained across both servers, so moodledata is /extra/moodledata on both servers and the root directory is /var/www/html/

In reply to Philip Widdowson

Re: Migrated to new server, can no longer access course files

by Ken Task -
Picture of Particularly helpful Moodlers

Ahhhh ... latest and greatest CentOS 7, huh?   Hmmmm ... that wasn't released that long ago.   Brave person, IMHO! ;)

Well, it's a new machine ... now am assuming under a virtual  OS ... so the guest OS (CentOS 7) has been allocated how much space and what does the output of:

df

look like?

Enough room on new server for rsync to copy all files/folders of moodledata?

'spirit of thinkering', Ken


In reply to Ken Task

Re: Migrated to new server, can no longer access course files

by Philip Widdowson -

Yup, plenty of space left on /extra (110gb+) and 40gb+ for the os and SQL store

In reply to Philip Widdowson

Re: Migrated to new server, can no longer access course files

by Ken Task -
Picture of Particularly helpful Moodlers

Ok then ... let's try this:

chown apache:apache /extra/moodledata -R

chmod ugo+rwx /extra/moodledata -R

Yep, that's wide open for apache user/group - but, Moodle is the only thing that should be talking/using it.

and while am at it ... what are ownerships/permissions on /extra?

Ken

In reply to Ken Task

Re: Migrated to new server, can no longer access course files

by Philip Widdowson -

Permissions for /extra are the same as the ones for /extra/moodledata - generally I am setting the permissions on /extra and propagating down to moodledata etc.


Tried the two commands, still the same thing happens. so totally not wow.

In reply to Philip Widdowson

Re: Migrated to new server, can no longer access course files

by Ken Task -
Picture of Particularly helpful Moodlers

Are the ownerships/permissions on /extra part of apache group or apache user?

Is /extra a partition or a mount point for NFS?

What does df look like?

And are there any references related to the issue in any of  the /var logs/ like secure or messages?

Don't know how CentOS 7 sets selinux by default, so check sestatus.   If selinux set to enforcing, one could successfully rsync as root, but apache (whatever user) won't be able to see use unless there is a setting in selinux to allow access to /extra/ anything.

'spirit of sharing', Ken

In reply to Ken Task

Re: Migrated to new server, can no longer access course files

by Philip Widdowson -

apache:apache is what I've set on /extra and everything below - which is the user/group Apache wanted for itself by default and if I run "id apache" the following is returned:

uid=48(apache), gid=48(apache), groups=48(apache)

/extra is a second disk - so /dev/sdb

df -h looks like:

If I "grep -ri e72bbc /var/log" nothing is returned apart from the apache log results.

SELinux I have set to disabled for the time being as it was having an impact, but in /etc/sysconfig/selinux I changed it to disabled.

In reply to Philip Widdowson

Re: Migrated to new server, can no longer access course files

by Philip Widdowson -

Firstly, just want to say thank you for being patient and your time assisting me with this fault... which was totally 100% self-inflicted.


Permissions wise... that wasn't really the problem in the end.


I came across the solution when I went to upload a large file into Moodle and PHP threw a wobbly... which then lead me down the root of copying my php.ini file from the old server to the new one... which, frustratingly, fixed the issue of not being able to access existing content.


On closer inspection, one needs to ensure that open_basedir in php.ini allows access to the moodledata folder.

open_basedir = /var/www/html:/path/to/moodledata

Average of ratings: Useful (1)