amandajames's picture

I am uploading a theme to WordPress, and installing it but it shows me the following ERROR:
The uploaded file exceeds the upload_max_filesize directive in php.ini.

I have already gone through a tutorial to increase upload size limit. It shows to put the code in PHP.ini file.

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 30M

I am not finding the PHP.ini file in root directory. Can someone help me to resolve this issue?

Forum: 
Jeremy Davis's picture

There are a few different ways to work around the issue that you're hitting.

To explicitly answer your question first, you should find 2 php.ini files on TurnKey WordPress. Assuming TurnKey v15.x, one should be /etc/php7.0/apache2/php.ini and the other should be /etc/php7.0/cli/php.ini. As the names suggest, the first is for PHP when running under the webserver (Apache). Whilst the other is when PHP is running from the commandline.

To change WordPress upload filesize limits, you'll want to edit the first one (for Apache). If it's an earlier (or yet to be released; newer) version of TurnKey, then the path might be slightly different as it includes the php version; i.e. 'php7.0' in this case. Regardless, this should allow you to edit it:

nano /etc/php*/apache2/php.ini

(It's worth noting that if you had multiple versions of PHP installed, then that command would edit them all, one after the other).

For the change to be implemented by the webserver, you'll also need to restart Apache:

service apache2 restart

Now you should be good to go!

For future reference, on Linux, generally system config files are located in /etc. A really handy commandline tool for finding files is 'find'. E.g. to search '/' (everywhere) for a file (directory is the other main type option) named "php.ini":

find / -type f -name "php.ini"

It's probably worth further noting, that editing the php.ini file can also be done via the Web based admin UI Webmin, which is installed on all TurnKey servers by default. Webmin is available via https on port 12321. I.e. https://YOUR_SERVER_IP_OR_DOMAIN:12321 (where YOUR_SERVER_IP_OR_DOMAIN is replaced with your actual IP or full domain name). I forget exactly where the PHP config is (I don't use Webmin much myself), but it should be quite easy to find.

However, there are other ways that you could upload the file too.

Again Webmin includes a "file manager" which would allow you to upload the file that way.

Another option would be to upload the desired file via SFTP (using an FTP client such as Filezilla or WinSCP). TurnKey includes SFTP enabled by default and there are no file size restrictions on uploading directly. Although it is worth noting that the file will be owned by the user uploading the file (most likely root) so that you would likely need to change the ownership before WordPress could do anything with it.

I hope that all helps...

Add new comment