The maximum size of an upload and maximum post size is not changed in wordpress settings but with php settings. PHP loads different settings for different programs/uses. PHP loads different php.ini in regular CLI use vs. apache2/webserver use. You will see this here.

MAKE SURE YOU HAVE SSH ACCESS TO YOUR SERVER AND SOME LINUX KNOWLEDGE

(0)
First find out where in your system the upload_max_filesize changes

cd /etc
egrep -ir “upload_max_filesize” *

NOTE THE LOCATIONS

Go to /var/www or whereever your wordpress is
cd /var/www
egrep -ir “upload_max_filesize” *

NOTE THE LOCATIONS (ideally you shouldnt be changing it here – you should just change the global php settings for your app, being apache2, from /etc)

(1)
First make a test.php file to see the current phpinfo.

vi /var/www/test.php

<?php
phpinfo();
?>

Save and exit

Or download the following wordpress plugin: WordPress phpinfo()
Activate the plugin
Load it from Tools->phpinfo()

(2)
Then go to
www.yoursite.com/test.php

Look for “Loaded Configuration File”

And note its value for me its:
/etc/php5/apache2/php.ini

This is the file we will need to change the upload_max_filesize

(3)
Notice that the above phpinfo() is different then if you run it from command line(CLI):

php -i
php -r “phpinfo();”
echo “<?php phpinfo(); ?>” | php

And here is

php -i | egrep “Loaded Configuration File|upload_max_filesize|post_max_size”
php -r “phpinfo();” | egrep “Loaded Configuration File|upload_max_filesize|post_max_size”
echo “<?php phpinfo(); ?>” | php | egrep “Loaded Configuration File|upload_max_filesize|post_max_size”

PHP loads different ini files for apache

(4)
On the site www.yoursite.com/test.php notice that .ini files for PHP apache settings are also loaded from:
Scan this dir for additional .ini files: /etc/php5/apache2/conf.d
Additional .ini files parsed: /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini

So go to that folder
cd /etc/php5/apache2/conf.d
egrep -ir “max_upload_size|post_max_size” *

Note if any of those files are changing max_upload_size

(5)
Go to /etc/php/apache2/php.ini and any other files that you might of found in step 4 that change the max_upload_size or post_max_size and change them to match what you want
vi /etc/php/apache2/php.ini

Type ESCAPE (this will ensure your in normal mode, by default you should be in this mode)
/max_upload_size ENTER
that should locate the first (and hopefully only instance of max_upload_size)

Change it from:
upload_max_filesize = 2M

To (type i to get to edit mode, when done hit ESCAPE to go to normal mode):
; upload_max_filesize = 2M
upload_max_filesize = 64M

Then change post_max_size
/post_max_size ENTER

Change it from:
post_max_size = 8M

To (type i to get to edit mode, when done hit ESCAPE to go to normal mode):
; post_max_size = 8M
upload_max_filesize = 64M

Save and exit

SIDE NOTE:
If you leave it like this
upload_max_filesize = 8M
upload_max_filesize = 64M
Then it will also work, the last setting loaded stays

SIDE NOTE:
The settings go under the [PHP] section of php.ini file, just if you do that you will notice [PHP] located at the top, so you might skip looking around for the extra variable initiations lower in the settings file (the ones that will be loaded are the lower ones). So dont forget to look for extras.

(6)
service reload apache2
NOTE: restart not necessary

Then go to www.yoursite.com/test.php

Looks for your “max_upload_size” and “post_max_size” hopefully they are the right size now. If not check out step 6 (remember how we made a note of the files in /etc/php/apach2

(6)

Confirm the settings first go to /etc/
cd /etc
egrep -ir “max_upload_size|post_max_size” *
Make sure you dont have any .ini files that change “max_upload_size” OR “post_max_size” in this folder /etc/php/apache2/conf.d settings, why? because they are read last and they.
Its okay if the lines begin with a ; because thats a comment.
If you have any culprits just edit them with “vi” you can either comment out the line that change “max_upload_size” OR “post_max_size”, or delete the line “max_upload_size” OR “post_max_size”

After that go to /var/www or whereever wordpress is
cd /var/www
and repeat the egrep there, and if you see culprits, edit them or comment them or delete them.
LOOKING THRU THE COMMENTS TIP
==============================

TIP: php.ini has alot of comments, if you want to see it without the comments
cat php.ini | sed “/^;/d;/^$/d”
NOTE: “/^;/d” this part deletes all of the lines starting with comment characters “;” and we are left with a blank line in its place. Now we get rid of the blank line with “/^$/d”. So combining “/^;/d” then “/^$/d” = “/^;/d;/^$/d” (note: with sed you glue two sed commands also with ;, so it does look confusing – my apologies – but i didnt make sed)
TIP: if you want to save it like that, but beware im not responsable for loss of comments or loss of everything working
cp php.ini php.ini.bak
cat php.ini | sed “/^;/d;/^$/d” > php.ini

Leave a Reply

Your email address will not be published. Required fields are marked *