We help IT Professionals succeed at work.

Configure Perl for Apache 1.3.3

CT2000
CT2000 asked
on
Medium Priority
509 Views
Last Modified: 2010-03-04
Hi,
  I need to configure Perl to work on Apache web server (1.3.3), I have already install Perl software (v5.6.1) on my web server. Even if I launch the simple script like hello world. It will give me an erorr message as below

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@datasphere.com.sg and inform them of the time the error occurred, and anything you might have done that may have caused the error.

Premature end of script headers: /usr/local/apache/cgi-bin/first.pl



--------------------------------------------------------------------------------

If I add something like "AddHandler perl-script .pl". When I execute it will ask me to wheather to open or download it (I have already associate .pl with wordpad editor).
 
Please advise what are the necessary step I should take in order for the configuration to work.


Comment
Watch Question

Commented:
I think the directive that you need to enable is

"AddHandler cgi-script .pl"

You can append any file type that you need the server to run as CGI scripts.  And make sure that Options ExecCGI is enable in that appropriate directory otherwise you might end-up with the same problem.

Make sure the permission is set properly.  I think it should be 755.

--- from httpd.conf
    #
    # 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
----

Btw, the directive can be applied within "VirtualHost" rather than applying it to Global config.

---
example;

    Alias /someurl/ "/usr/local/webdata/someurl/"

    <Directory "/usr/local/webdata/someurl">
        Options Indexes MultiViews ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    AddHandler cgi-script .pl

--
good luck

Commented:
btw,

check the apache log file, you should get more information there.  I problem persist, please post some portion of the logfile (not all.... ).

.

Author

Commented:
Hi,
  I am not quite sure which directory is the configuration file. I presume it is /usr/local/apache/etc. My cgi directory is /usr/local/apache/cgi-bin.
  From your statement above
Alias /someurl/ "/usr/local/webdata/someurl/", I don't quite understand. What are you referring to? Normally it would be
Documentroot /usr/local/apache/share/htdocs. Are you referring to the root of the web folder?
  Got small problem with my web server. I cannot telnet from home. will post the log on Monday morning.
  Thanks in advance
  CT2000

Commented:
Apache normally resides in /usr/local/apache, and the conf file lies in /usr/local/apache/conf.  If you are running RedHat, try /etc/httpd/conf/httpd.conf

The Alias is the Apache Directive to enable a directory outside serverroot path to be accessible.  Normally, only everything under DocumentRoot is available.

In your case, just modify the setting for DocumentRoot.
CERTIFIED EXPERT

Commented:
does
    usr/local/apache/cgi-bin/first.pl
execute well from within your shell?

Author

Commented:
Hi  
  Below is a portion of the access_log

202.156.2.211 - - [04/Feb/2002:02:52:07 +0800] "GET /ds_images/vt_04.gif HTTP/1.1" 304 -
202.156.2.211 - - [04/Feb/2002:02:52:19 +0800] "GET /ds_images/back.gif HTTP/1.1" 304 -
202.156.2.211 - - [04/Feb/2002:02:52:40 +0800] "GET /corridor.jpg HTTP/1.1" 200 102852
202.156.2.211 - - [04/Feb/2002:02:53:30 +0800] "GET /outside180.jpg HTTP/1.1" 200 1452298
202.156.2.211 - - [04/Feb/2002:02:54:17 +0800] "GET /office3-1.jpg HTTP/1.1" 200 1470370
203.92.71.98 - - [04/Feb/2002:08:54:40 +0800] "GET /old/pg_contact.html HTTP/1.1" 304 -
203.92.71.98 - - [04/Feb/2002:08:54:40 +0800] "GET /styles/style.css HTTP/1.1" 404 299
203.92.71.98 - - [04/Feb/2002:08:54:40 +0800] "GET /old/images/bar_contact.gif HTTP/1.1" 304 -
203.92.71.98 - - [04/Feb/2002:08:54:40 +0800] "GET /old/images/phone.gif HTTP/1.1" 304 -
203.92.71.98 - - [04/Feb/2002:08:54:43 +0800] "POST /cgi-bin/feedback.pl HTTP/1.1" 500 620


And below is a portion of the error_log

[Sat Feb  2 19:38:07 2002] [error] [client 203.117.33.25] Premature end of script headers: /usr/local/apache/cgi-bin//feedback.pl
[Sat Feb  2 19:38:15 2002] [error] [client 203.117.33.25] File does not exist: /usr/local/apache/share/htdocs/styles/style.css
[Sun Feb  3 00:01:00 2002] [error] [client 203.255.177.207] File does not exist: /usr/local/apache/share/htdocs/scripts/root.exe
[Sun Feb  3 00:01:03 2002] [error] [client 203.255.177.207] File does not exist: /usr/local/apache/share/htdocs/MSADC/root.exe
[Sun Feb  3 00:01:12 2002] [error] [client 203.255.177.207] File does not exist: /usr/local/apache/share/htdocs/c/winnt/system32/cmd.exe
[Sun Feb  3 00:01:16 2002] [error] [client 203.255.177.207] File does not exist: /usr/local/apache/share/htdocs/d/winnt/system32/cmd.exe
[Sun Feb  3 00:01:19 2002] [error] [client 203.255.177.207] File does not exist: /usr/local/apache/share/htdocs/scripts/..    ?../winnt/system32/cmd.exe
[Sun Feb  3 02:01:10 2002] [error] [client 66.7.131.153] File does not exist: /usr/local/apache/share/htdocs/robots.txt
[Sun Feb  3 04:21:36 2002] [error] [client 216.35.116.93] File does not exist: /usr/local/apache/share/htdocs/robots.txt
[Sun Feb  3 07:46:49 2002] [error] [client 216.35.119.78] File does not exist: /usr/local/apache/share/htdocs/robots.txt
[Sun Feb  3 11:53:11 2002] [error] [client 64.165.17.201] File does not exist: /usr/local/apache/share/htdocs/whatsnmp.htm
[Sun Feb  3 22:26:09 2002] [error] [client 160.96.179.55] File does not exist: /usr/local/apache/share/htdocs/robots.txt
[Mon Feb  4 00:19:44 2002] [error] [client 203.92.71.189] File does not exist: /usr/local/apache/share/htdocs/scripts/root.exe
[Mon Feb  4 02:51:27 2002] [error] [client 202.156.2.211] File does not exist: /usr/local/apache/share/htdocs/PixScreenBeanInfo.class
[Mon Feb  4 08:53:31 2002] [notice] httpd: caught SIGTERM, shutting down
[Mon Feb  4 08:53:31 2002] [notice] Apache/1.3.3 (Unix) configured -- resuming normal operations
[Mon Feb  4 08:54:40 2002] [error] [client 203.92.71.98] File does not exist: /usr/local/apache/share/htdocs/styles/style.css
[Mon Feb  4 08:54:43 2002] [error] (2)No such file or directory: exec of /usr/local/apache/cgi-bin//feedback.pl failed
[Mon Feb  4 08:54:43 2002] [error] [client 203.92.71.98] Premature end of script headers: /usr/local/apache/cgi-bin//feedback.pl



To  ahoffmann,
   my /usr/local/apache/cgi-bin/first.pl executes well in my shell.
    CT2000



Author

Commented:
To samri
   I am running Sun solaris on SPAR platform. It is quite funny, all the while I was configuring my Apache httpd.conf which was located at /usr/local/apache/conf. Till recently I somehow realise I have to configure my httpd.conf which was located at /usr/local/apache/etc.

CT2000

Commented:
Watch this error;

[Mon Feb  4 08:54:43 2002] [error] (2)No such file or directory: exec of /usr/local/apache/cgi-bin//feedback.pl
failed

And check ahoffman's comment; check whether the scripts run in command shell.

Check your scripts, make sure the first line contains absolute path, ie #! /usr/loca/bin/perl and not just #! perl.

Btw;; the default for apache config file is in /usr/local/apache/conf.  Perhaps you might need to make sure you apache is not being compromised (hacked).

If you can afford to upgrade, there is Apache 1.3.22 coming up, 1.3.3 is quite old.

good luck

Author

Commented:
Hi,
  What are the things I have to consider when I do an upgrade from 1.3.3 to 1.3.22? Will the configure be preserved?
  Please advise.
  Thanks in advance.
  CT2000

Commented:
In most cases, the configuration will be preserved.  But I would recommend that you keep the existing apache tree separate and do a fresh install.  Then later migrate the data over.  If you can afford this.

And the sentence "backup your data" is always like a motto prior to upgrading. Just be prepared.  Personally I never had much problem during the upgrade process.

There should not be much different in config file syntax between 1.3.3 and 1.3.22, unless you had done some customization (recompiling the apache), or adding customized modules yourself.

Since you had noticed some "strange" bahavior in term of file location, and the log file looks "funny" to be (Like people are trying to hack your server or maybe already been hacked), It would be advisable to start a fresh install.  Make sure you had the existing config around.  In most cases, you will need to ensure any VirtualHost, Alias, Directory directives are kept the same as the existing one.

It's good to run some "Intrusion Detection software" to check for integrity of your server.

good luck.
CERTIFIED EXPERT

Commented:
>  my /usr/local/apache/cgi-bin/first.pl executes well in my shell.

I believe that. But

> [Sat Feb  2 19:38:07 2002] [error] [client 203.117.33.25] Premature end of script headers: /usr/local/apache/cgi-bin//feedback.pl

Did that run too?

Sounds like your script does not produce a valid HTTP header.

Commented:
ct200,

ahoffman's right.

I personally would tackle the scripts first prior to upgrading the server.  It's nice to get the latest version running, but if the scripts is buggy, you might end-up with the same frustration.

try running the scripts from command shell (as recommended by afhoffman), and maybe posting the output here... At least the first few lines.  Or if the code is not too long, maybe you can post the code as well, so that we are can take a look, and try to simulate.

cheers
Monitoring.
Moondancer
Community Support Moderator @ Experts Exchange

Author

Commented:
Hi samri
   Where can I get a binary version of apache 1.3.22. I am trying to download it from www.sunfreeware.com. It is not available. The webmaster advise me to download from the mirror web site. I have try a number of web site. The version is either 1.3.6, I just could not get a 1.3.22

   Please advise
   CT2000
Commented:
The binaries repository can be found on Apache's website;

http://www.apache.org/dist/httpd/binaries/

Specific to Solaris;
http://www.apache.org/dist/httpd/binaries/solaris/

Just grab one that suits you Solaris Environment.

Depending on your Sparc (if you are running one), do a "uname -a" will give you the some info on your sparc machine.
For example:
apache_1.3.22-sun4u-sun-solaris2.280.tar.gz    

Look at "-sun4u" This is apache-1.3.22 precompiled for UltraSparc arch machine.  For older Sparc, you might be looking at "-sun4c" version.  Check the one for your machine for more detail.

Author

Commented:
Thanks for giving me a good site to download the software

Explore More ContentExplore courses, solutions, and other research materials related to this topic.