Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi-scripts don't work with apache/perl installed on WinXP 1

Status
Not open for further replies.

HeatherFeuer

Technical User
Jan 3, 2002
19
US
I recently installed Perl 5.8.007 that comes with a fairly complete packed except for mySQL. I have it installed with virtual hosts for Apache (the main server) and two other websites that I maintain. I like being able to test scripts on my local WinXP Pro machine. I have service pack one and all the current updates except for Service Pack 2 -- haven't felt the need for it.

My server installation accepts and runs all the html documents for all the configured sites. However, I can't get any of my cgi or perl scripts to run. I have followed the directions for adding paths and the script(s) have the correct path to Perl. My httpd.conf file includes "AddHandler cgi-script .cgi .pl" (without the quotes).

What am I forgetting or doing wrong?

Heather
 
The [red]AddHandler[/red] Directive is for using scripts outside the cgi-bin folder. What is your configuration in httpd.conf for cgi-bin.
It should be
Code:
ScriptAlias /cgi-bin/ "C:\watever\path\to\apache\cgi-bin"
<Directory "C:\watever\path\to\apache\cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
Do you run your scripts from there?
Do you get any error mgses in the [red]Apache/logs/error_log[/red] file while you try to run your scripts?
If yes, check them out, and if you don't understand something then post them here, along with the code of the script.


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Thanks for the response, 'Pengo.

My Apache installation won't let me do backslashes. When I trid to restart the service in the console window, I kept getting syntax errors, mostly on any cgi-related directives. But I still can't get any of my scripts to be recognized. In the browser, I get a 404. In my error log I get the following:

"[Tue May 17 16:36:20 2005] [error] [client 000.000.0.000] script not found or unable to stat: E:/Websites/Apache/cgi-bin"

I masked the IP. It is a static IP address for the computer Apache is installed on. Here is the script I have been using to troubleshoot:

Code:
#!Perl

use CGI;
$query = new CGI;
print $query->header;
print $query->start_html("A Clickable Image");
print <<END;
<H1>A Clickable Image</H1>
</A>
END
print "Sorry, this isn't very exciting!\n";

print $query->startform;
print $query->image_button('picture',"./wilogo.gif");
print "Give me a: ",$query->popup_menu('letter',['A','B','C','D','E','W']),"\n"; # 
print "<P>Magnification: ",$query->radio_group('magnification',['1X','2X','4X','20X']),"\n";
print "<HR>\n";

if ($query->param) {
    print "<P>Magnification, <EM>",$query->param('magnification'),"</EM>\n";
    print "<P>Selected Letter, <EM>",$query->param('letter'),"</EM>\n";
    ($x,$y) = ($query->param('picture.x'),$query->param('picture.y'));
    print "<P>Selected Position <EM>($x,$y)</EM>\n";
}

print $query->end_html;

On the first line, I have tried everything from the full path to perl.exe all the way to what you see now. I can't seem to get apache to recognize any perl or cgi scripts. Here is the script alias and directory for .cgi and .pl from my httpd.conf file:

Code:
ScriptAlias /cgi-bin/ "E:/WebServer/Apache2/cgi-bin/"

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

I'm really stumped. When I had apache server running under Win2K, I never had this problem! Any further suggestions would be greatly appreciated!

Heather
 
on the first line you should have the full path to you perl executable file like this

[red]#!c:\whatever\perl\bin\perl.exe[/red]

Now your script is OK. What i think is that you have to recompile your apache , which in windows means something like reinstall.

Try on the command line

[red]E:\> WebServer\Apache\bin\apache -l[/red]

it will show you which modules are built in.

If you can see [red]mod_cgi.c[/red] on the list that will show up, then you have it but something happen on the apache installation. Reinstall.

If you cannot see that file then you should Load it dynamically by adding the next line into your httpd.conf file

[red]LoadModule cgi_module modules/mod_cgi.so[/red]

You also have to check if you have in this folder 'E:\WebServer\Apache2\modules\' a file named 'mod_cgi.so' then add the line i show you.

if you don't have the file then adding the line is useless.
Reinstall.


By the way forgive me for the backslashes. You are right you cannot use them.


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Hi, Pengo, thanks for your help!

It's taken me awhile because I completely uninstalled Apache Perl and then used a utility to check for and remove any mentions of Apache2 or Perl. Then I went ahead and reinstalled by binaries and followed all the instructions about which files to change.

Here is the list of LoadModule directives from my httpd.conf file:

Code:
LoadModule access_module modules/mod_access.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_module modules/mod_auth.so
LoadModule autoindex_module modules/mod_autoindex.so
[b]LoadModule cgi_module modules/mod_cgi.so[/b]
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule imap_module modules/mod_imap.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule info_module modules/mod_info.so
LoadModule status_module modules/mod_status.so
#LoadModule auth_anon_module modules/mod_auth_anon.so
#LoadModule auth_dbm_module modules/mod_auth_dbm.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule info_module modules/mod_info.so
#LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule status_module modules/mod_status.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule usertrack_module modules/mod_usertrack.so

So I know the cgi module has been loaded. If you use the "-l" command, all it will show you is the the core modules that are installed without the "LoadModule" directive. This is the result of typing "apache -l":

Code:
Compiled in modules
    core.c
    mod_win32.c
    mpm_winnt.c
    http_core.c
    mod_so.c

I can open up the basic apache page when I type in But when I type in - which has the correct path to perl in the header, I get a 404 browser error and the following error in my error log:

[Wed May 18 21:18:03 2005] [error] [client 000.00.0.000] script not found or unable to stat: E:/WebServer/Apache2/cgi-bin/clickable-image.cgi

I am truly stumped!!

Heather
 
I know that this will sound stupid but try

stop the apache server which running....

go to httpd.conf file and at the section that you have

ScriptAlias /cgi-bin/ "E:/WebServer/Apache2/cgi-bin/"
<Directory "E:/WebServer/Apache2/cgi-bin/">
.......
</Directory>


delete the last slashe. to look like this (only at the Directory directive, NOT the ScriptAlias)

ScriptAlias /cgi-bin/ "E:/WebServer/Apache2/cgi-bin/"
<Directory "E:/WebServer/Apache2/cgi-bin">
.......
</Directory>


restart the server....

tell me if it works!


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
When I did the reinstall, I re-configured httpd.conf from scratch, as well as perl.conf. So I left the trailing "/" off. Unfortunately, I don't remember where and how to add the line so the .pl extension is recognized and processed like the ".cgi" extention.

I'm not sure if this will help, but here is part of the information from phpinfo:

Code:
[b]apache2handler[/b]
[b]Apache Version[/b]  Apache/2.0.52 (Win32) PHP/4.3.10 mod_ssl/2.0.52 OpenSSL/0.9.7e mod_perl/1.99_20-dev Perl/v5.8.6  
Apache API Version  20020903  
Server Administrator  @@ServerAdmin@@  
[b]Hostname:Port[/b]  apache:80  
Max Requests  Per Child: 0 - Keep Alive: on - Max Per Connection: 100  
Timeouts  Connection: 300 - Keep-Alive: 0  
Virtual Server  No  
[b]Server Root[/b]  E:/WebServer/Apache2  
[b]Loaded Modules[/b]  core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex [b]mod_cgi[/b] mod_dir mod_env mod_imap mod_include mod_isapi mod_log_config mod_mime mod_mime_magic mod_proxy proxy_connect proxy_http proxy_ftp mod_negotiation mod_userdir mod_vhost_alias mod_deflate mod_setenvif mod_info mod_status sapi_apache2 mod_ssl mod_apreq mod_perl Apache::Template

That clarifies that mod_cgi has been installed. So I am still stumped!

By the way, I enabled server-status and server-info just to see what they do. When I type the URL, I get a forbidden. How would I assign the right permissions? I've never used my .htaccess file when I've had apache installed on my personal computer, maybe I need one anyway?

Heather
 
I finally figured out how to allow access to server-info and server-status. That was my "DOH" moment for the day!

Using status-info, here is what is shown for mod_cgi.c:

Code:
Module Name: mod_cgi.c 
Content handlers: yes
Configuration Phase Participation: Create Server Config, Merge Server Configs
Request Phase Participation: none 
Module Directives:
ScriptLog - the name of a log for script debugging info 
ScriptLogLength - the maximum length (in bytes) of the script debug log 
ScriptLogBuffer - the maximum size (in bytes) to record of a POST request 
Current Configuration:

There should be something under Current Configuration, shouldn't there? Could this info help show why cgi scripts aren't recognized?

Heather
 
post the whole httpd.conf file and if you have any perl.conf, or cgi.conf or something with (perl/cgi into it).conf


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Before I do that, I need to bring you up to date. I'm still stumped at one point, but it's further along in the process.

I completely uninstalled everything in my webserver folder, then went through the registry to make sure I really uninstalled it all. Then I went and downloaded the apache and perl .msi binaries. Using the .msi files gave me completely different setup options, but the install went much smoother and at the end of it first apache then perl were fully installed and the apache service was up and running.

With this install, the cgi-bin worked and was able to run the cgi scripts with no problem! Yay!

The only real problem is with a "premature end of script headers" in one of my scripts, and I think I'll take that problem over to the CGI forum where it really belongs.

Thank you SO much, pengo for all your help and advice! You were so very patient with me and I truly appreciate it.

Heather
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top