phpwordpressapacheubuntuphp-7.4

Self-hosted Wordpress and unable to successfully adjust the upload_max_filesize


I copied the latest wordpress onto a Linode ubuntu 20.04 server using cURL and was able to deploy it live with apache2 and custom DNS, but have been unable to upload a PRO plugin due to PHP upload_max_filesize issue:

enter image description here

I ran php --ini on the server and here is the output:

Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File:         /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed:      /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.4/cli/conf.d/10-opcache.ini,
/etc/php/7.4/cli/conf.d/10-pdo.ini,
/etc/php/7.4/cli/conf.d/15-xml.ini,
/etc/php/7.4/cli/conf.d/20-bcmath.ini,
/etc/php/7.4/cli/conf.d/20-calendar.ini,
/etc/php/7.4/cli/conf.d/20-ctype.ini,
/etc/php/7.4/cli/conf.d/20-curl.ini,
/etc/php/7.4/cli/conf.d/20-dom.ini,
/etc/php/7.4/cli/conf.d/20-exif.ini,
/etc/php/7.4/cli/conf.d/20-ffi.ini,
/etc/php/7.4/cli/conf.d/20-fileinfo.ini,
/etc/php/7.4/cli/conf.d/20-ftp.ini,
/etc/php/7.4/cli/conf.d/20-gd.ini,
/etc/php/7.4/cli/conf.d/20-gettext.ini,
/etc/php/7.4/cli/conf.d/20-iconv.ini,
/etc/php/7.4/cli/conf.d/20-igbinary.ini,
/etc/php/7.4/cli/conf.d/20-json.ini,
/etc/php/7.4/cli/conf.d/20-mbstring.ini,
/etc/php/7.4/cli/conf.d/20-msgpack.ini,
/etc/php/7.4/cli/conf.d/20-mysqli.ini,
/etc/php/7.4/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.4/cli/conf.d/20-phar.ini,
/etc/php/7.4/cli/conf.d/20-posix.ini,
/etc/php/7.4/cli/conf.d/20-readline.ini,
/etc/php/7.4/cli/conf.d/20-shmop.ini,
/etc/php/7.4/cli/conf.d/20-simplexml.ini,
/etc/php/7.4/cli/conf.d/20-sockets.ini,
/etc/php/7.4/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.4/cli/conf.d/20-sysvsem.ini,
/etc/php/7.4/cli/conf.d/20-sysvshm.ini,
/etc/php/7.4/cli/conf.d/20-tokenizer.ini,
/etc/php/7.4/cli/conf.d/20-xmlreader.ini,
/etc/php/7.4/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.4/cli/conf.d/20-xsl.ini,
/etc/php/7.4/cli/conf.d/20-zip.ini,
/etc/php/7.4/cli/conf.d/25-memcached.ini

In /etc/php/7.4/cli/php.ini, I updated upload_max_filesize (higher and higher all the way up to 512M) and post_max_size and restarted apache, but still hitting the same error. Also added the Upload filesize plugin and set that pretty high as well: enter image description here

At this point I'm wide open to ideas on how this can be resolved. The error message seems pretty cut and dry.

I also attempted to add @ini_set('upload_max_size' , '256M' ); to the wp-config.php to no avail and created a test.php file that echoes the value of upload_max_filesize, which does echo as expected.


Solution

  • Which ini file will be used that depends on the module. You need to edit these configuration files for a wider compatibility:

    /etc/php/7.4/apache2/php.ini
    /etc/php/7.4/cgi/php.ini
    /etc/php/7.4/cli/php.ini
    

    Alternatively, you can create an user.ini file.

    Also, you have to edit at least:

    memory_limit
    max_post_size
    upload_max_filesize
    

    Where value of memory_limit > max_post_size >= upload_max_filesize. For example, you can set the values 10MB, 8MB, 6MB or 8MB.

    Please Note: The above answer is for the setup with MOD PHP. Please read my blog article for the required instructions for MPM Event with PHP-FPM.