The uploaded file exceeds the upload_max_filesize directive in php.ini

Hi Community,

I am a new comer with Linode. I have installed and configure it already. Now I have installed wordpress. I face the problem is that "The uploaded file exceeds the uploadmaxfilesize directive in php.ini." when I upload my theme. I don't know where I can my php.ini in my server linode.
Please help me and don't mind for my poor english.

Thank you before hand.

4 Replies

This is a tricky issue for people just starting out because there is more than one setting that needs to be changed and multiple places where they can be changed. To further complicate this, each location has a separate way of making the change.

Settings

We can change the "upload_max_filesize" (The maximum size of an uploaded file.), but if we do not increase "post_max_size" (sets the limit on the amount of data we are willing to process in one web request) the space we are willing to give up for the upload will not matter. Sometimes, if we are uploading really big files, we also need to worry about "memory_limit" (the amount of memory we are willing to use to handle one request).

List of php.ini directives

php.ini

Where to find it

You may have an environment variable set which will tell you where it is:

echo $PHPRC

You can look in this path for your php.ini

If this doesn't work, there are some common places to find it:

  • /etc/php.ini
  • /usr/bin/php5/bin/php.ini
  • /etc/php/php.ini
  • /etc/php5/apache2/php.ini

You can also use brute force with the find command (the mumbo jumbo at the end hides all kinds of errors about files you don't have access to):

sudo find / -name 'php.ini' 2&> /dev/null

This command may return more than one location so you may need to use trial and error.

What to change

You will want to change the lines that say

upload_max_filesize = xxxx
post_max_size = yyyy
...

Note that the post_max_size has to be greater or equal to the upload_max_filesize.

.htaccess

You can also change settings on a directory by directory basis. The syntax of this file is different than your php.ini file because we are telling apache to tell php.ini that we are overriding the php.ini for this directory and everything underneath it.

The values we want to add here are:

php_value upload_max_filesize xxxx
php_value post_max_size yyyy
...

Once you have made these changes, you will want to restart your web server and php services to read in the modifications.

Related Question: WordPress file size limit

To add to this post, in case the change doesn't work, you may also want to check if the upload directive needs to be changed in other places such as user init files. Also, as hphillips hinted before, configuration files have different priorities when they are processed so one can overwrite the other. This is explained in the following post:

Which one does Wordpress prioritize when it comes to php.ini, wp-config and .htaccess?

@hphillips writes:

If this doesn't work, there are some common places to find it:

  • /etc/php.ini
  • /usr/bin/php5/bin/php.ini
  • /etc/php/php.ini
  • /etc/php5/apache2/php.ini

Since the advent of PHP 7 or so, php.ini has been centralized in a single place /etc/php:

  • /etc/php/<version>/cli/php.ini
  • /etc/php/<version>/apache2/php.ini
  • /etc/php/<version>/fpm/php.ini

where <version> is the PHP version number and {cli, apache2, fpm} are the operational php.ini's for the command-line, the apache2 plug-in and the fastcgi process manager, respectively.

PHP comes with two native functions to show which config file is loaded:

You can try each one of these out with something like:

php -r 'echo php_ini_loaded_file();'

-- sw

Don't forget to:

user@localhost ~]$ sudo systemctl restart php-fpm httpd

after making any changes to php.ini

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct