Cannot change upload_max_filesize or post_max_size in php.ini

Matt Edmonston picture Matt Edmonston · Nov 7, 2012 · Viewed 24.2k times · Source

Bear in mind, I am no sysadmin, I am just a developer. I cannot find anyone with the exact problem as me, just similar, and none of their "fixes" seem to work.

I am currently running an Amazon EC2 instance running.

CentOS 6.2
Nginx 1.2.2
PHP 5.3.16 with APC
Percona 5.5.24 // not currently using this as I am using an RDS

I have set my php.ini (/etc/php.ini) settings to the following

upload_max_filesize=10M
post_max_filesize=20M

After reloading the config, using php -i via ssh, these settings seemed to be loaded. Showing upload_max_filesize=10M, etc.

When using phpinfo() or ini_get, both options are returned as 4M

phpinfo() indicates that the file I am editing is the one loaded (/etc/php.ini).

I have also run php -i | grep "\.ini" to check which files are loaded, and there are no unnecessary loaded configs. I even went through each loaded file individually to check they didn't have the settings inside.

Additionally, I have been suggested to try using a .user.ini config file. This did not change the values either.

ini_set() does not work either.

I'm at a bit of a loss.

EDIT: not sure this will help, but I am using this AMI http://megumi-cloud.com/

Answer

Rupesh Kumar picture Rupesh Kumar · Jun 9, 2015

Filename:

nginx/sites-available/default

Add:

location ~ \.php$ {
      fastcgi_param PHP_VALUE "upload_max_filesize = 50M \n post_max_size=51M";
}

Run: From command line: sudo service nginx restart