When running PHP applications under Apache using mod_fcgid combined with suexec privilege separation, web requests may suddenly abort with HTTP 500 Internal Server Errors and the following message in Apache error logs:
Error Message:
End of script output before headers: php.fcgi • mod_fcgid: error reading data from FastCGI server
Root Cause
suexec enforces strict security checks on the FastCGI wrapper script and user directory:
- The wrapper script and parent directories must be owned exclusively by the virtual server user and group—not
rootorapache. - File permissions cannot be group-writeable (
chmod 755is required,775or777causes instant suexec rejection). - The target script must reside strictly inside the compiled
suexecdocument root (e.g./home/user/public_html).
Resolution Steps
Inspect /var/log/httpd/suexec.log to reveal the exact permission violation, and enforce correct ownership:
# Fix permissions and ownership
chown -R user:user /home/user/fcgi-bin /home/user/public_html
chmod 755 /home/user/fcgi-bin/php.fcgi
chmod 755 /home/user/public_html