Katafalkas
Katafalkas

Reputation: 993

php nginx max upload file size - unusual case

I was going through number of pages in google and pretty much all answers associated with this in stackoverflow, bus still, can not get this thing working.

I can upload smaller then 2M files, but not any larger.

I am running Centos 6.2 with PHP-FPM (PHP 5.3.10) and NGINX (nginx version: nginx/1.0.12).

Now I got client_max_body_size 10M; in nginx.conf, in the http section. I also got upload_max_filesize = 8M , post_max_size = 8M , memory_limit = 128M

usually in almost any answer to this question I have met, these changes helps for users.

Now I done some research, and made this script:

<?php
//ini_set('upload_max_filesize', '8M');
$max_upload   = (ini_get('upload_max_filesize'));
$max_post     = (ini_get('post_max_size'));
$memory_limit = (int) (ini_get('memory_limit'));

echo ('$max_upload ' . $max_upload);
echo ('$max_post ' . $max_post);
echo ('$memory_limit ' . $memory_limit);
?>

Now If I run in in server terminal - i get $max_upload 8M $max_post 8M $memory_limit 128 But if I run it via webserver (NGINX) - I get $max_upload 2M $max_post 8M $memory_limit 128

So my assumption is that its NGINXes problem, but yet again the only NGINX parameter regarding this matter is client_max_body_size 10M; , which is sec correctly and is placed in the right place in the config.

I am sorry if this is something obvious, or if there is something I have missed, would be glad if someone would point me to the right direction.

Cheers !

EDIT:

So we solved it with AlexeyKa's help. We looked up in phpinfo, and there it said that php was using different php.ini file. Some time ago I made a copy of php.ini into my home directory. And it turnes out that when (some time ago) I restarted php-fpm, it switched from /etc/php.ini file to /home/my-user/php.ini file. Essentially I renamed the /home/my-user/php.ini and restarted the php-fpm. This solved everything, as it switched to /etc/php.ini. I will try to this behavior further, and will update the post, just in case someone will have the same problem.

Upvotes: 0

Views: 10540

Answers (2)

Gregory Hanis
Gregory Hanis

Reputation: 51

change in

/etc/php5/fpm/php-fpm.conf

and /etc/php5/cli/php.ini to be safe and change where it has

upload_max_filesize = 2M

to whatever file size u want example

upload_max_filesize = 8M

then reload

/etc/init.d/php5-fpm restart
/etc/init.d/nginx reload
/etc/init.d/nginx restart

Upvotes: 0

AlexeyKa
AlexeyKa

Reputation: 558

May be different php.ini used? One for php-cli and another for php-fpm?

Upvotes: 2

Related Questions