cgi-bin not working

elbarto

Verified User
Joined
Oct 8, 2008
Messages
133
Hi, could someone tell me how to enable the cgi-bin folder to use perl scripts?

If I go to edit the user he has CGI-bin enabled. Now, when he goes to http://domain.com/cgi-bin/script.pl he can see the perl code instead of its execution result:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<html><header><title>Hola Mundo</title></header><body>";
print "<font face=verdana size=2>Hola Mundo<br><br>";
print "</body></html>";

Is there anything else that I should configure/check in order to make this work?

Thanks in advance!
 
I just checked and it wasn't installed.
I installed it using custombuild, running ./build mod_perl
Then restarted Apache and tried again.

At first I thought it wasn't working, because I tried and got the same message. Then I realized I was trying accessing via http://ip-address/~user/cgi-bin/script.pl, and thought that could be a problem. So I tried with the domain and now it works.

However, I think it's awful that it isn't working via IP address... specially because everyone can see the sourcode. How can I fix this?

Thanks!
 
Sorry, my last message is wrong.
It is working when I use the domain in the address because the domain is pointing to another server (duh!).

So... I installed mod_perl but it's still not working. Any ideas?
 
Is cgi turned on at the reseller level for that user?

You may need to test it by pointing the new IP# to the domain name in your local machine hosts file.

Jeff
 
You don't have to have mod_perl installed for a perl cgi script to run. Its running as a cgi script, not an apache module.

You say its not working but you don't tell us what type of error you are getting. "Not working" does not help us at all to help you. You have to tell us what "is" happening.

What does the error log say? If a cgi script is failing there will be an entry in the error log.
 
@floyd: as I said the problem was that the script wasn't being executed and rather its contents were displayed

Anyway, I took jlasman's advice and pointed the domain to the new address in my hosts file... then I tested it again and I saw a 500 Apache error. I saw the logs and found a permissions problem (the folder and the file could be written by others). I corrected that and now it's working with the domain name in the URL.

However, I'm still getting the same error when I open the script through IP/~user/cgi-bin/script.pl

Is it possible to fix this? Mostly for security reasons.
 
BTW, I also checked Apache's logs while requesting the script via IP address and couldn't find any log at all... not even access logs...
I checked on the main access_log and the domain's access_log. Where should that appear?
 
I wish vBulletin would wrap shorter so I could read an entire line.
My brain misses the last half of the line unless I concentrate on it.

Still it doesn't have anything to do with mod_perl for sure.
 
Do you have this in the main httpd.conf file:

Code:
AddHandler cgi-script .cgi .pl
 
Now we're getting somewhere...
I added the .pl extension to the cgi-script handler. Now I'm getting a 403 error, and the logs says that the ExecCGI option is off for that cgi-bin directory.

I don't understand why I don't get the same errors while using the domain in the URL. I mean, isn't it the same virtual host?
 
I don't understand why I don't get the same errors while using the
domain in the URL. I mean, isn't it the same virtual host?

No not at all. The ip address defaults to /var/www/html Its not looking at
the virtual host at all. And how can it look at the virtual host when the
domain is not in the url.

Now you have to put ExecCGI in the Options line in httpd.conf. I forgot
which line it is so what I did was put it in all of them. You can do one at
a time if you want until you find the right one.
 
Yes, you're right... As soon as I open the httpd.conf and saw the <Directory /home/*> tag I understood how that worked...

I appended the ExecCGI option to that directory and it worked. The thing is that if I copy the script.pl to the document root of that user, it's also executable.

So what I did was to add the following to my httpd.conf

<Directory /home/*/public_html/cgi-bin>
Options ExecCGI
</Directory>

And now it's working as a I wanted :)

Thanks very much for all your support!
 
Back
Top