cgi scripts outside of the cgibin

nhwebgroup

Verified User
Joined
Aug 8, 2005
Messages
24
Location
nh
I have MANY cgi scripts out side of the cgi-bin folder on one website. I can not get them to run outs side of the cgi-bin

i have added a custom directive to HTTPC in the DA tool but the scrips still do not run

here is what i added to the DA httpd

<Directory /home/admin/domains/mywebsite.com/public_html/customscripts/>
Options ExecCGI
</Directory>

here is a sample CGI file:
<code>
#!/usr/bin/perl

#output html
print "Content-type: text/html\n\n";
print "<h1>hello world!</h1>";

$e = `perl -ver`;
$r = `whereis perl5`;
$z = `whereis sendmail`;#
$w = `top`;#
$d = `w`;

print "<pre>perl version:<br>$e<hr>perl path:<br>$r<hr>sendmail path:<br>$z<hr>top:<br>$w<hr>w:<br>$d<hr>environment vars:<br>";##

while (($key, $val) = each %ENV) {
print "$key = $val\n";
}

print "<hr>path tranlsated(NT)<br>$ENV{'PATH_TRANSLATED'}</pre>";
exit;
</code>

</code>

When i run this scrip in the browser i get Internal server error

I have check the permissions and they are set to 755 for both the file and the directroy.

What do i need to do to get cgi scripts to work outside the cgi
 
did you also try using the .htaccess file and making sure that the master httpd.conf file allows for this overide aswell as not being overiden itself anywhere else?
 
so i created an .htacces file with the following

<Directory /home/admin/domains/mysite.com/public_html/scriptfolder>
Options +ExecCGI
</Directory>
AddHandler cgi-script .cgi
****************

my httpd.conf file look like this:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory "/var/www/html">

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
********
So i assume that AllowOverride All will allow the .htaccess file to work.

but the scripts do not run?

I can run the script via the command line via SSH without error so i know it's not the script....

any other suggestions?
 
You are probably running into a problem due to suexec.

Check out the Debugging section of this document:
http://apache-server.com/tutorials/LPsuexec.html

Scripts in the /public_html/ directory will not run due to the fact that the uid is set to the user but the gid is set to apache (example: smith/apache). Your scripts have their uid and gid set to the user (smith/smith). This difference in directory gid and script gid will prevent suexec from running the script.

You can't change the public_html gid because apache won't be able to open the directory. Changing your scripts gid won't work because by then, apache is running as the user uid and gid.

Scripts in subdirectories on your website should still work though assuming you have uid/gid set to the user and the file permissions are correct.
 
Same problem but strange error

Same problem but strange error
in suexeclog file i found this errors:

[2006-07-04 14:55:03]: info: (target/actual) uid: (main/main) gid: (main/main) cmd: test.cgi
[2006-07-04 14:55:03]: error: target uid/gid (1003/111) mismatch with directory (1003/105) or program (1003/111)

and cgi stop working besides cgi-bin

I changed chmod of files and directories to 755
and write +ExecCGI in every httpd.conf for every domain
and ScriptAllies

Bot the same error and 500 http error too.
Who had the same problem and solved in it.
 
It means the owner permission from the script or either the directory the script is in are probably not correct.

ls -la

and see what it gives you
 
drwxr-xr-x 3 main apache 138 2006-07-04 17:45 public_html

and cgi-bin directory :

drwxr-xr-x 10 main main 4096 2006-07-04 15:54 cgi-bin

I think I need to change on public_html on main main too ('main' is a user)

How to do this?

thanx
 
Back
Top