Connecting Tech Pros Worldwide Forums | Help | Site Map

Running cgi (or perl at all) in apache

Kelicula's Avatar
Expert
 
Join Date: Jul 2007
Posts: 169
#1: Oct 19 '07
I have installed Activestate perl with Apache 2.2 and I can't get perl written cgi scripts to run.

I have changed the conf file to this

<Directory "htdocs/cgi-bin">
SetHandler cgi-script
Options ExecCGI
</Directory>

And I have:

<IfModule dir_module>
DirectoryIndex index.html index.shtml index.cgi
</IfModule>

And:

<Directory "htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks ExecCGI Includes

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

As well as:

LoadModule cgi_module modules/mod_cgi.so

And:

AddHandler cgi-script .cgi
AddHandler server-parsed .html

AND!:
ScriptInterpreterSource registry

I have set my file types to open the command line interpreter for the "open" action of files with .cgi

And I can't get cgi scripts to function properly on my Windows XP SP2 box.


Anyone been through this??

Help!!

:)

When I try to open a page that has perl it just says waiting for localhost...
In my status bar, all other pages work. Even SSI enabled...

numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,572
#2: Oct 25 '07

re: Running cgi (or perl at all) in apache


Quote:

Originally Posted by Kelicula

I have installed Activestate perl with Apache 2.2 and I can't get perl written cgi scripts to run.

I have changed the conf file to this

<Directory "htdocs/cgi-bin">
SetHandler cgi-script
Options ExecCGI
</Directory>

And I have:

<IfModule dir_module>
DirectoryIndex index.html index.shtml index.cgi
</IfModule>

And:

<Directory "htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks ExecCGI Includes

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

As well as:

LoadModule cgi_module modules/mod_cgi.so

And:

AddHandler cgi-script .cgi
AddHandler server-parsed .html

AND!:
ScriptInterpreterSource registry

I have set my file types to open the command line interpreter for the "open" action of files with .cgi

And I can't get cgi scripts to function properly on my Windows XP SP2 box.


Anyone been through this??

Help!!

:)

When I try to open a page that has perl it just says waiting for localhost...
In my status bar, all other pages work. Even SSI enabled...

Kelicula,

I have Active State and Apache installed on my windows machine, and if I remember right, it was already configured by default for CGI (using Perl scripts).

First, your scripts (cgi) would need to be placed into your c:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin folder. There is already a script in there called printenv.cgi (or .pl).

In your c:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf file, you will need to change the following. There is a section that talks about the shebang line in the Perl scripts. You will need to change what ever is there to be "#!c:/perl/bin" as that is where ActiveState installed to. Once you do that, save it.

That shebang line is what you should put at the top of your perl cgi scripts. If it is not there, then the script will not run and you will probably get something like a 503 error. Also, the script (printenv.cgi) will probably not have the correct shebang line so change it and save it.

In the conf file by the way, you will also want to make sure you have ServerName set to "www.localhost.com:80", unless you are hosting for yourself.

Once you do that, it should be fine.

Also, for your reference, you can read this link.


Regards,

Jeff
Kelicula's Avatar
Expert
 
Join Date: Jul 2007
Posts: 169
#3: Oct 26 '07

re: Running cgi (or perl at all) in apache


Thanks! I'm running cgi now. I am still having some issues though, I think it is because I have altered my conf file so much, I can't tell what's been altered or not anymore.

I need to unintall, and reinstall, then save a copy of the default conf file somewhere else to be able to go back to it if needed.

Word to wise, save a backup of the conf file!!
Reply


Similar Apache Web Server bytes