modfcgid: MaxRequestLen
How to Fix mod_fcgid MaxRequestLen Error While Uploading Files
Introduction
When uploading files in applications such as WordPress, Joomla, or other PHP-based websites, you may encounter upload failures due to the mod_fcgid request size limitation. This issue occurs when the uploaded file exceeds the configured MaxRequestLen value in the Apache FCGI configuration.
This guide explains how to identify and resolve the issue by increasing the MaxRequestLen value.
Prerequisites
- Root or sudo access to the server
- Access to the Apache configuration files
- Ability to restart the Apache service
Implementation
Step 1: Verify the Error in Apache Logs
Check the Apache error log for messages similar to the following:
tail -f /usr/local/apache/logs/error_log | grep domainname.com
Example output:
[warn] [client 203.197.151.138] mod_fcgid: HTTP request length 131274 (so far) exceeds MaxRequestLen (131072)
[error] [client 203.197.151.138] File does not exist: /home/domain/public_html/500.shtml
This indicates that the upload request size has exceeded the configured MaxRequestLen limit.
Step 2: Locate the FCGI configuration file.
Find the PHP FCGI configuration file for the affected domain.
A common location is:
/usr/local/apache/etc/userdata/std/2/domain/domainname.com/phpini.conf
Step 3: Edit the Configuration File
Open the configuration file using your preferred editor.
vi /usr/local/apache/etc/userdata/std/2/domain/domainname.com/phpini.conf
Step 4: Increase the MaxRequestLen Value
Add or modify the following directive:
MaxRequestLen 15728640
The configuration should look similar to:
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 20
MaxRequestLen 15728640
Step 5: Save the Configuration
Save the changes and exit the editor.
Step 6: Restart Apache
Restart the Apache service for the changes to take effect.
service httpd restart
Step 7: Verify File Uploads
Attempt to upload the file again through the application.
If the upload completes successfully, the issue has been resolved.
Conclusion
The mod_fcgid MaxRequestLen error occurs when the HTTP request size exceeds the configured upload limit. By increasing the MaxRequestLen value in the domain’s FCGI configuration file and restarting Apache, larger file uploads can be processed successfully in applications such as WordPress and Joomla.
