Operating System - HP-UX
1753724 Members
4810 Online
108799 Solutions
New Discussion юеВ

running .cgi and .pl scripts in Apache server

 
Thi Vu
Frequent Advisor

running .cgi and .pl scripts in Apache server

Hi everyone,

I just started the Apache web server on our D210 HP11.i server. When I went to hhtp://ipaddress the default web page show up. I think this is good; however I ran into a few problems when I tried to run my cgi and pl scripts for the site. I did configure the httpd.conf file as follow:

1. ScriptAlias /cgi-bin "/apache/cgi-bin/"

Allowoverride None
Options +ExecCGI
Order allow,deny
Allow from all


where /apache/cgi-bin/ is a file system that contains lots of the Html, Perl and CGI scripts for the site.

2. I also modified:
AddHandler cgi-script .cgi .pl

After the above I restart the server and went to the web to check if my .html, .cgi and .pl files are run - all I see is the Apache's default page. The permission on all the files are 755. I'm so desperate that I even remove my "ScriptAlias" setting and links the default setting to my scripts' file system - no result. I also try to move all of my scripts to the /opt/apache/htdocs dir - all it shows on the web page is as followed:

Name Last modified Size Description
--------------------------------------------------------------------------------
Parent Directory 04-Apr-2001 11:24 -
bw6.img 27-Aug-2001 15:02 26.8M
contact.html 27-Aug-2001 15:03 1k
default.html 27-Aug-2001 15:03 1k
help.html 27-Aug-2001 15:03 3k
info.cgi 28-Aug-2001 15:06 1k
menu.cgi 28-Aug-2001 15:06 6k
temp/ 28-Aug-2001 17:24 -
title.html 27-Aug-2001 15:03 1k
top_menu.cgi 28-Aug-2001 15:06 3k

Can someone please help. Thanks in advance.

Thi


6 REPLIES 6
Denver Osborn
Honored Contributor

Re: running .cgi and .pl scripts in Apache server

Use the following changes to your httpd.conf file;

ScriptAlias /cgi-bin/ "/apache/cgi-bin/"


Allowoverride None
Options None
Order allow,deny
Allow from all


To test;
# cp -p /opt/apache/cgi-bin/printenv /apache/cgi-bin

# vi /apache/cgi-bin/printenv
->make change to perl location if needed

from browser
http://ip_address/cgi-bin/printenv

I think you'll be good to go after making changes to your httpd.conf.

-denver
Thi Vu
Frequent Advisor

Re: running .cgi and .pl scripts in Apache server

Hi Denver,

I did as per your suggestion but still not working. I still see the "Index of /" page and then the listing of what I have in my Documentroot/htdocs dir. However, this time I went to the link of one of the file and click to open, I got the "Forbidden: you don't have permission to access /filename on this server" message - I had the permission for both dir. and files to be 755, the owner are "root" and the group is "sys" but still got the same message.

I went and type http://ip_address/cgi-bin/printenv at the browser it printout the environment var. OK. I feel like I'm missing some steps after modifying the httpd.conf file thus enable me to execute any of my .html, .cgi and .pl scripts.

Thi
John Bolene
Honored Contributor

Re: running .cgi and .pl scripts in Apache server

Looks fine to me.

Are you using for the request
http://ipaddress/cgi-bin/script.whatever

or just
http://ipaddress

You only get the default page with using the last example.
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
John Bolene
Honored Contributor

Re: running .cgi and .pl scripts in Apache server

I have a perl test that I put in there.
cat /opt/apache/lib/cgi-bin/perl-test

#!/opt/perl5/bin/perl

print "Content-type: text/html\n\n";
print "test"





permissions on the file are 755
the 3 lines are needed including the blank line

It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
Bill Thorsteinson
Honored Contributor

Re: running .cgi and .pl scripts in Apache server

Check the contents of the errorlog. Its location
is specifed by the ErrorLog entry in httpd.conf.

It should have more details on why you are being
denied access to files.

Check the access entries in httpd.conf. Restrictions
can be applied to Directory, File, DirectoryMatch,
or Location. Make sure you don't something
locking access to the files.

The first directory specification in the httpd.conf should
point to your document root. This usually has quite
generous access rights.

If you still have problems check the security_tips.html
file on your server or at
http://httpd.apache.org/docs/misc/security_tips.html

I usually set up an alias to apache available to the
local site to access the documentation pages. Also
use RCS check-in check-out to mantain version control
on your configuration files. It has bailed me out a
couple of times.
Thi Vu
Frequent Advisor

Re: running .cgi and .pl scripts in Apache server

Hi everyone,

Thank you all for your help. I finally fingured out why the HP/Apache default page show up after I set up the Apache server when I typed this http://ipaddress at the browser. The answer lies in the IndexDirective; under that directive in the httpd.conf file you can specified which file to execute first when someone go into your webpage. The default setting from httpd.conf file is the file name call Index.html under /opt/apache/htdocs directory. You can change to whatever file you want in the IndexDirective and it works like a charm.

Again thank you all for all the help in the past.

Thi