-   Linux - Software (
-   -   Apache CGI Problem : Browser not running script (

Zaknafien 12-30-2003 11:51 PM

Apache CGI Problem : Browser not running script
Ive been looking around this site for days looking for anything remotely resembling this problem and have not had any luck.

Here is the problem. When I try to run my test script from the Browser (galeon and IE on a different computer) the browser wont execute it they try to download the script. (i.e. - typing "" the "DocumentRoot" is /mysite/ into the location in the browser) Which is not exactly I must say what I want. I have used "ScriptAlias" to make the cgi's able to run in my cgi-bin directory and used "AddHandler" to tell it to run scripts with .cgi and .pl extensions. I am using Apache 2.x. I cant seem to figure out why it is not running the script. Any Ideas? Anybody?

My cgi script (I even tried renaming it first.cgi - didnt matter still does same effect) -

print "Content-type: text/html\n\n";
print "Hello, World.";

-End of script -

My vhosts config file portion (IP's and Domains edited)-

################# Vhosts.conf
#This is where we store the VirtualHosts configuration.
#Since Apache 1.3.19, we modified the setup to include some nice tricks:
#- We added the User and Group directives so VirtualHosts now work with
# suexec directive. If set, Apache will run all cgi scripts under that
# user and group (provided the uid and gid are > 100 for security). The
# directories and cgi files *must* belong to that user/group for the
# feature to work
#- We added the Setenv VLOG directive. This works in conjunction with
# the CustomLog in common.conf. When Setenv VLOG is set, apache will
# create a /var/log/httpd/VLOG-YYYY-MM-<ServerName>.log instead of logging
# to access_log. Use this instead of defining a special logfile for
# each vhost, otherwise you eat up file descriptors.
#- You can also specify a path for the VLOG for each Vhost, for example,
# to place the logs in each user's directory. However, if you want to
# use the file for accounting, place it in a directory owned by root,
# otherwise the user will be able to erase it.
#- I suggest only including the ErrorLog *only* if the vhost will use
# cgi scripts. Again, it saves file descriptors!
#- We added the Rewrite directives so vhosts will work with the
# PERLPROXIED configuration

ScriptAlias /cgi-bin/ /var/www/html/hosts/site1/cgi-bin/
DocumentRoot /var/www/html/hosts/site1
Options ExecCGI
AddHandler cgi-script cgi pl

ScriptAlias /cgi-bin/ /var/www/html/hosts/site2/cgi-bin/
DocumentRoot /var/www/html/hosts/site2
Options ExecCGI
AddHandler cgi-script cgi pl

ScriptAlias /cgi-bin/ /var/www/html/site3/cgi-bin/
DocumentRoot /var/www/html/hosts/site3
Options ExecCGI
AddHandler cgi-script cgi pl

DocumentRoot /var/www/html/hosts/site4

-End of Vhosts config file -

techrolla 12-31-2003 12:01 AM

check the apache logs, in the apache folder. I have this same problem, although I forgot about it with jsp and php, but the reason my logs gave were because there was some incorrect header or something. so maybe search around for bad header problems with apache and perl.

Zaknafien 12-31-2003 12:57 AM

Thank you for your help techrolla. I figured out what it was though for those that would like to know or are having this particular problem. I had written (accidentally) an empty space between the start of the cgi and the "#/usr/bin/perl" statement... I deleted the empty space and viola! everything works as it is supposed to. Now on to making some real cgi's.

techrolla 12-31-2003 01:16 PM

heh, cool, np. Im gonna see if I did the same thing...

All times are GMT -5. The time now is 12:13 PM.