Install the Mason Framework

The Mason Framework is simple to install if you have HTML::Mason working. If you don't have the HTML::Mason installed and working, most Linux distributions already include it on the packages, so just install it.

Let's assume you are going to install the Mason Framework using the .tar.gz file that you can find in the Download page.

I like everything that isn't installed using the distribution packages under /servers (Note: before anyone start talking about path conventions and stuff like those, I don't care. Install it where you want, just change the paths). For this exercise I'll assume /servers/software/mfwork/ as the base directory for the instalation of the Mason Framework.

So... /servers/software:

cd /servers/softwarewget http://mason-framework.net/download/mfwork-current.tgztar -zxf mfwork-current.tgzcd mfwork/databasemysql -u root -p
Enter Password:
mysql> CREATE DATABASE mfwork;
mysql> use mfwork;
mysql> source mfwork.sql;
mysql> GRANT INSERT, UPDATE, DELETE, SELECT on mfwork.* TO mfwork@localhost identified by 'mfworkpasswd' ;


Note: Please, please, please... don't use those passwords. Specially don't use those passwords if you are in a shared server.

Ok. You're warned. Now let's move. At this point you have the mason framework files, you have the database for your first Mason Framework instance. So, now you need to configure your apache. I'm assuming an apache configuration that already loads modperl, and all you need is to load the Perl Modules and define your virtualhost.


PerlModule HTML::Mason::ApacheHandler
PerlModule Apache::DBI
PerlModule Digest::MD5
PerlModule POSIX
PerlModule Apache::Request

<Perl> use lib qw(/servers/software/mfwork/lib); use MFWork; use MFWork::Handler; </Perl>
<VirtualHost *:80>         ServerName yourdomain.com  #      ServerAlias *
        DocumentRoot /servers/software/mfwork/docroot
        SetHandler perl-script         PerlHandler HTML::Mason::ApacheHandler         PerlSetVar MasonCompRoot "/servers/data/htdocs/mfwork"         PerlSetVar MasonDataDir "/var/mason"         PerlSetVar       MasonDeclineDirs 0
        <Location />                 PerlSetVar compdir "/comps/"                 PerlSetVar dbname "mfwork"                 PerlSetVar dbuser "mfwork"                 PerlSetVar dbpass "mfworkpasswd"                 PerlSetVar sitebase "yourdomain.com"         </Location> </VirtualHost>


The values in the PerlSetVar lines need to match the related values on the GRANT, and the compdir must be the mason path to the components. If you use a MasonCompRoot value related to the mfwork directory, "/comps/" works fine, but if you have a diferent Mason Configuration, you need to match the value in compdir with the correct location of the comps directory inside the mfwork directory.

What about now?

 # /etc/init.d/apache-perl restart


And everything should be up and running. Point your browser to your virtualhost, and you should see a vary basic homepage, with a login box in you left. Login with admin and admin123, and you are ready to go. Change your password before anything else.

Aditional options



Directories to images and downloads

You can put directories inside your documentroot and then configure them, so HTML::Mason is not the handler for that directories, or you can configure alias for other directories. I would prefer those, because that way you can use a same software directory to handle several virtualhosts, each with several hosts.

This is what you would need:

<VirtualHost *:80>
 # ...

  <Alias /images /servers/images/yourdomain.com/>   <Location /images>     setHandler default-handler   </Location> </VirtualHost>


Configure several virtualhost

Even if the Mason Framework can handle several hosts (and sites) with a single instalation, you can still want to have diferent instances of the Mason Framework (with diferent databases). What do you need to configure a diferent virtualhost?

  1. Create a new database
  2. Restore the default dump in the new database
  3. GRANT the permitions
  4. Create the new virtualhost with the correct paramenter
  5. If you need Alias to images or downloads, create them
  6. Restart the apache.


What's next? Well, personalize your sites.