Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help getting Perl/CGI running on OS X localhost with apache

Reply
Thread Tools

Help getting Perl/CGI running on OS X localhost with apache

 
 
petermichaux@yahoo.com
Guest
Posts: n/a
 
      05-10-2005
Hi,

I am trying to learn about perl and cgi. I have apache and php running
on my OS X (10.3) localhost. I followed the instructions on the
following site to configure apache for perl my modifying the file
"/etc/httpd/httpd.conf" on my computer.

http://www.cgi101.com/book/connect/mac.html

The only difference from that webpage is my configure file will parse
".shtml" files instead of ".html" files.

I have written a file called "first.cgi" and saved it in my sites
folder.

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "Hello, World!\n";

At the terminal command line I can successfully run the command "perl
first.cgi".

When i point my browser to "http://localhost/~peter/first.cgi" I get
the following message

Forbidden
You don't have permission to access /~peter/first.cgi on this server.
Apache/1.3.33 Server at peter-michauxs-computer.local Port 80

I tried using the terminal command "chmod 755 first.cgi". It looks like
the permissions are set correctly

-rwxr-xr-x 1 peter peter 108 9 May 23:14 first.cgi*

The forbidden message did not go away. What's going wrong? Is apache
not configured correctly? Do i need any extra files in my sites folder?

Any help greatly appreciated!!!!!

Thanks,
Peter

 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      05-10-2005
wrote:

> Hi,
>
> I am trying to learn about perl and cgi. I have apache and php running
> on my OS X (10.3) localhost. I followed the instructions on the
> following site to configure apache for perl my modifying the file
> "/etc/httpd/httpd.conf" on my computer.
>
> http://www.cgi101.com/book/connect/mac.html
>
> The only difference from that webpage is my configure file will parse
> ".shtml" files instead of ".html" files.


shtml = SSI, not CGI

> I have written a file called "first.cgi" and saved it in my sites
> folder.


Use a cgi-bin dir *outside* your document root.

> #!/usr/bin/perl -w


use warnings; # instead of -w
use strict;

Also, use -T.

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


Be careful with printing your own headers...

You can use <<HERE docs, eg.

print <<HELLO;
Content-type: text/plain

Hello, World!
HELLO

(note that what you served was not valid HTML, hence I changed the
content-type to plain).

> The forbidden message did not go away. What's going wrong? Is apache
> not configured correctly? Do i need any extra files in my sites
> folder?


make a cgi-bin directory in the *parent* of your Document Root, e.g.

cgi-bin
htdocs

next you need:

ScriptAlias /cgi-bin/ "/absolute/path/to/cgi-bin/"

<Directory "/absolute/path/to/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Note that the second path has *no* trailing / and the first *has*.

If you are serious in developing stuff I recommend using virtual hosts,
see: http://johnbokma.com/mexit/2005/01/0...onf-split.html

Check your error_log, I often use:

tail -f logs/error_log

HTH,


--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

 
Reply With Quote
 
 
 
 
axel@white-eagle.co.uk
Guest
Posts: n/a
 
      05-10-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> When i point my browser to "http://localhost/~peter/first.cgi" I get
> the following message
>
> Forbidden
> You don't have permission to access /~peter/first.cgi on this server.
> Apache/1.3.33 Server at peter-michauxs-computer.local Port 80
>
> I tried using the terminal command "chmod 755 first.cgi". It looks like
> the permissions are set correctly
>
> -rwxr-xr-x 1 peter peter 108 9 May 23:14 first.cgi*
>
> The forbidden message did not go away. What's going wrong? Is apache
> not configured correctly? Do i need any extra files in my sites folder?


Have you checked that the permissions on the directory allow access?
Quick check: copy first.cgi to first.html and see if the perl script is
displayed as text.

Otherwise it seems like an Apache configuration issue (perhaps CGI scripts
are not enabled in user directories).

Axel


 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      05-10-2005
(E-Mail Removed) wrote:
> I am trying to learn about perl and cgi.


That's fine. If you need help with Perl, this is a good place to ask.
Btw, please study the posting guidelines:
http://mail.augustmail.com/~tadmc/cl...uidelines.html

You'd better not bring up CGI questions here, unless the problem is
related to the use of any of the CPAN modules for dealing with CGI
tasks. Other CGI questions are better asked in
comp.infosystems.www.authoring.cgi.

> I have apache and php running on my OS X (10.3) localhost.


<snip>

> When i point my browser to "http://localhost/~peter/first.cgi" I get
> the following message
>
> Forbidden
> You don't have permission to access /~peter/first.cgi on this server.
> Apache/1.3.33 Server at peter-michauxs-computer.local Port 80


That's an Apache configuration problem, which is even more off topic in
this group. You may want to try this group instead:

comp.infosystems.www.servers.ms-windows

OTOH, if you want to avoid the hazzle you are currently experiencing,
why not try the bundle at http://www.indigostar.com/indigoperl.htm

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
petermichaux@yahoo.com
Guest
Posts: n/a
 
      05-10-2005
Hi John,

Thanks for the reply. Unfortunately it went over my head. Could you
clarify a few points

>> The only difference from that webpage is my configure file will

parse
>> ".shtml" files instead of ".html" files.


>shtml = SSI, not CGI


Will this affect my first.cgi test since i am directing my browser to
the actual cgi file? So what should I do?

>> I have written a file called "first.cgi" and saved it in my sites

folder.

>Use a cgi-bin dir *outside* your document root.


My sites folder is "/users/peter/Sites". What should the cgi-bin
directory be?

I cannot understand what you complete first.cgi file would be with the
modifications you have suggested. I have seen other hello world files
like mine suggested on the internet. I'm surprised that you seem to say
it is not even close to correct.

I do not understand "make a cgi-bin directory in the *parent* of your
Document Root, e.g....". Where would cgi-bin and htdocs be in relation
to "/users/peter/Sites"?

Sorry, I guess I need a bit more hand holding to get started. But I am
really interested.

Thanks,
Peter

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      05-10-2005
Gunnar Hjalmarsson <(E-Mail Removed)> wrote in news:3ecahgF2br3qU1
@individual.net:

> (E-Mail Removed) wrote:


....

>> When i point my browser to "http://localhost/~peter/first.cgi" I get
>> the following message
>>
>> Forbidden
>> You don't have permission to access /~peter/first.cgi on this server.
>> Apache/1.3.33 Server at peter-michauxs-computer.local Port 80

>
> That's an Apache configuration problem, which is even more off topic in
> this group. You may want to try this group instead:
>
> comp.infosystems.www.servers.ms-windows


He is on OS X, which is based on BSD Unix so, he'll probably have better
luck in

comp.infosystems.www.servers.unix
comp.infosystems.www.servers.mac

> OTOH, if you want to avoid the hazzle you are currently experiencing,
> why not try the bundle at http://www.indigostar.com/indigoperl.htm


I don't think that is available for OS X.

Sinan
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      05-10-2005
(E-Mail Removed) wrote in news:1115747652.929148.72670
@o13g2000cwo.googlegroups.com:

> My sites folder is "/users/peter/Sites". What should the cgi-bin
> directory be?
>
> I cannot understand what you complete first.cgi file would be with the
> modifications you have suggested. I have seen other hello world files
> like mine suggested on the internet. I'm surprised that you seem to say
> it is not even close to correct.
>
> I do not understand "make a cgi-bin directory in the *parent* of your
> Document Root, e.g....". Where would cgi-bin and htdocs be in relation
> to "/users/peter/Sites"?
>
> Sorry, I guess I need a bit more hand holding to get started. But I am
> really interested.


Good for you. However, what you are interested in, currently, does not have
anything to do with Perl.

You have an Apache configuration issue. Thus, you should read about Apache
configuration, and ask questions on the relevant fora.

Sinan
 
Reply With Quote
 
petermichaux@yahoo.com
Guest
Posts: n/a
 
      05-10-2005
The off topic messages did not appear until after I posted my second
message. It seemed like one person did not mind the question so I
continued. Rough crowd 'round here.

As far as _perl_ goes, is my file "first.cgi" acceptable for what I am
trying to do? John does not think it will work.

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "Hello, World!\n";

Thanks,
Peter

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      05-10-2005
A. Sinan Unur wrote:
> Gunnar Hjalmarsson wrote:
>> That's an Apache configuration problem, which is even more off topic in
>> this group. You may want to try this group instead:
>>
>> comp.infosystems.www.servers.ms-windows

>
> He is on OS X, which is based on BSD Unix so, he'll probably have better
> luck in
>
> comp.infosystems.www.servers.unix
> comp.infosystems.www.servers.mac


Thanks for the correction! Don't know why OS X made me think Windows...

>> OTOH, if you want to avoid the hazzle you are currently experiencing,
>> why not try the bundle at http://www.indigostar.com/indigoperl.htm

>
> I don't think that is available for OS X.


No, of course it's not.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      05-10-2005
(E-Mail Removed) wrote:
> Rough crowd 'round here.


If you consider the volume of messages in this group, you'll likely
understand why we point out when somebody brings up an off topic problem.

> As far as _perl_ goes, is my file "first.cgi" acceptable for what I am
> trying to do? John does not think it will work.


John didn't say it won't work, but he suggested a couple of alternative
ways to do it.

> #!/usr/bin/perl -w
> print "Content-type: text/html\n\n";
> print "Hello, World!\n";


That's a perfectly fine script for testing purposes ( provided that the
path to the Perl interpreter actually is /usr/bin/perl ).

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit Ring server to localhost only. RingFinger.new('localhost')apparently doesn't work koicat Ruby 0 07-02-2010 08:01 PM
change from "//localhost:numbers/" to just "//localhost/"? =?Utf-8?B?S2VuTGVl?= ASP .Net 5 02-12-2006 05:14 AM
Localhost isn't localhost EdwardH Java 20 10-01-2005 12:08 AM
Can I Reset the Root from localhost/myproject/ to localhost/ Alex ASP .Net 4 02-08-2005 01:45 PM
HttpModule -- how to intercept urls like http://localhost/abc/def or http://localhost/abc/def/ where abc, def are non virtual dir Jiong Feng ASP .Net 0 11-19-2003 05:29 AM



Advertisments