.htaccess pcfg_openfile: unable to check htaccess file

.htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
Number of replies: 8
I've just done an upgrade to the latest 1.9 (downloaded tonight) version from an earlier 1.9 and I got the above error log after receiving a 500 Internal Error during the upgrade process (I think it was right at the end of the process).
So far the site seems to have upgraded without any problems but when I clik on Notifications in the Admin block I get the same error. I have noticed that there is some discussion about this in the Polish forums but as yet I am unable to decode that as my mother tongue is English...
Does anyone have any clues?

Many thanks in advance,

Simon
Average of ratings: -
In reply to Simon Clegg

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Richard Enison -
SC,

I used Google Language Tools to translate the Polish discussion into English. See http://74.125.93.104/translate_c?hl=en&sl=pl&tl=en&u=http://moodle.org/mod/forum/discuss.php%3Fd%3D22038&usg=ALkJrhiMGPZYFvzcy1jwoBDvYLPtEjd_EQ. It did a much better job than the other translator I tried, but I still found it hard to follow. This could be partially due to the fact that
  1. the discussion is 3.5 years old, and
  2. the browser used was lynx (text only)
However, I get the impression that the problem might have been a file permission problem. Make sure that your webserver (the user it runs as) has permission to read the .htaccess file.

RLE
Average of ratings: Useful (1)
In reply to Richard Enison

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
Thanks RLE,
Yes, it's clear from the log that the issue is permissions related. However, My installation is on shared hosting and the global .htaccess file is outwith my home directory (i don't currently have a local .htaccess file, never have had, and I have had this Moodle installation working fine since verion 1.6).

What I am struggling to understand is why I have suddenly encountered this error now for the first time in over 2 years, on the same server... It has only happened now with this latest upgrade. I rolled the upgrade back to the previous backed up version and the issue remains. The intalltion itself seems fine - so far everythng seems to work, but I am unable to access Notifications or ....mysite/admin/index.php without getting the 500 internal error.
In reply to Simon Clegg

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
This is what I get from my hosting supplier:

Sounds like the software's trying to open/run/check a htaccess file that was created by the software (WordPress [Moodle] or by a component you've installed correclty) but was unable to open it either because it doesn't exist, its corrupted or some other problem with it. That's about as much as I can advise really.

Does Moodle try to create an .htaccess file? It hasn't in this case and possibly the cause of the error...?
In reply to Simon Clegg

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Richard Enison -
SC,
  1. There is no global .htaccess file. The main configuration file for Apache, which your host sets up in a place inaccessible to you and that applies to all their clients, is a conf file, usually called httpd.conf. The .htaccess files are a facility that makes it possible for those clients, like yourself, to make Apache settings that apply only to their sites. It is up to each host that uses Apache
    1. whether to allow their clients to use .htaccess files, and
    2. what Apache directives to allow in them.
  2. I have no idea, at this point, why you have not had this problem in 2 years but do now. That's what we need to find out.
  3. Yes, Moodle does try to create an .htaccess file, in the data directory, if there isn't one there already. Its purpose is to make that directory inaccessible to web browsers, just in case it happens to be within the web-accessible root directory. As such, it should say

    order deny,allow
    deny from all

    Instead, it writes

    deny from all
    AllowOverride None

    The second line tells Apache to ignore .htaccess files. The file wants Apache to ignore it! What good is it then? I have pointed this out in these forums several times, but as far as I can tell it has not been corrected. Maybe I need to report it to the tracker.
RLE
Average of ratings: Useful (1)
In reply to Richard Enison

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
Thanks RLE,

That's clearer. Yes, there is a .htaccess file in the moodledata directory. This is good. Here are it's contents:

deny from all
AllowOverride None

The permissions on this file are -rw-rw-rw
The permissions on the moodledata directory are drwxr-xr-x

So how are we so far? Are things how they should be?

Basically, I am getting the error each time I try to access ...mysite/admin/index.php

Thanks so much for you help so far smile

Simon


In reply to Simon Clegg

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Richard Enison -
SC,

Well, the permissions on your moodledata are 755, and on .htaccess 666 (let's not get superstitious about that!). They could be a little more secure (lower), but they are not too low to allow Moodle the access it needs; which is to say, they do not explain the error.

I just Googled the error msg. in your subject line. It does appear to be an Apache problem. There is a lot of talk about permissions, and phantom .htaccess files. By what they say, again, your permissions appear to be okay. I'm beginning to think that the problem is that

AllowOverride None

line in the .htaccess file. It could be that it has Apache going in circles. On the one hand, there is an .htaccess, file, so it reads it to see what it wants Apache to do. But when it gets to that line, it finds that it is supposed to ignore .htaccess files! But if it does that, then it would also ignore that line, and therefore should read the file after all, and we're right back where we started, chasing our tail.

If you delete the file, Moodle will recreate it. But it only does that if there is no file of that name in moodledata already. So leave the file there, but edit it: remove that AllowOverride line. See if that makes the problem go away. If it does, then I definitely will have something to give the developers a piece of my mind about in the tracker!

RLE
Average of ratings: Useful (1)
In reply to Richard Enison

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
RLE, Thanks so much for making such an effort in pursuing this.

I removed the AllowOverride None line for the .htaccess file (in /moodledata/)
This had no effect - still got the error. Removed the .htaccess file altogether and as you said,Moodle recreated it and I still get the error.

I am currently trying to check mu log files but they don't seem to be updating - got the server admin checking that out now. But in the meantime... could Moodle be trying to access any other .htaccess files elsewhere in the file structure?

Cheers


In reply to Richard Enison

Re: .htaccess pcfg_openfile: unable to check htaccess file

by Simon Clegg -
Okey dokey,

Turns out the error above may not have been the offending issue after all.
Having just checked my logs again, I found this:

******.co.uk [Wed Oct 15 18:34:16 2008] [error] [client 217.44.3.184] FATAL: emalloc(): Unable to allocate 32 bytes, referer: http://****.co.uk/
****.co.uk [Wed Oct 15 18:34:16 2008] [error] [client 217.44.3.184] Premature end of script headers: index.php, referer: http://*****.co.uk/

So I added an .htaccess file into the home root with the line

RLimitMem 128000000


Problem solved!!

Odd that it was failing to allocate just 32b and odder sill that I have not encountered this issue in the past. Shared hosting evil I'll have to get a proper server!

RLE, thanks for all your help and please accept my apologies for unintentionally sending you on a wild goose chase. YOur assistance was really helpful nonetheless.

Many thanks!!