Increase max filesize for Wordpress files (one click installation)

April 28, 2017 420 views
WordPress Ubuntu 16.04

I want to upload a 50 MB File to my one click wordpress installation.

Wordpress cries that its too big a filesize.

Where are the configurations files I need to edit to set the filesize to mazbe a 100 MB?

3 Answers

@Sternenfisch

WordPress relies on your PHP configuration, so if PHP isn't configured to allow uploads of that size, WordPress will throw an error.

You'll want to modify your PHP's php.ini file and change:

upload_max_filesize

and

post_max_size

The defaults are 2MB and 8MB, so we can adjust those to something higher for your needs. I'd set them as:

upload_max_size = 64M

and

post_max_size = 96M

If you're using NGINX instead of Apache, there's a variable in NGINX's main configuration file that you may also need to change as it also limits the size of uploads, that'd be:

client_max_body_size

You'd need to define that and set it to 64M as well.

client_max_body_size 64m;

You'd then restart Apache, or restart both NGINX and PHP-FPM. It just depends on which you're using.

  • I know that. I want to know where php.ini is located in one click wordpress installation in digitalocean.

    • @Sternenfisch

      The issue isn't that we, as a community, do no read or listen, it's that in many cases, the OP is not 100% clear with all details, so we have to provide a best-guess type of answer.

      When we, as a community, make assumptions, in many cases, they are wrong. Given the trend -- as well as popularity of WordPress, there are more one-click installers than I can count. They all do various things to the server, some of which modify directory structure.

      The default directories for most repositories will be:

      /etc/php/[version]/apache2
      

      or

      /etc/php/[version]/fpm
      

      Where [version] is the version of PHP that was installed.

      That said, not all repositories use that structure, some place the release at the root, so it looks like:

      /etc/php[version]/apache2
      

      or

      /etc/php[version]/fpm
      

      Again, with [version] being your PHP version. The above are different -- the first applies to Apache while the other applies to PHP-FPM and in most cases, NGINX.

      ...

      That being said, I know that you mentioned one-click installer in your OP, though without a reference to whether you used the DigitalOcean one-click, a one-click for cPanel, a one-click for Plesk, etc -- we're just taking a guess.

      ...

      Some installers even use:

      /usr/local/php[version]
      

      or

      /usr/local/php/[version]
      

      ...

      You can also create a PHP info file using:

      <?php phpinfo()
      

      ... name it info.php, access it from the web, and it'll tell you everything about your PHP installation. You could also run php -i from the CLI to get the same but in a less-graphical format.

      ...

      I actually am a sysadmin, though without accessing a system directly, all I have to go on is your post and what you follow up with. From there, I'll do my best to help :-).

      • I appreciate you doing the best you can to help.

        And I am fortunate to have come across this community function to ask questions mind you, while I feel digitalocean being the best suited webhost I have come across so far.

        As for the problem at hand, I have by now modified 4 php.ini I found in various directories in the droplet. None of them have actually been able to modify the upload file size limit.

        Which is what I expect.
        I have studied IT for several years before, and I am aware that it is a highly technical issue.
        What happens however, is that Brother Internet guides you to advice that is outdated, because it outdates really fast.

        So a guide on how to do this for Ubuntu 14.xx doesnt help me, cause now the droplet is ubuntu 16.04, uses a different php, which itself has changed its foldernames and directory structure.

        So I am mainly down to trial and error, and posting questions, hoping that someone actually goes through the process, makes it work and then gives me the steps.

        Cause if there is one thing I can do fast and efficient is to replicate working solutions.

        Figuring out it solutions myself (coding extensions etc) not so much. Just dont got the mental endurance to wrap my head around all the variables involved.

        But like said, I have looked into the structures I found. Now I look into those you mentioned.

        And hope someone comes along who in a scenario similar to mine made it work.

        And as for my comment, its good you are responsive.
        Thanks for that.

        Robert

        • @Sternenfisch

          A sure fire way to see which ini file is being used is to create an info.php file and upload it to the web root (where your index.php file is).

          That file should contain:

          <?php phpinfo();
          

          Now access that using http://yourdomain.com/info.php and the first block will tell you everything you need to know about the file(s) being used.

          You'll want to look for:

          Configuration File (php.ini) Path
          

          Which tells you where the file is...and then:

          Loaded Configuration File
          

          Which tells you which configuration file is loaded and being used. Once changes are made, you need to restart Apache for the changes to take effect.

          service apache2 restart
          

          Delete info.php afterwards as you don't want all that exposed to the public.

  • Also I noticed on an majority of my questions, those posting answers dont bother reading .

    Question was:

    Where are the configurations files

    Not
    What must I change.

    • People are just trying to help you out here mate, they don't do this for living! If you keep being a dick like this they won't help you anymore.

      The configuration files are at /etc/php/7.0/apache2

The configuration files are at /etc/php/7.0/apache2

@Sternenfisch

To help speed things up, I deployed Apache2 + PHP 7.0 on a fresh Droplet.

PHP's php.ini file is located here /etc/php/7.0/apache2/php.ini. Depending on your PHP version, you may need to change that to 5.6 or 7.1.

When editing that file:

nano /etc/php/7.0/apache2/php.ini

And setting:

post_maxsize = 96M

and

upload_max_size = 64M

Then restarting Apache2:

service apache2 restart

The settings are showing as updated as they should be.

This can be confirmed by using:

<?php

$pms = ini_get('post_max_size');
$ums = ini_get('upload_max_filesize');

echo '<pre style="line-height: 2rem;">';
echo '<strong>post_max_size</strong>: ' . $pms;
echo '<br>';
echo '<strong>upload_max_size</strong>: ' . $ums;
echo '</pre>';
  • I just wanted to say that I had the same issue as OP and the information that everyone provided here was excellent. One thing that is frustrating is what value to change. @jtittle1 was great and I used ctrl+w to search for post_maxsize to change the value. Previously I had been searching "upload" and changing the wrong field:


    File Uploads ;
    ;;;;;;;;;;;;;;;;

    ; Whether to allow HTTP file uploads.
    ; http://php.net/file-uploads
    file_uploads = On

    ; Temporary directory for HTTP uploaded files (will use system default if not
    ; specified).
    ; http://php.net/upload-tmp-dir
    ;uploadtmpdir =

    ; Maximum allowed size for uploaded files.
    ; http://php.net/upload-max-filesize
    uploadmaxfilesize = 40M


    Thank you for everyone that posted and if people are still having issues with this, make sure you are searching for the correct term!!

Have another answer? Share your knowledge.