Apache and CGI.

jsbush

Diamond Member
Nov 13, 2000
3,871
0
76
Anyone know the line you need to add in apache httpd.conf file so you can run a cgi script? I don't understand there instructions. My perl is in c:/perl/bin.

It gives me an error when I try to start apache when I have this line:
!c:/perl/bin

Thanks.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
On unix the header for script files should be #!/path/to/executable, not just !/path. It's probably the same on Windows.
 

jsbush

Diamond Member
Nov 13, 2000
3,871
0
76
Ok, I'm completly confussed about this cgi stuff. I got php working fine, I just don't get the cgi part.

Even with it set at #!c:/perl/bin it doesn't work.

If i use the test file in the cgi-bin directory (printnev.pl) it gives me an internet server error.
 

bubba

Golden Member
Oct 10, 1999
1,589
0
0

In order to run scripts through the server, you also have to configure your server. You need to enable scripting at all, plus you need to enable the directory you are running scripts in to be executable. It is well documented in the httpd.conf how to do this.

The section you are looking for looks something like this:

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>


Then later on:


# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
AddHandler cgi-script .cgi


And further down:

# If the perl module is installed, this will allow execution of mod_perl
# to compile your scripts to subroutines which it will execute directly,
# avoiding the costly compile process for most requests.
#
## UNCOMMENTING FOR SCRIPTS
<IfModule mod_perl.c>
Alias /perl /var/www/perl
<Directory /var/www/perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Directory>
</IfModule>

##############################################
## ADDING DIRECTORIES FOR EXEC PRIVS (example by bubba)
##############################################
<Directory /home/username/public_html/cgi-bin>
Options +ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>


 

jsbush

Diamond Member
Nov 13, 2000
3,871
0
76
Thanks, but...

I followed the steps above, but I got this error message

Forbidden
You don't have permission to access /signup.cgi on this server.


Any ideas?

I set my whole www directory to read cgi. Does apache not see sub directories.
 

jsbush

Diamond Member
Nov 13, 2000
3,871
0
76
Still doesn't work, after trying everything mentioned here. I get this forbidden message.
 

jsbush

Diamond Member
Nov 13, 2000
3,871
0
76
If I take off add handler, I don't get a forbidden message, I just see the cgi script as plain text.