You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ray and Lara Recendez <Ra...@PacBell.Net> on 2001/09/17 22:15:44 UTC

Apache::Hello

PLEASE HELP.....

I am trying to get Apache::Hello to work. I saved it as Hello.pm in
lib/perl/Apache. Below are my setup files and pertinent info. When I access
the virtual location (hello/world) from Apache's root directory, my browser
returns the following message: "The document contains no data." I can
successfully run Apache's built-in server-status module. I don't receive any
errors when starting Apache and don' t see any errors in the logs. Any
suggestions?

Apache Version 1.3.9
mod_perl Version 1.26
Perl Version 5.6.1

# vi startup.pl
"startup.pl" 19 lines, 372 characters
#!/usr/local/bin/perl

# modify the include path before we do anything else
BEGIN {
   use Apache ();
   use lib Apache->server_root_relative('lib/perl');
}

# commonly used modules
use Apache::Registry ();
use Apache::Constants ();
use CGI qw(-compile :all);
use CGI::Carp ();

# put any other common modules here
# use Apache::DBI ();
# use LWP ();
# use DB_File ();
1;

# vi perl.conf
"perl.conf" 10 lines, 318 characters
#Tells Apache to load and run the startup script when it is first launched.
PerlRequire             conf/startup.pl
PerlFreshRestart        On

###I also tried this in httpd.conf because it was not working and
server-status is in httpd.conf
<Location /hello/world>
   SetHandler   perl-script
   PerlHandler  Apache::Hello
</Location>

# vi Hello.pm
"Hello.pm" 26 lines, 392 characters
package Apache::Hello;
# File: Apache/Hello.pm

use strict;
use Apache::Constants qw(:common);

sub handler {
   my $r = shift;
   $r->content-type('text/html');
   $r->send_http_header;
   my $host = $r->get_remote_host;
   $r->print(<<END);
<HTML>
<HEAD>
<TITLE>Hello There</TITLE>
</HEAD>
<BODY>
<H1>Hello $host</H1>
Who would take this book seriously if the first example didn't
say "hello world"?
</BODY>
</HTML>
END
   return OK;
}

1;

Thanks, Ray


Re: Apache::Hello

Posted by Jeremy Howard <jh...@howard.fm>.
Ray and Lara Recendez wrote:
> I am trying to get Apache::Hello to work. 
<...>
> #!/usr/local/bin/perl

Turn PerlWarn On as described here:
  http://perl.apache.org/src/mod_perl.html#SWITCHES

Also try running Apache in single-user mode:
  /usr/local/apache/bin/apachectl -X

This helps you pick up problems in simple scripts.



Re: Apache::Hello

Posted by Tatsuhiko Miyagawa <mi...@edge.co.jp>.
On Mon, 17 Sep 2001 13:15:44 -0700
Ray and Lara Recendez <Ra...@PacBell.Net> wrote:

> # vi Hello.pm
> "Hello.pm" 26 lines, 392 characters
> package Apache::Hello;
> # File: Apache/Hello.pm
> 
> use strict;
> use Apache::Constants qw(:common);
> 
> sub handler {
>    my $r = shift;
>    $r->content-type('text/html');

s/content-type/content_type/

Maybe you've got the error msg like "Undefined subroutine
&Apache::Hello::type called at ..."


--
Tatsuhiko Miyagawa <mi...@bulknews.net>