Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

iceweasel does not execute perl scripts

22 views
Skip to first unread message

kamaraju kusumanchi

unread,
Nov 16, 2014, 9:30:03 PM11/16/14
to
I am trying to set up the apache server with mod_perl so that I can
execute perl scripts in the browser itself.

I have the following packages installed

rajulocal@hogwarts:~/public_html/perl$ dpkg -l \*apache\* | grep ^ii
ii apache2 2.4.10-6 amd64 Apache HTTP Server
ii apache2-bin 2.4.10-6 amd64 Apache HTTP
Server (modules and other binary files)
ii apache2-data 2.4.10-6 all Apache HTTP
Server (common files)
ii apache2-utils 2.4.10-6 amd64 Apache HTTP
Server (utility programs for web servers)
ii libapache-poi-java 3.10-1 all Apache POI
- Java API for Microsoft Documents
ii libapache-pom-java 10-2 all Maven
metadata for all Apache Software projects
ii libapache2-mod-perl2 2.0.9~1624218-2 amd64 Integration
of perl with the Apache2 web server
ii libapache2-mod-perl2-doc 2.0.9~1624218-2 all Integration
of perl with the Apache2 web server - documentation
ii libapache2-reload-perl 0.12-3 all module for
reloading Perl modules when changed on disk

My iceweasel version is
rajulocal@hogwarts:~/public_html/perl$ dpkg -l \*iceweasel\* | grep
^ii | grep -v l10n
ii iceweasel 31.2.0esr-2~deb7u1 amd64 Web
browser based on Firefox
ii iceweasel-dbg 31.2.0esr-2~deb7u1 amd64
Debugging symbols for Iceweasel

I checked that the perl module is enabled

root@hogwarts:~# a2enmod perl
Module perl already enabled

I checked that the apache server is running by going to
http://localhost/index.html and that the userdir module is working by
going to http://localhost/~rajulocal/index.html .

I created the following perl script

rajulocal@hogwarts:~/public_html/perl$ cat mod_perl_rules1.pl
print "Content-type: text/plain\n\n";
print "mod_perl rules!\n";

However, if I point the iceweasel brower to
http://localhost/~rajulocal/perl/mod_perl_rules1.pl , it launches the
file download dialog saying

You have chosen to open:
mod_perl_rules1.pl
which is: PL file (65 bytes)
from: http://localhost

What should Iceweasel do with this file?
Open with ...
Save File
Do this automatically for files like this from now on.
Cancel Ok


Is there some configuration I am missing? I tried looking at articles
such as https://www.debian-administration.org/article/635/A_brief_introduction_to_mod_perl_-_Part_1
but none of them seem to have this problem.

Any thoughts/suggestions/comments are most welcome.

raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: https://lists.debian.org/CABpbYac-yznCw1aD6BZ=kEBY0xXJ0OKCrZJ9ZcFkcctPtd=9...@mail.gmail.com

David Christensen

unread,
Nov 16, 2014, 10:30:05 PM11/16/14
to
On 11/16/2014 06:20 PM, kamaraju kusumanchi wrote:
> I am trying to set up the apache server with mod_perl so that I can
> execute perl scripts in the browser itself.

There once was an attempt to put Perl code into web pages for execution
by browsers (among others), but JavaScript won that contest:

http://www.cpan.org/authors/id/M/MS/MSERGEANT/PSIntro.html


http://docs.activestate.com/activeperl/5.8/Components/Windows/PerlScript.html


mod_perl is a persistent Perl interpreter running inside Apache, and
avoids the forking and initialization costs incurred by Perl CGI scripts.


> rajulocal@hogwarts:~/public_html/perl$ cat mod_perl_rules1.pl
> print "Content-type: text/plain\n\n";
> print "mod_perl rules!\n";
...
> However, if I point the iceweasel brower to
> http://localhost/~rajulocal/perl/mod_perl_rules1.pl , it launches the
> file download dialog

That is not a valid mod_perl program, and Apache requires additional
configuration to know what URL's are to be passed to mod_perl. For all
things mod_perl, please see:

http://perl.apache.org/


Without seeing your Apache configuration, it may or may not be a valid
Perl CGI script. Have you set the execute bit on the file?


Note that PSGI/ Plack is a newer way to run Perl programs inside a web
server (Apache, nginx, and others):

http://plackperl.org/


HTH,

David


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: https://lists.debian.org/546968BD...@holgerdanske.com

kamaraju kusumanchi

unread,
Nov 17, 2014, 1:10:04 AM11/17/14
to
On Sun, Nov 16, 2014 at 10:17 PM, David Christensen
<dpch...@holgerdanske.com> wrote:
> On 11/16/2014 06:20 PM, kamaraju kusumanchi wrote:
>> rajulocal@hogwarts:~/public_html/perl$ cat mod_perl_rules1.pl
>> print "Content-type: text/plain\n\n";
>> print "mod_perl rules!\n";
>
> ...
>>
>> However, if I point the iceweasel brower to
>> http://localhost/~rajulocal/perl/mod_perl_rules1.pl , it launches the
>> file download dialog
>
>
> That is not a valid mod_perl program, and Apache requires additional
> configuration to know what URL's are to be passed to mod_perl. For all
> things mod_perl, please see:
>
> http://perl.apache.org/

Thanks for pointing out that Apache requires additional configuration.

I initially looked at
http://perl.apache.org/docs/2.0/user/intro/start_fast.html before
posting to the list. But it was difficult to follow since the website
tries to configure it differently than what seems to be Debian's way
of configuring things.

For example, it asks to add the following to httpd.conf
LoadModule perl_module modules/mod_perl.so

But there is no httpd.conf in Debian. Instead I found this in Debian

root@hogwarts:/etc/apache2/mods-enabled# cat perl.load
LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so

It talks about "Registry Scripts" without first telling what is
actually meant by a registry script. So it was all confusing to me.

> Without seeing your Apache configuration, it may or may not be a valid Perl
> CGI script. Have you set the execute bit on the file?

I finally got it working through some trial and error. Here is my
configuration file

root@hogwarts:/etc/apache2/mods-enabled# cat perl.conf
<IfModule mod_perl.c>
Alias /perl/ /home/rajulocal/public_html/perl/
<Location /perl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
</Location>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

root@hogwarts:/etc/apache2/mods-enabled# ls -al perl.conf
-rw-r--r-- 1 root root 308 Nov 17 00:19 perl.conf

It is interesting that for other modules (ex:- userdir) Debian
supplies userdir.load, userdir.conf files . But for the mod_perl,
Debian only supplies that perl.load file.

Another issue was that, in the browser I was pointing to
http://localhost/~rajulocal/perl/mod_perl_rules1.pl which opens up the
download dialog. But instead, I should point it to
http://localhost/perl/mod_perl_rules1.pl which works fine. I realized
that this is due to the Alias directive. But no where in the docs
http://perl.apache.org/docs/2.0/user/config/config.html , this
directive is explained. Instead one is expected to refer to the docs
of old version ( http://perl.apache.org/docs/1.0/guide/config.html )
where these things are explained.

In the hindsight, all this looks pretty obvious. But it took me a long
time to figure it all out.

> Note that PSGI/ Plack is a newer way to run Perl programs inside a web
> server (Apache, nginx, and others):
>
> http://plackperl.org/

Ultimately, what I want to do is a very simple thing. May be I am
using the wrong tools here and making it more complicated than it
actually should be. Please point me in the right direction if this is
the case.

I have a perl script that takes a bunch of input parameters and spits
some output. I wanted to write a web interface for it where I get the
input from the user via "HTML forms" and pass it to the perl script,
then run it and show the output. Should I use javascript for this sort
of thing? If so, where does it fit in? Any pointers to good
documentation are appreciated.

thanks
raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: https://lists.debian.org/CABpbYafPXAJh1gnH=UAPz2vfLuZ1mCfb6...@mail.gmail.com

David Christensen

unread,
Nov 18, 2014, 12:00:04 AM11/18/14
to
On 11/16/2014 10:01 PM, kamaraju kusumanchi wrote:
> Thanks for pointing out that Apache requires additional configuration.
> I initially looked at
> http://perl.apache.org/docs/2.0/user/intro/start_fast.html before
> posting to the list. But it was difficult to follow since the website
> tries to configure it differently than what seems to be Debian's way
> of configuring things.
> For example, it asks to add the following to httpd.conf
> LoadModule perl_module modules/mod_perl.so
> But there is no httpd.conf in Debian. Instead I found this in Debian
> root@hogwarts:/etc/apache2/mods-enabled# cat perl.load
> LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so
> It talks about "Registry Scripts" without first telling what is
> actually meant by a registry script. So it was all confusing to me.

Yes, there are differences between stock Apache and Debian Apache. Take
a look at 'apropos apache', a2enmod(8), a2dismod(8), and the
/etc/apache2 tree.


> I finally got it working through some trial and error. Here is my
> configuration file
> root@hogwarts:/etc/apache2/mods-enabled# cat perl.conf
> <IfModule mod_perl.c>
> Alias /perl/ /home/rajulocal/public_html/perl/
> <Location /perl>
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> PerlOptions +ParseHeaders
> Options +ExecCGI
> Order allow,deny
> Allow from all
> </Location>
> </IfModule>

My "That is not a valid mod_perl program" statement was based upon the
traditional mod_perl handler registration/ callback approach discussed
in the Eagle book:

http://shop.oreilly.com/product/9781565925670.do


I'd forgotten that mod_perl has a backwards compatibility/ forward
migration feature which allows mod_perl to run Perl CGI scripts. That's
what you found. Beware that in the past, there was the risk of bugs due
to variable initialization assumptions common in CGI scripts. Read your
Apache documentation carefully if you're going to deploy this.


> But no where in the docs
> http://perl.apache.org/docs/2.0/user/config/config.html , this
> directive is explained. Instead one is expected to refer to the docs
> of old version ( http://perl.apache.org/docs/1.0/guide/config.html )
> where these things are explained.
> In the hindsight, all this looks pretty obvious. But it took me a long
> time to figure it all out.

Congratulations on your determination and new-found knowledge! :-)


> Ultimately, what I want to do is a very simple thing. May be I am
> using the wrong tools here and making it more complicated than it
> actually should be. Please point me in the right direction if this is
> the case.
> I have a perl script that takes a bunch of input parameters and spits
> some output. I wanted to write a web interface for it where I get the
> input from the user via "HTML forms" and pass it to the perl script,
> then run it and show the output. Should I use javascript for this sort
> of thing? If so, where does it fit in? Any pointers to good
> documentation are appreciated.

Choosing a computer programming language is difficult. If you're up to
it, read "Structure and Interpretation of Computer Programs" and work as
many exercises as you can stand:

http://mitpress.mit.edu/sicp/full-text/book/book.html

SICP is not for the faint of heart -- the difficulty ranges from hard to
extreme. But your programming language world-view and coding skills
will be transformed.


Another consideration is how to deliver your program. Web browser based
applications, by design, have limited access to client-side data.
Basically, the user has to manually enter, save, upload, download, etc.,
everything. But, if they are standards-compliant, they can run in most
any modern browser. Native applications, including clients for client/
server applications, have far more capabilities (and risks). But, you
have to write one for each and every platform. Thus, the appeal of
Java/ JVM.


If you're going to let other people run programs on your computer, you
need to deal with security -- especially if the computer is on the
Internet. This adds system and network design and administration.


David


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: https://lists.debian.org/546AD07A...@holgerdanske.com
0 new messages