Domain unable to execute CGI scripts
Running AlmaLinux v8.10.0 with cPanel & WHM v130.0.16 (STANDARD)
I’ve been pulling my hair out for two days now and have pretty much given up. I have a single domain that is unable to execute CGI scripts. When the script is executed, I get a 500 Internal Server Error, and when that exact same script is tested on other domains on the same server, it works.
Some facts:
- CGI Privilege – Enabled
- Script is in /cgi-bin/ and chmod 755
- Shebang is correct
- Nothing in .htaccess preventing execution (ie. Options -ExecCGI)
- Tried adding Options +ExecCGI to .htaccess
Not sure what else I can do. As a last hope, I am hoping someone can see something in the httpd.conf file that I am missing:
<VirtualHost IP_HERE:80>
ServerName USERDOMAIN.com
ServerAlias mail.USERDOMAIN.com www.USERDOMAIN.com
DocumentRoot /home/USERDOMAIN/public_html
ServerAdmin webmaster@USERDOMAIN.com
UseCanonicalName Off
## User USERDOMAIN # Needed for Cpanel::ApacheConf
<IfModule userdir_module>
<IfModule !mpm_itk.c>
<IfModule !ruid2_module>
<IfModule !mod_passenger.c>
UserDir disabled
UserDir enabled USERDOMAIN
</IfModule>
</IfModule>
</IfModule>
</IfModule>
# Enable backwards compatible Server Side Include expression parser for Apache versions >= 2.4.
# To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
# the user's .htaccess file. For more information, please read:
# http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
<IfModule include_module>
<Directory "/home/USERDOMAIN/public_html">
SSILegacyExprParser On
</Directory>
</IfModule>
<IfModule suphp_module>
suPHP_UserGroup USERDOMAIN USERDOMAIN
</IfModule>
<IfModule suexec_module>
<IfModule !mod_ruid2.c>
SuexecUserGroup USERDOMAIN USERDOMAIN
</IfModule>
</IfModule>
<IfModule ruid2_module>
RMode config
RUidGid USERDOMAIN USERDOMAIN
</IfModule>
<IfModule mpm_itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID USERDOMAIN USERDOMAIN
</IfModule>
<IfModule mod_passenger.c>
PassengerUser USERDOMAIN
PassengerGroup USERDOMAIN
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ /home/USERDOMAIN/public_html/cgi-bin/
</IfModule>
# Global DCV Rewrite Exclude
<IfModule rewrite_module>
RewriteOptions Inherit
</IfModule>
# To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/std/2_4/USERDOMAIN/USERDOMAIN.com/*.conf"
</VirtualHost>
<VirtualHost IP_HERE:443>
ServerName USERDOMAIN.com
ServerAlias mail.USERDOMAIN.com www.USERDOMAIN.com
DocumentRoot /home/USERDOMAIN/public_html
ServerAdmin webmaster@USERDOMAIN.com
UseCanonicalName Off
## User USERDOMAIN # Needed for Cpanel::ApacheConf
<IfModule userdir_module>
<IfModule !mpm_itk.c>
<IfModule !ruid2_module>
<IfModule !mod_passenger.c>
UserDir disabled
UserDir enabled USERDOMAIN
</IfModule>
</IfModule>
</IfModule>
</IfModule>
# Enable backwards compatible Server Side Include expression parser for Apache versions >= 2.4.
# To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
# the user's .htaccess file. For more information, please read:
# http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
<IfModule mod_include.c>
<Directory "/home/USERDOMAIN/public_html">
SSILegacyExprParser On
</Directory>
</IfModule>
<Proxymatch ^https?://127\.0\.0\.1:(2082|2083|2077|2078|2079|2080|2086|2087|2095|2096)/>
<IfModule security2_module>
SecRuleEngine Off
</IfModule>
<IfModule security3_module>
modsecurity_rules 'SecRuleEngine Off'
</IfModule>
</Proxymatch>
<IfModule mod_suphp.c>
suPHP_UserGroup USERDOMAIN USERDOMAIN
</IfModule>
<IfModule suexec_module>
<IfModule !mod_ruid2.c>
SuexecUserGroup USERDOMAIN USERDOMAIN
</IfModule>
</IfModule>
<IfModule ruid2_module>
RMode config
RUidGid USERDOMAIN USERDOMAIN
</IfModule>
<IfModule mpm_itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID USERDOMAIN USERDOMAIN
</IfModule>
<IfModule mod_passenger.c>
PassengerUser USERDOMAIN
PassengerGroup USERDOMAIN
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ /home/USERDOMAIN/public_html/cgi-bin/
</IfModule>
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /var/cpanel/ssl/apache_tls/USERDOMAIN.com/combined
SSLUseStapling off
<Directory "/home/USERDOMAIN/public_html/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
</IfModule>
# To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/ssl/2_4/USERDOMAIN/USERDOMAIN.com/*.conf"
</VirtualHost>
-
Hey there! Since you've already done extensive troubleshooting on this it might be best to create a ticket so this can be examined on the server directly. Do you see anything in the main Apache log (/etc/apache2/logs/error_log) when the 500 error happens that may provide more clues?
0 -
Thanks for the reply, this is what I see:
[Mon Nov 10 06:29:11.164777 2025] [cgid:error] [pid 675625:tid 675776] [remote MY_IP] End of script output before headers: test.cgi
[Mon Nov 10 06:29:12.272054 2025] [cgid:error] [pid 849745:tid 849745] (2)No such file or directory: AH01241: exec of '/home/USERDOMAIN/public_html/cgi-bin/test.cgi' failedTo keep it simple, this is the test script - which works fine on other domains:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World!";0 -
Thanks for that - could you check the PHP handler for that domain in WHM and see if that's different than other domains on the system?
0 -
This domain is inheriting 8.1 as are the other domains: Inherit - PHP 8.1 ( ea-php81 )
After some more digging and reading, I did find that if I add -w to the end of my shebang, everything works. So that makes this an encoding error? I still would like to figure out why this is only happening on this one domain.
0 -
That part I'm not sure - it might be best to open a ticket.
0
Please sign in to leave a comment.
Comments
5 comments