moodle-docker icon indicating copy to clipboard operation
moodle-docker copied to clipboard

PHP: upload_max_filesize set to 2MB

Open rlorenzo opened this issue 7 years ago • 10 comments

The PHP container seems to default to 2MB in its php.ini config for upload_max_filesize.

Can the upload_max_filesize and post_max_size configs be set to higher values, like 2GB?

rlorenzo avatar Sep 23 '17 00:09 rlorenzo

Hi @rlorenzo, there already was a discussion about a better php.ini settings in #9 but no one, including me, proposed something at that time.

Thanks for rising! Matteo

scara avatar Sep 23 '17 07:09 scara

We implemented this on our fork: https://github.com/ccle/moodle-docker/commit/7b760ecdb5be80b47524db4de7f8e72e3f54bf9a

Not sure if this was the best method, but let us know if you want a similar patch made for this repo.

rlorenzo avatar Nov 02 '17 23:11 rlorenzo

Hi @rlorenzo, https://github.com/ccle/moodle-docker/commit/7b760ecdb5be80b47524db4de7f8e72e3f54bf9a#diff-3254677a7917c6c01f55212f86c57fbfR16 looks OK - I'd like to add more stuff like something as max_execution_time (https://docs.moodle.org/33/en/PHP#PHP_Settings) but here is out-of-scope -, not the mysql stuff which would be:

  1. a separate issue
  2. do not build a local image: add the custom values via a mount to /etc/mysql/conf.d as explained in https://hub.docker.com/_/mysql/, including a trailing :Z (more at https://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/)

Edit: would you like to propose a PR? Otherwise, I'll do it.

HTH, Matteo

scara avatar Nov 05 '17 09:11 scara

Any chance for merging commit 7b760ecdb5be80b47524db4de7f8e72e3f54bf9a @scara ? We need configurability for php.ini to increase the maximum memory.

tmuras avatar Dec 18 '18 09:12 tmuras

Can I ask what you need it increasing for? Happy to increase it but would be good to get more info to make sure the new amount is right.

andrewnicols avatar Dec 18 '18 09:12 andrewnicols

Just to run it:

➜ sudo -E bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/run.php
Running single behat site:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/lib/testing/classes/util.php on line 288

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1052672 bytes) in /var/www/html/cache/stores/file/lib.php on line 368
To re-run failed processes, you can use following command:
php admin/tool/behat/cli/run.php --rerun

But the Moodle instance I have here is heavily modified one. I simply set up the maximum memory to 1G.

tmuras avatar Dec 18 '18 10:12 tmuras

Okay, so out of the box Moodle works fine with the standard memory allocation.

I think we have a few options:

  1. add a hard-coded php.ini to the image in moodlehq/moodle-php-apache
  2. add a hard-coded php.ini which is mapped in the docker-compose.yml in these scripts
  3. add a php.ini directory here which is mapped to the includes directory in the docker-compose.yml in these scripts

I feel like a mapped directory may be the way to go as it allows more future flexibility for people to add their own configs but thoughts are appreciated.

andrewnicols avatar Dec 18 '18 12:12 andrewnicols

So basically we should copy extra config into $PHP_INI_DIR/conf.d/ directory, as per https://hub.docker.com/_/php/#configuration

Mapping could be a way to go, for example we add optional MOODLE_DOCKER_PHP_EXTRA_CONFIG environment variable.

If set, then bin/moodle-docker-compose will map MOODLE_DOCKER_PHP_EXTRA_CONFIG into container's $PHP_INI_DIR/conf.d/ .

tmuras avatar Dec 21 '18 13:12 tmuras

https://github.com/ccle/moodle-docker/commit/7b760ecdb5be80b47524db4de7f8e72e3f54bf9a

That seems to be a 3 line edit and should work perfectly for the vast majority of people. I'm okay with that.

FossPrime avatar Apr 09 '19 16:04 FossPrime

Would be much easier, when it would be in the moodle-php-apache image?

Why MoodleHQ can not set it per default at least to 100 MB?

For us we've now added a new configuration file to https://github.com/moodlehq/moodle-php-apache/tree/master/root/usr/local/etc/php/conf.d. As we're already using a custom image in moodle-docker due customizations.

Greets Adrian

adpe avatar May 18 '21 14:05 adpe

Hi,

I'm closing this now beacuse @ https://github.com/moodlehq/moodle-php-apache/pull/171 we are going to raise it to 200MB, plus now there are options in the php images to pass any arbitrary ini setting or init script.

Ciao :-)

stronk7 avatar Mar 20 '23 09:03 stronk7