• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

cgi-bin scripts will not run (perl)

M

mmcbee

Guest
This seems to be an issue in other parts of the forum but I am unable to find a solution

I cannot run the simplest of scripts in the "cgi-bin" directory in the root of any vhost domain. So as a qiuck fix I created a "cgi-local" directory in httpdocs and the scripts run fine

The os and plesk version is Fedora Core 2 + PSA v7.5.2

Error log shows:
[Tue Apr 26 10:32:16 2005] [error] [client ] failed to open log file /var/log/httpd/suexec_log
[Tue Apr 26 10:32:16 2005] [error] [client ] fopen: Permission denied
[Tue Apr 26 10:32:16 2005] [error] [client ] Premature end of script headers: test.pl

suexec_log shows
[2005-04-26 10:32:16]: uid: (10006/megamikersg) gid: (10001/10001) cmd: test.pl

suexec is as follows:
ls -la /usr/sbin | grep "suexec"
-r-s--x--- 2 root apache 18832 Jan 28 01:31 psa-suexec
-r-s--x--- 2 root apache 18832 Jan 28 01:31 suexec
-r-s--x--- 1 root apache 10856 Nov 12 10:21 suexec.saved_by_psa
-r-s--x--- 1 root apache 18692 Dec 8 10:39 suexec.saved_by_psa.01.10;05:42
-r-s--x--- 1 root apache 18692 Dec 16 05:31 suexec.saved_by_psa.02.07;15:26
-r-s--x--- 1 root apache 18692 Nov 17 10:41 suexec.saved_by_psa.11.23;12:03
-r-s--x--- 1 root apache 18692 Nov 22 14:26 suexec.saved_by_psa.11.29;13:04
-r-s--x--- 1 root apache 18692 Nov 25 05:54 suexec.saved_by_psa.12.10;15:43


Any help would be appreciated

Thank you

Mike
 
hi there,

hmm i would suggest, that you post the content of any customer's conf/httpd.includ


regards
manuel
 
Well after messing around with this for 8 hours, it started working. Of course I have no idea why, but I am not going to complain.

Thanks:
 
well lucky you mmcbee...
unfortunately I am still looking for the elusive answer.

alfmanuel asks for contents of customer httpd conf.include files - but this is a brand new install (rhel 7.5.2) so there are no customers yet. just one virgin domain - without a working cgi-bin

this is a problem I've seen documented elsewhere but I havent found a working solution yet

any clues or tips for this apreciated, and also to the problem with squirrelmail that cant/wont create directories
 
plesk, i think, has hundreds of configuration variants.
so post the httpd.include of a domain.
 
I guess I spoke to soon, I created a new shared domain and now that domain will not work within the cgi-bin, same issue and errors as above. However the privious domain I crerated still works

No vhost.conf file created.

httpd.include is: ( I tried with and without FollowSymLinks)

# ATTENTION!
# DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK
# FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM
# MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE
# FOLLOWING FILE(S):
# /home/httpd/vhosts/mydomain/conf/vhost.conf
# /home/httpd/vhosts/mydomain/subdomains/<subdomain-name>/conf/vhost.conf

<VirtualHost myIPaddress:80>
ServerName mydomain:80
ServerAlias www.mydomain
UseCanonicalName Off
SuexecUserGroup domainadmin psacln
ServerAdmin "[email protected]"
DocumentRoot /home/httpd/vhosts/mydomain/httpdocs
CustomLog /home/httpd/vhosts/mydomain/statistics/logs/access_log combined
ErrorLog /home/httpd/vhosts/mydomain/statistics/logs/error_log
<IfModule mod_userdir.c>
UserDir /home/httpd/vhosts/mydomain/web_users
</IfModule>
ScriptAlias /cgi-bin/ /home/httpd/vhosts/mydomain/cgi-bin/
Alias /plesk-stat /home/httpd/vhosts/mydomain/statistics/
Alias /webstat /home/httpd/vhosts/mydomain/statistics/webstat
Alias /webstat-ssl /home/httpd/vhosts/mydomain/statistics/webstat-ssl
Alias /ftpstat /home/httpd/vhosts/mydomain/statistics/ftpstat
Alias /anon_ftpstat /home/httpd/vhosts/mydomain/statistics/anon_ftpstat
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory /home/httpd/vhosts/mydomain/httpdocs>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Files>
</IfModule>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_value open_basedir "/home/httpd/vhosts/mydomain/httpdocs:/tmp"
</IfModule>
Options +Includes +ExecCGI
</Directory>
<Directory /home/httpd/vhosts/mydomain/web_users>
<IfModule sapi_apache2.c>
AddType text/plain .php .php4 .php3 .phtml
php_admin_flag engine off
</IfModule>
</Directory>
<Directory "/home/httpd/vhosts/mydomain/statistics">
AuthType Basic
AuthName "Domain statistics"
AuthUserFile /home/httpd/vhosts/mydomain/pd/d..plesk-stat
require valid-user
</Directory>
Alias "/error_docs" "/home/httpd/vhosts/mydomain/error_docs"
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
</VirtualHost>
 
Ok,

It turns out that permission on my site were for lack of a bettter word "broken". In fact /usr/sbin/suexec did not have a suid bit set.
-r-s--x--- root apache


Dont ask how that is set it is over my head and I had to have someone look into the problem they fixed it and told me that was part of the problem. I do not know the chmod for -r-s--x---

My permissions were also wrong for the following
/var/log/httpd, should be
drwx------ root root

/var/log/httpd/suexec_log, should be
-rw-r--r-- root root

/home/httpd/vhosts/your-domain-name.com/statistics, should be
dr-xr-x--- root psaserv
and
/home/httpd/vhosts/your-domain-name.com/cgi-bin
should be,
drwxr-x--x ftpuser psaserv

As most of you know but just in case scripts in the cgi-bin directory need to be -rwxr-xr-x ftpuser psacln

Replace "ftpuser" with the ftp user name for that domain

I am sure there are others here that can chime in with an explantion as to the suid bit information.

Please keep in mine I am on FedoraCore 2 Linux 2.6.9-041221 and Plesk psa v7.5.2_build75050204.17

All I can tell you now is that all my PERL scripts now work, and I hope any of this can help some figure out why thier scripts do not work in the CGI-BIN.

I just wanted to report my outcome.

All the best,

Mike
 
Hello. To solve this problem for a customer who needed it resolved urgently, we commented out the line:

SuexecUserGroup username psacln

in httpd.include and restarted Apache. I realize that you're not supposed to modify httpd.include, however, like I say, it was an emergency.

I didn't like this solution, so later in the evening I un-commented-out that entry and restarted apache, then ran the test script, and suddenly it works fine with suexec enabled. Does anybody know the answer to this mystery?

Thanks
 
I've the same problem too and fixed the problem by restored the /usr/sbin/suexec from the previously backup
 
Back
Top