Max uploaded file size changed in php.ini, but big file does not load

Max uploaded file size changed in php.ini, but big file does not load

by David Delgado -
Number of replies: 12

I am using a shared hosting. I created a php.ini with this, to override default  uploaded file size of 8 MB:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600

I also created a .htaccess with this:

LimitRequestBody 67108864

I tested that everything was working fine with a php script:

<?php
echo ini_get("upload_max_filesize");
?>

When called, it printed:

64M

So, it is supposed to work fine, but it does not. When I try to upload a 20 MB SCORM module, after loading it for a while, it tells me that its size was bigger than the max_post_size in php.ini.

Anyone knows what is happening? Any fix? I am desperate. sad

Average of ratings: -
In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Ken Task -
Picture of Particularly helpful Moodlers

Seems I re-call seeing in these forums a posting that said on some shared systems, the php.ini or .htaccess files need also to be placed in the module folders.  In your case: /moodle/mod/scorm/

Doesn't hurt to try!  If it doesn't work, one can remove the php.ini/.htaccess in the scorm directory.   Since it is remotely hosted, might also check with hosting provider FAQ's/Community forums, etc.  Others on your providers shared systems might have had the same issue and have found a soluton.

'spirit of sharing', Ken

In reply to Ken Task

Re: Max uploaded file size changed in php.ini, but big file does not load

by David Delgado -

Believe me, Ken, I do not ask for help here before looking for a solution everywhere else: Google, FAQ, Docs,... in lots of places.

The point here is that .htaccess is recursive, and thus, you only have to put it in moodle main directory, but, as you suggested, php.ini is NOT recursive, and you have to put it in every directory you have to use, which I did not know and I find really anoying.

I created an upload script in PHP to check if .htacces and php.ini where working in my hosting provider: it worked fine with the file I was trying to upload, so the problem was only in Moodle.

After knowing the problem with php.ini, I copied it in the directories suggested in the Moodle Administration FAQ

* public_html
* moodle/admin
* moodle/course
* moodle/files
* root of your moodledata directory

But it still did not work. So, I made use of grep to find the file where the error appeared, and it was 

./repository/repository_ajax.php

So, I copied php.ini in the repository directory and a few others inside it, and Voila! It worked. smile

Now I am trying to find a way to make php.ini recursive, to have to put it only once in the moodle directory, but it does not work fine, and I get an error 500 (Internal Server Error). Any ideas on how to do that?

In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Guillermo Madero -

Hi David,

Just in case you end up needing it, at the following site there's a script to recursively copy the php.ini file into every directory:

http://tips-scripts.com/php_ini_copy

About the 500 error, it is usually best to start by checking the server error logs.

In reply to Guillermo Madero

Re: Max uploaded file size changed in php.ini, but big file does not load

by David Delgado -

Hi, Guillermo,

Thank you for answering. Anyway, I have been investigating and the error 500 should be because my hosting provider uses PHP as FastCGI, and the other solution is for those using PHP as an Apache Module (suPHP).

On the other hand, there is a much easier way to copy recursively the php.ini file into every directory, if you have acess to SSH (as I have), that is using the find command, in just 1 line:

find . -type d -exec cp /path/to/php.ini {} \;

In reply to Guillermo Madero

Re: Max uploaded file size changed in php.ini, but big file does not load

by Ken Task -
Picture of Particularly helpful Moodlers

Maybe what Moodle needs to provide is a tool for those who host on remote/shared systems to check max uploads (and other settings related) in ALL the directories that require adjustments due to system restrictions imposed by providers of shared systems.  Sounds simple, but imagine it to be more complicated as providers of shared systems may not do things in the same fashion/manner, etc.

Interesting read (for those more technically inclined):

http://php.net/manual/en/ini.core.php

Just for my education ... .htaccess is an Apache thang and while it is supposed to be recursive, apache 'hands off' to PHP further restrictions/overrides.  Where as php.ini is strictly PHP, but if .htaccess referes/defers to PHP then one should concentrate efforts in php.ini to resolve such problems.  That a sound trouble-shooting approach?

'spirit of sharing', Ken

In reply to Ken Task

Re: Max uploaded file size changed in php.ini, but big file does not load

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 know this is one of the more unhelpful things I have said, but I can't help thinking this is the hosting company's issue, not Moodle's.

I'm not against helping people at all but these are issues that users are going to run up against with any (large) PHP application.

In most cases, it's unlikely you are going to be able to run a 'production' Moodle system on shared hosting with default settings. I think I shall add something like this to the docs (if it's not there already)..

"on shared hosting ask your hosting company for clear instructions on how to override default PHP settings".

These php.ini / .htaccess files (there can be others) are a function of how the hosting company configures their systems which makes it even more difficult to generalise. If fact, I don't think we should as (unless we know for a fact - for that host) it just causes even more confusion and misinformation.
In reply to Howard Miller

Re: Max uploaded file size changed in php.ini, but big file does not load

by David Delgado -

"I can't help thinking this is the hosting company's issue, not Moodle's" -> You are wrong, in ALL shared and even dedicated hosting, you have to deal with configuring .htaccess or httpd.conf, and the general php.ini or the local one. You must know which options to put in each case, and the ones we are discussing about (allowing bigger uploaded files) are not vendor specific.

" it's unlikely you are going to be able to run a 'production' Moodle system on shared hosting with default settings. I think I shall add something like this to the docs (if it's not there already).." -> Take a look at your own statistics of registered moodle sites. Most of them have very few users, and I am sure they are on shared hostings. And, as I told you before, there is an specific subject in the Moodle Admin FAQ to cover the thing we are talking about: allow the uploading of bigger files. It just need to be fixed adding the repository directory as a place to put the php.ini file. I would have changed that if I do not get a server error everytime I try to edit it.

"on shared hosting ask your hosting company for clear instructions on how to override default PHP settings" -> They are always the same: use .htaccess and php.ini files

"These php.ini / .htaccess files (there can be others) are a function of how the hosting company configures their systems which makes it even more difficult to generalise" -> I have looked at lots of possible configurations, and almost all are the same for ALL the shared hostings (or even dedicated ones). The only one I found that is different is the one trying to make php.ini recursive, that was related to how the PHP was configured (it only worked when installed as a module - suPHP, and not as CGI).

And, last, it does not hurt to discuss all this things here, even if they work for an specific configuration, we are here to help, and solving this things in the forums helps others searching for solutions in Google or here to "never solve the same problem twice".

Howard, I really do not understand that "do not look for help on that here" attitude.  It is the first time since 2003 that I found that response in moodle.org. mixed

In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
David,

I think you entirely mis-read me or maybe I wasn't clear.

I know from experience that the way these things are set up on various hosting sites can differ considerably. Users come on here and, not unreasonably, ask for advice. They get responses but, bottom line, the people responding are often just guessing. Unless you know for a FACT how xyz hosting has set up its .htaccess or php.ini files then I seriously believe the best advice is "ask your host how that works".

That's not even remotely the same thing as "we don't care and we're not helping you"; it's "we don't know and this is what you should do".

I have to deal with a lot of shared hosting sites on behalf of clients and I mostly find them confusing with subtle differences in the way things are configured.

This is absolutely NOT a "do not ask for help on here" attitude. However, the definitive advice is sometimes to be found elsewhere and I don't have a problem with saying that. Also, I am in no way against discussing such matters here - it's good to have some useful answers to search against.

As I say, I think you have entirely misunderstood me. I am only concerned that we give people asking the best possible advice.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Max uploaded file size changed in php.ini, but big file does not load

by David Delgado -

Howard,

Sorry if I misunderstood you. I think I did, as you are telling me. Anyway, I just wanted to tell you that nearly all the discussion on php.ini and .htacess in this thread (changing max upload size) can be used for any shared hosting, and so it is put in the FAQ.

Perhaps, when regarding to other things related to the specific hosting we should refer first to the specific hosting help, but take into account that many people, as me, have done that already and looked for info in the FAQ, docs and forums in the specific hosting (and Google, and other docs, and Moodle documentation, etc.), and come here as a last resource, that usually makes with a happy solution, as I have found for my problems. Those solutions may help others.

Just in case you are wondering what specific shared hosting I am using, mine is 1and1, and now, after finding help here, my Moodle install is working perfectly fine. I do not think that finding help (even specific) here hurts anybody smile

In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Cool big grin

I absolutely do not think that finding help here is anything other than a good thing. There are loads of hosting companies out there and I just have a concern that we actually increase people's confusion when the best advice is to go and ask their hosting company's support service. Why not? You're probably paying for it wink

I think it's helpful to mention the hosting that you are using. That means we have a definite link in the forums... "I used xyz hosting and found it worked like this"!
In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
PS... changed that FAQ for you. I also rewrote it a bit as it didn't mention site-wide php.ini at all.

Obviously, having to copy a php.ini file all over the place isn't ideal if there's any kind of alternative.
In reply to David Delgado

Re: Max uploaded file size changed in php.ini, but big file does not load

by Anne Krijger -

FWIW; changing .htaccess or folder specific php.ini files does seem like server configuration to me. As a non root user you may not even have change access to the directory Moodle is installed in. Also; having to place the same php.ini file in every directory seems.... odd to say the least. I'd seriously start to question the people who required such configuration.

That said; In cases where you do have to do it yourself; wouldn't using symbolic links work better on *nix environments? That way the change made to the 'mother of all php.ini files' would directly be reflected in all others.

BTW; keep in mind that if you ever make a change to the set up (add a module for example), you may need to repeat the copy/create link process again.

If there really is no way around it, I guess someone should write and admin plugin to handle this mess.

Anne.