1

I am quite new to Perl and Mason. Please excuse me if you think my question here is trivial.

There is a website that has been developed using the Mason framework. As per my knowledge, it only uses Apache, Perl (ModPerl), Mason and MySQL. I have the website's code with me and I am trying to make the website work on my Ubuntu localhost.

These are the steps that I followed from scratch:

  1. Installed Apache, MySQL, Perl and ModPerl
  2. Installed HTML-Mason with cpanm: cpanm HTML::Mason
  3. Added the following lines to apache.conf

AddType text/html .mhtml

PerlSetVar MasonCompRoot /var/www/comps
PerlSetVar MasonDataDir /var/mason-data-dir
PerlModule HTML::Mason::ApacheHandler

<LocationMatch "\.mthml$">
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler
</LocationMatch>

<LocationMatch "(.mas|handler)$">
    SetHandler perl-script
    PerlHandler "sub { return Apache::Constants::NOT_FOUND }"
</LocationMatch>

I am testing like this

I created a simple "Hello World" file named test.mhtml and placed it in the directory /var/www/. When I try to open this file in the browser it displays the following:

% my $var = "World"; Hello <%$var%>

instead of displaying just Hello World

Do I have to make any other configuration changes?

Borodin
  • 126,100
  • 9
  • 70
  • 144
Amogh
  • 11
  • 1
  • Is that what's in `test.mhtml`? It's not valid MHTML data – Borodin Nov 18 '14 at 23:32
  • Thanks for your reply @Borodin. Yes, that is what I have written in `test.mthml` Can you please tell me what code I can have in my mthml file to do a simple test and find out if Mason is working or not? Here is the content of `index.mthml` that I found in the website's source code, just for your reference: `<& lib/firstPage.mas &>` `<%attr> class=> 'www' %attr>` – Amogh Nov 19 '14 at 00:00
  • You seem to be getting very confused. First of all you have both `mhtml` and `mthml` in various places in your code. I assume that's a typo, but if it's a copy of your real code then it's going to stop it working. Secondly, do you *really* mean MHTML? That's MIME HTML, which is a way of putting the HTML together with all the resources -- images, CSS, JavaScript -- into a single file. And then what you're actually *writing* is a Mason file that, when executed, produces a simple text string, not HTML or MHTML. I can't tell what you're *supposed* to be doing so you need to ask someone who does. – Borodin Nov 19 '14 at 01:32
  • Thanks again for your reply @Borodin! Yes, that was a typo. I meant `mhtml` and not `mthml`. You are right, I was confused. I was actually trying to test simple Mason code through the `test.mhtml` file, and was trying to check if Mason renders that code in the browser. A while ago I realized that, in `apache2.conf`, I had set the variable `MasonCompRoot` to `/var/www/comps` but had placed `test.mhtml` in `/var/www`. I changed the path to `/var/www` and opened the file in my localhost. Only the string `Hello World` got displayed in the browser. Thanks for your help! :) – Amogh Nov 20 '14 at 04:35

0 Answers0