I imported virtual servers (webmin & virtualmin installed on ubuntu 8.10 that had already some sites configured) but I’m struggling with sites that use cgi scripts.
When a cgi script is called, I get lots of 500 and messages like:
Error: Can’t open for output counter file. Reason: Permission denied
So I guess it must be a permission issue. First I thought it might be a folder thing, as virtualmin seems to want things to be in /public_html although the original sites were and are at /user/htdocs. But simple html files work fine.
What am I to do?
Well the error log doesn’t help a lot
[Thu May 21 00:45:16 2009] [error] [client 220.127.116.11] (2)No such file or directory: exec of ‘/home/default/-domain-.com/user/htdocs/cgi-bin/links/search.cgi’ failed, referer: http://www.-domain-.com/
[Thu May 21 00:45:16 2009] [error] [client 18.104.22.168] Premature end of script headers: search.cgi, referer: http://www.-domain-.com/
Well, the script is there, and if I call a ‘hello world’ perl script in the same folder it works fine. The search.cgi script is reading a lot of other files. All this worked fine before “importing the virtual server”. So I was hoping this something you’ve seen happening before when importing servers and that it’d be easy to solve…
I’ll continue ‘playing’ with it now.
And thanks for your answer!
Well, just to be super-sure – if you do a:
ls -l /home/default/-domain-.com/user/htdocs/cgi-bin/links/search.cgi
It sees that there okay?
Here you go:
root@ubuntu:/home/default/-domain-.com/user/htdocs/cgi-bin/links# ls -l
-rwxr-xr-x 1 gci matrixdomain 4217 2009-05-06 01:39 rate.cgi
-rwxr-xr-x 1 gci matrixdomain 10847 2009-05-06 02:04 report.cgi
-rwxr-xr-x 1 gci matrixdomain 10812 2009-05-06 02:05 report.cgi-new.html
-rwxr-xr-x 1 gci matrixdomain 10729 2009-05-06 02:05 report.cgi.old.html
-rwxr-xr-x 1 gci default 13298 2009-05-20 23:53 search.cgi
-rwxr-xr-x 1 gci matrixdomain 11966 2009-05-06 01:39 search.cgi.10-12-99
-rwxr-xr-x 1 gci matrixdomain 6764 2009-05-06 01:39 subscribe.cgi
-rwxr-xr-x 1 gci default 2597 2009-05-06 02:04 test.cgi
So yes, I’m sure.
So, the group ownership looks suspicious. I don’t know if it’s causing this particular problem…but suexec is very particular about permissions and ownership.
You might check the suexec_log for more on what suexec is thinking.
First of all: I really appreciate how fast you’re answering here, that’s quite unbelievable.
About suexec, I’ve disabled that. You see, before installing webmin and virtualmin, I tried it on the server and it made most of the dynamically perl driven sites stop working. So after installing virtualmin, that was an apache mod (I think which I’ve disabled. (Together with google I found out how to do it.)
So it can’t be suexec. (I think)
About the groups as you see them: they were all matrixdomain first, but I tried changing that to ‘default’ as you can see, as that’s the group they’re in. But still, they worked before, and changing matrixdomain to default had no effect. Neither on test.cgi, that one simply worked with both groups…
Ah, then since it’s not using suexec, the Apache user needs to be able to get there and run those apps.
Ordinarily, in a system installed using install.sh Apache is automatically added to the group of each new virtual server (which allows slightly tighter permissions on homes). But, since you’re using a distro unsupported by the install script, you may have skipped that step. Apache might not be able to get to that script.
Try adding the apache user (www-data, I think on Ubuntu) to the "default" group in /etc/groups. Restart Apache, and see what happens.
I think that was already the case. In /etc/group I found:
All sites are in those two groups.
I dunno. You’ve got me stumped. Is the path leading up to it all 750 or greater? (group needs to have execute permission all the way up the path)
Would you like/mind to have a look at the server yourself?
(forgot to mention all folders in the path seem chmodded right (755))
I can take a peek if you like.
What I’d need are:
Root login details
The URL you use to access the CGI script that’s not working
And if you could include a link to this forum post in the message body, that’d be helpful
You can email the above to email@example.com.
Okay, I think I see the large problem that was causing the 500 error.
The path to Perl was set to /usr/local/bin/perl, rather than where Perl is on your system, /usr/bin/perl.
I updated that in your script.
At this point, you get a different error, but one that’s a bit easier to understand It’s now saying it can’t open the search log file.
Now, it wasn’t specific about what or where the file was – I added some custom code to your script to list the path to the file it was trying to open, so now the problem should be more apparent.
However, I’ll leave it to you to take from here
Try loading that URL again, and the error you see should help out now.
Yell if you have any questions
Thanks a lot!
crazy no, how something like that could have happened? Seems strange it didn’t produce the error before switching over to webmin/virtualmin. To be honest, I immediately thought all cgi scripts, or lots of them, would now not work and was not looking forward to lots of hours of correcting it all. So I’m kind of happy now.
Thanks a lot, really.
Now off trying to find out why the server is not sending mails anymore…