Unable to change upload_max_filesize or post_max_size in php.ini

Remember, I'm not a sysadmin, I'm just a developer. I can’t find anyone with the exact problem, as I just look alike, and none of their “fixes” seem to work.

I am currently running an instance of Amazon EC2.

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 set my php.ini settings (/etc/php.ini) to the following

 upload_max_filesize=10M post_max_filesize=20M 

After reloading the configuration using php -i via ssh, these settings seemed to be loaded. Mapping 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 uploaded ( /etc/php.ini ).

I also launched php -i | grep "\.ini" php -i | grep "\.ini" to check which files are downloaded and there are no extra configurations loaded. I even looked at each downloaded file separately to check that they had no settings inside.

In addition, I was offered to try using the .user.ini configuration file. It also did not change the meaning.

ini_set() does not work either.

I lost a little.

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

+7
source share
8 answers

I contacted the guys who did AMI and found out that there are additional configuration files that override php.ini

There are 2 files that contain settings

 /etc/php-fpm.d/www.conf // This is the file which holds upload_max_filesize and post_max_size, among others /etc/php-fpm.conf 

Obviously, places can vary in different configurations, but hopefully this helps someone to figure out what else to look for.

+3
source

File name:

 nginx/sites-available/default 

Add

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

Run: From the command line: sudo service nginx restart

+12
source

Try the command as follows:

 php --ini 

It will show you which ini files are downloaded by php.

Output Example:

 [ admin@staging ~]$ php --ini Configuration File (php.ini) Path: /usr/local/etc Loaded Configuration File: /usr/local/etc/php.ini Scan for additional .ini files in: /usr/local/etc/php Additional .ini files parsed: /usr/local/etc/php/extensions.ini 
+5
source

If you explicitly set these values ​​in your php.ini file and they do not match when you run the PHP script, then something has redefined them. You know that your php.ini settings are correct, because in the CLI version of PHP, the information shows the new settings.

I also run php -i | grep ".ini" to check which files are downloaded and there are no extra configurations loaded. I even looked at each downloaded file separately to check that they had no settings inside.

This is great, but it tells you which .ini files were downloaded from the PHP CLI, not your application.

You need to check the parsing section of the extra .ini files of your phpinfo() output to see which files are downloaded from your web server. One of these files overrides your settings.

Finally, if none of these files becomes the culprit, you should make a global find ini_set() in your project to make sure that some rogue script does not set these values ​​for you (trying useful).

Keep digging, you will find the culprit in one of these two places.

+2
source

I had the same problem as a PHP application complaining about upload file size. Using the lilne version of php command (php -ini), I defined the php.ini file as follows: / etc / php 5 / cli / php.ini

with php -info I checked the settings. but still the application gave me the same error. I found that PHP has different ini files for CLI and Apache. Check the / etc / php 5 folder, which has apache2 and cli files with separate internal ini files. Just change / etc / php 5 / cli / php.ini to change apache settings.

+1
source

Reboot the web server. That is all you have to do.

0
source

Remember, I'm not a sysadmin, I'm just a developer. I can’t find anyone with the exact problem, as I just look alike, and none of their “fixes” seem to work.

I was in the same boat with the same problem, and it turned out that they were connected!

I included lines to increase upload_max_filesize and post_max_size , but they were ignored, and phpinfo() returned the default values. I restarted Apache and also checked the added extra .ini files without joy.

The solution was that I added my lines to increase these options near the beginning of the file, and they were overwritten later in the same file!

So, if you have this problem, make sure that you are not making the same stupid mistake as I, and Ctrl-F to find the original instance of the ad, and then edit it and not add your own; )

0
source

You can solve this problem by updating your www.conf file as my lists https://gist.github.com/dleone81/de311bee44c44a7ce8813cd17a5e9af9

0
source

All Articles