[Bug]: PHP's upload_max_filesize doesn't affect Nginx' client_max_body_size
Platform
macOS
Operating system version
macOS Sonoma 14.4.1
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.6.0 (24)
PHP Version
No response
Bug description
I need to import sql via phpmyadmin. The file is 250MB. I changed Max File Upload Size to 512 in the PHP tab. I also went to php.ini and made sure both post_max_size and upload_max_filesize are set to 512M.
These don't help me tho, because I'm getting 413 Request Entity Too Large nginx/1.25.4.
Now I cannot go to vi /etc/nginx/nginx.conf to modify the client_max_body_size because the file doesn't exist.
Where can I change this setting?
Steps to reproduce
Try to upload 250MB file.
Relevant log output
Nginx logs is empty.
I have also seen this problem on Herd Pro, but have been able to update the Nginx configuration (located at ~/Library/Application Support/Herd/config/nginx/herd.conf) which resolved the 413 error. However it appears that the php engine is not respecting the settings in php.ini at ~/Library/Application Support/Herd/config/php/83/php.ini. Using phpinfo() shows upload_max_filesize=2M and post_max_size=8M despite having set upload_max_filesize=1024M post_max_size=1024M in php.ini.
This issue seems resolved following update to 1.6.1
thanks for heads up, i'll test in the evening and hopefully close the issue if it works.
So i update to herd 1.6.1 build 25. I went to php.ini and set
post_max_size=2048M
upload_max_filesize=2048M
then i went to applications/herd/content/resources/config/nginx/
opened nginx.conf and set client_max_body_size 2048M;
opened herd.conf and set client_max_body_size 2048M;
restarted everything, even the computer to be sure.
went to phpmyadmin.test and tried to import export.sql of 242MB.
still getting the same error
is there anything else i could try?
This issue seems resolved following update to 1.6.1
For me it didn't, anyone else who can confirm this?
I fixed the 413 error by editing ~/Library/Application Support/Herd/config/nginx/herd.conf and changing the value of client_max_body_size there. I would assume the file you edited in the application bundle would be overwritten when Herd updates and is overridden by the value in the ~/Library/Application Support directory.
This issue seems resolved following update to 1.6.1
For me it didn't, anyone else who can confirm this?
For me aswell.
MacOS Sonoma Herd 1.6.1
Editing ini files has no effect.
/Library/Application Support/Herd/config/php/82/php.ini /Library/Application Support/Herd/config/php/83/php.ini
upload_max_filesize=100M
post_max_size=100M
phpinfo(); exit;
// post_max_size = 8M
// upload_max_filesize = 2M
Any news?
Same issue here.
MacOS Sonoma 14.3.1 Herd 1.7.1
Editing values such as 'upload_max_filesize' in the php.ini file or even directly in Herd has no effect.
Even though 'Max File Upload Size' is set to 2 or any other value, using 'phpinfo()' displays 128M
After doing some searching, I think I've managed to find the cause of this issue.
When looking into the 'Library/Application Support/Herd/config/fpm/php-version-fpm.conf' file, there's the following code:
; FPM pool configuration for Herd
[global]
error_log = /Users/matthiasclaessen/Library/Application Support/Herd/Log/php-fpm.log
[herd]
php_admin_value[error_log] = /Users/matthiasclaessen/Library/Application Support/Herd/Log/php-fpm.log
user = matthiasclaessen
group = staff
listen = /Users/matthiasclaessen/Library/Application Support/Herd/herd82.sock
listen.owner = matthiasclaessen
listen.group = staff
listen.mode = 0777
;; When uncommented, the following values will take precedence over settings declared elsewhere
php_admin_value[memory_limit] = 512M
php_admin_value[upload_max_filesize] = 128M
php_admin_value[post_max_size] = 128M
;php_admin_value[error_log] = /Users/matthiasclaessen/Library/Application Support/Herd/Log/php-fpm.log
;php_admin_flag[log_errors] = on
;; Note: increasing these values will increase the demand on your CPU and RAM resources
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
The lines:
php_admin_value[memory_limit] = 512M
php_admin_value[upload_max_filesize] = 128M
php_admin_value[post_max_size] = 128M
Should be commented, because like mentioned in the comment above them, they will take precedence over settings declared elsewhere, such as your 'php.ini' file.
After commenting these lines, I tested editing the values in Herd, and it seems to work.
@sschlein, could this be a possible fix?
Edit: after some more testing, this does not seem to work consistently, as I can no longer adjust the values, even when having these lines commented.
Edit 2: It seems that adjusting the values more than once in Herd, the 'FPM-php-version' service stops running due to another FPM instance already listening on the herd.sock. This is the output of the log:
[14-Jun-2024 13:48:27] NOTICE: [pool herd] 'user' directive is ignored when FPM is not running as root
[14-Jun-2024 13:48:27] NOTICE: [pool herd] 'group' directive is ignored when FPM is not running as root
[14-Jun-2024 13:48:27] ERROR: Another FPM instance seems to already listen on /Users/matthiasclaessen/Library/Application Support/Herd/herd82.sock
[14-Jun-2024 13:48:27] ERROR: FPM initialization failed
I'am facing the same issue with Herd 1.8.0. M2 MacBook Pro, macOS 14.5.
Having the same issue with Herd Pro 1.8.0 build 29 13-inch, M1, 2020 MacBook Pro, macOS Sonoma 14.5
Also uncommenting the php-fpm.conf did nothing. phpinfor(); says I load the correct ini from /Users/martin/Library/Application Support/Herd/config/php/83/php.ini
it still shows post_max_size 8M 8M
Hi All,
I opened #857 to draw some more attention to the issue, and it turns out that there was a "leftover" PHP-FPM process, once this was killed everything worked again - I was a valet user prior, maybe some of the users in this thread were too, so possibly old NGINX or old PHP-FPM processes running from Valet? (an educated guess on my part, not a fact)
Hope this helps.
Nothing works for me when trying to update client_max_body_size.
What I tried:
- php.ini - updates are reflected (confirmed with phpinfo)
post_max_size=10000M
upload_max_filesize=10000M
-
nginx.conf
client_max_body_size 10G;in http -
herd.conf
client_max_body_size 10G;in server (tried with 10000M instead of 10G, also nothing) -
Herd Settings: Max File Upload Size to 10000
-
Stop all and Force stop all
File has around 8.7G, and it fails every time with error 413 (Request Entity Too Large)
In error log I can't see what is the max value so I am stuck.
MacOS, Sonoma 14.5 Herd 1.9.1 (Build: 31)
@kikky7 little too much for me such an upload limit. Maybe check some other solutions. for example, start here: https://www.youtube.com/watch?v=kSW1gTBWz4k&t=1s
@kikky7 little too much for me such an upload limit. Maybe check some other solutions. for example, start here: https://www.youtube.com/watch?v=kSW1gTBWz4k&t=1s
That's video for php, on php side it passes. My report is about nginx.