500 server error when uploading large images



After hardening the server by adding extra security and changing the defaults, some php scripts running on the server got affected by the process. Each time i try uploading images higher then x kb i was getting a 500 server error (x is an irrelevant file size to you)

This might seem like a trivial issue such as changing some values inside the php.ini file, like the post_max_size – upload_max_filesize etc , to higher then x kb, but this did not resolve the issue. So i dove into the logs:

/usr/local/apache/domlogs/thedomainname.com
/usr/local/apache/logs/
/var/log/messages

but i was not able to find a recorded error.  I realized that there was a local error log on the domain in mention that is missing. So i created an error log file inside a directory i chose, for ex: touch  /home/domainname/error_catchall then added the following line to the /usr/local/apache/conf/httpd.conf under the domain name values, ex:

<VirtualHost example:80>
    SeverName example.com
    ServerAlias *.example.com
    DocumentRoot /path/to/files/app
    ErroLog /home/example/erro_catchall
</VirtualHost>

then executed the upload script. I finally located the error:

[DATE] [warn] [client XX.XX.XX.XX] mod_fcgid: HTTP request length 131896 (so far) exceeds MaxRequestLen (131072), referer: http://www.example.com/script.php

I knew at least that this is an issue with an installed apache module: mod_fcgid. Which means a tweak to ” FcgidMaxRequestLen”  needs to be added to the httpd.conf file. But because recompiling apache will wipe out this configuration, i added it from whm–>apache configuration –>include editor –>pre main include.

i added the following: 
FcgidMaxRequestLen 1073741824

and restarted apache.

Problem Solved!