/ sysadmin

Fixing File Upload Error - exceeds MaxRequestLen

As you may know, web hosts limit file upload sizes via the php.ini file. It's fairly simple to change the directives in said file to increase the maximum file upload size.

The site I'm working on for GP Church of Christ gives the church content administrator the ability to upload sermon audio files. Being that most sermons are 30+ minutes, the mp3 audio files tend to be larger than 20 MB.

After a few attempted uploads, we were getting this weird error in the server log: mod_fcgid: HTTP request length 16777353 (so far) exceeds MaxRequestLen (16777216). The WordPress uploader showed an HTTP Error dialog, but no elaborate description of the issue.

After a couple days of digging, experimenting, failing all over the place, I came upon this article, which explains perfectly how to overcome this problem.

But let's step back for a minute and examine what really is the problem. My server, is using the FastCGI module for PHP support, rather than Apache. The php.ini file still has directives that govern the ability to do actions like uploading files. In addition to those php.ini directives, there are two locations that govern the FastCGI module and it's upload limits.

  1. The FastCGI global config file, probably at /etc/httpd/conf.d/fcgid.conf.
  2. A domain specific FastCGI config file at /var/www/vhosts/your_domain_name_here/conf/last_httpd_ip_default.include.

Vim into both those files and ensure that the following lines are there and have a value, any value.

<IfModule mod_fcgid.c>
FcgidMaxRequestLen 1073741824

As above, I've got mine set to the default of 1 GB (1 GB = 1073741824 bytes).

Apparently, fcgid settings are also in your virtual hosts file at /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php. Find the same IfModule mod_fcgid.c element and make the same change.

Next, let's reconfigure your domain with Plesk:

/usr/local/psa/admin/bin/httpdmng --reconfigure-domain yourdomain.com

Lastly, restart PSA and Apache:

service httpd restart
service psa restart

Now, you should be good to go! Try uploading a large file under 1 GB.