Can someone please help me out?
Which settings were you altering in php.ini? There are 2 as I remember.
$ sudo updatedb # or something else for other distro
$ locate php.ini # hopefully you have locate
alternately you might have find:
from the root dir:
$ find . -name php.ini
This can take some time to run.
Sorry if this is too basic or too linux to be helpful but I'm new to Moodle and php smile.
The first thing I would to is locate the source of the problem. Create a PHP file with the following code:
<?php header('Content-Type: text/plain'); $settings = array('upload_max_filesize','post_max_size'); foreach ($settings as $setting) { print "$setting: ".ini_get($setting)."\n" }
The post_max_size should be larger than upload_max_filesize (otherwise you get funny problems). The reason is that if a file is too large and the limits are the same, it may cause the other data in the POST request to go missing.
The settings file_uploads, max_input_time, and memory_limit may affect uploads as well, check these settings if you continue to have problems.
If these numbers are okay, then it's an issue with Moodle, otherwise it's an issue with your PHP settings.
You should read the docs first (you don't mention reading the docs....) Are you running php as cgi, and if so, why did you restart apache? Might you want to zip and upload your php.ini?
I have two php.ini files: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini. I changed both files just to be on the safe side.
In both files I changed these settings:
max_execution_time = 300
max_input_time = 600
memory_limit = 1024M
upload_max_size = 1024M
post_max_size = 1024M
When I run the test script suggested above it indicates that both upload_max_size and post_max_size are 1024M. (In case you are wondering, we will only be using moodle over a local network so file size is not a problem)
In moodle, under Security > Site Policies I have set Maximum uploaded file size to 1073741824.
However, despite all of this when I go to edit a specific course the only options I have under Maximum file size are: 2MB, 1MB, 500k, 100k, 50k, 10k.
I have read everything I could find on the Moodle site, forums and docs included, on how to set the maximum upload size and it seems like I'm doing everything right. What have I missed?
Secondly, I'm not trying to. I'm trying to raise the limit on the classes so high that the upload limit is never an issue. I have set my site-wide limit to a whole gigabyte but the highest option I have available on each class is 2 megs. Hence the problem.
set your /etc/php5/cli/php.ini to these settings (if you are running mod_php you will want to change both especially if you are involking cron via CLI
; Maximum size of POST data that PHP will accept.
post_max_size = 28M
; Maximum allowed size for uploaded files.
upload_max_filesize = 28M
and remove the php size settings from any htaccess files.....
and now go check your Moodle GUI and see what shows up.....
Read the php docs on the diff between post and upload max file sizes and play with these until you feel comfortable.
If you really want to push the envelope, after checking your apache limits try
; Maximum size of POST data that PHP will accept.
post_max_size = 1G
; Maximum allowed size for uploaded files.
upload_max_filesize = 1G
But consider the comments below..
- you probably do not want to use Moodle scripting to upload 1 gig files; use ftp (I suppose that at some point where expected assignment files become that large, more effective tools for large file transfer may be implemented).
- there are other apache (e.g. limitrequestbody and large file support) and OS limitations (such as whether this is a 1`6bit, 32 bit or 64 bit OS) and as you push limits things will break , especially if you set applications to use resources that are not otherwise made available.
In /etc/php5/cli/php.ini I have post_max_size and upload_max_filesize both set to 1G. When I run a test script to output what the values are set to it correctly lists them as 1G.
The Moodle GUI STILL will only list 2MB as the highest available option under "Maximum upload size" on the course settings.
In my flailing around trying to get this to work I have done everything I can think of, even if it probably wouldn't make a difference including rebooting the machine, restarting Apache, adding .htaccess files that specific the LimitRequestBody again (since I have already set that in httpd.conf to 2147483647). I have also logged in and out of Moodle, refreshed the page, cleared the cache and refreshed the page.
What is the deal here??
Please follow the steps I suggested and then advise of the results....
Did you already do what I suggested and if so can up zip and upload a screen capture of your moodle php info page and you php.ini files? In the interim I would reduce file size in both php.ink files to 1M and if that is not reflected in your moodle install I am guessing that there is another php.ini file somewhere....
Is this installation on your own server or on a web host?
Attached is my php.ini file (both are identical). Right now I have the sizes set in bytes but I have also tried 1G and 1024M.
check all htaccess and delete file size limits
reset apache limit
set php.ini sizes to "28M" not in bytes
capture phpinfo page and upload it and your php.ini as a zip
and then restart apache (and double check whether you are running mod_php)
If still no joy set both your php.ini files to 1M and try again and see if the change down is reflected in the drop down.
Thanks for all your help. I'll take another crack at this on Monday and try 28M.
hth
Frank

That is the thrust of the suggestion as well that you sabotage your php.ini file to determine if it's even being read-and doing a find as root will assist in addressing that-which is one reason I am assuming per your prior post that you read the links to how php.ini is sourced.
Likewise confirming you are not running mod_php will help to determine what apache is doing, and cleaning out changes to apache don't files and any htaccess files will also help reduce possible issues.
Is there no place I can configure these preset upload limits? Or does Moodle have to figure it out on its own based on the server environment?
I am on the road and can't see the file you uploaded, but should be able to do that today.... In the meantime have a look at http://www.askapache.com/php/custom-phpini-tips-and-tricks.html
Is it possible that this is a bug with Moodle?
And then the same for /course and /file
Not sure what your post re edit.php meant......
On your suggestion I just adding symlinks to /course and /files and will have no results.
I don't understand what the problem can be at this point. PHP's settings are clearly correct. Apache's settings are clearly correct. Moodle's global settings are clearly correct. It is just this one dropdown that is preventing me from doing what I need to do.
At this point I am trying to limit my filesize just as a test to see if I can control the value at all. My maximum filesize, as far as php is concerned, should be 64k. However, I still have 2MB listed as an option.
I tried lowering Moodle's system setting and that successfully lowered the maximum upload size. I then incrementally increased the size and found that it caps at 2MB. Is there some other Moodle setting that prevents the system from going past 2MB?
This represents a step forward as to date you have indicated that mOOdle has not responded at all to changing the php.ini entries.
Max size should only be controlled by Apache conf or htaccess files (either through limitbody or php_values being set), the max your OS can handled, and max set in php.ini
Did you determine whether you were running mod_php and are you setting both of the php.ini files in /etc?
Did you look at the doc I sent you regarding setting the php env so php knows where to look for a single php.ini?
I am not running mod_php.
Actually I'm not sure that Moodle has responded to changing the php.ini entries. I'm saying that I changed the site policy max filesize in Moodle's configuration (under Security) and that's how I was able to lower the maximum filesize. What I found striking was that I could dial the Moodle settings down as much as I wanted but the second I passed 2MB it stopped responding.
To make sure Apache is not a part of the equation I set the limit to Apache's maximum of 2 gigabytes in my httpd.conf file. I have both php.ini files set to the same values (just to be safe) and I have one of them symlinked in several directories in my Moodle folder structure.
PHP tests still respond to changes made in my php.ini files. It seems that the only piece that's not responding is that one dropdown in the course settings. Is it possible to manually add new values that would override the current 2MB cap?
* Killed any .htaccess files just to make sure they're not responsible
* Changed both /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini (the only two php.inis on the system other than the symlinks) to be 20M under both upload_max_filesize and post_max_size
* Restarted Apache
Still no joy
If you don't want to set PHPRC in your server's environment or set phpinidir in your apache conf file, let's try deleting the symlinks and copy the ini file to the admin, course, and files directories as well as to the cgi-bin directory, or where ever php is being executed from as a CGI... if this has been compiled as CGI then your php file is what is executed so with force redirect you would likely had a file named php in your cgi-bin, which would be the executable for cgi, and therefore it would be from cgi-bin that your ini file would be read. http://us2.php.net/manual/en/security.cgi-bin.force-redirect.php
It still looks to me like this is a directory by directory issue resulting from the fact that php is sourcing the ini file based on the working directory when the call is made, which suggests that in setting limits the 2M default is being used in some instances because of that context.. As I mentioned, if you set php to use the correct ini file then this should no longer be an issue (though please make sure that none of your apache conf files (there are a few....) or htaccess files are interfering with php directives.....
Here's the links I provided before.....
http://www.askapache.com/2007/php/custom-phpini-tips-and-tricks.html
http://us2.php.net/configuration
If all else fails, let's turn up php debugging and let's see if the log files will give us some idea of what Moodle is doing....
Alright, here's the deal. In my /etc/apache2/conf.d folder was a file called "moodle" that had some PHP settings including (wait for it) a 2MB file upload cap.
Everything's working now! Thanks for the help everyone, especially Marc!
How did the file get created?
Did you just delete the file or did you change settings?
What happens if you delete it?
What's in the file?
I assumed you built this install, but when I went back through the posts you only said it was your server; did you use a distro from moodle like lamp (ie is this conf file an undocumented feature?)
is this file actually referenced by one of the apache conf files or is it sourced only because it's in conf.d?
How did the file get created?
Did you just delete the file or did you change settings?
What happens if you delete it?
What's in the file?
I as
In any event, if you look here:
http://docs.moodle.org/en/Step-by-step_Install_Guide_for_Ubuntu_using_apt-get
you will find a discussion of the moodle file you discovered,
This moodle install will only work from the localhost. To make it accessible from other hosts you must edit the file /etc/apache2/conf.d/moodle. Type
sudo nano /etc/apache2/conf.d/moodle
(This is actually a soft link from /etc/moodle/apache.conf). This fires up the 'nano' text editor which is command line text editor and the sudo gives you the write access you need.
There is also extensive discussion about linking /etc/moodle/apache.conf with /etc/pache2/conf.d/moodleAnd here is a discussion on the packaging specifics peculiar to some forms of linux:
http://www.control-escape.com/web/configuring-apache2-debian.html
As you can see, apache will read as conf files the contents of conf.d, so it is "easier" to set moodle apache conf directives in /etc/moodle/apache.conf, which through linking to the apache conf.d directory, are read when you force apache to reread conf files via a restart....
Of course, none of this is apparently documented in the docs vis-a-vis changing file limits.... LOL.... and I will try to get to that, but if you would like to experiment so that the docs could address some examples (deleting the file, commenting out the directives, use of the file instead of a custom php.ini, etc) that would be great.....
See http://moodle.org/mod/forum/discuss.php?d=94601&parent=417707 for directories, but setting env correctly much preferred
two places to check
Administration ► Courses ► Course default settings and
Administration ► Security ► Site policies