On the server, Perlbrew offers a much improved environment to manage Perl modules and it is higly recommended. To install Perlbrew, do the following:
Installing and activating Perlbrew enables one to, among the many options, replace the the CPAN install command for modules: 'perl -MCPAN -e shell' with simply: 'cpanm -S [module]' which installs any Perl modules into the server's existing set. Dropping the '-S', will place the module within a particular user's local directories (which unless a program is coded to search for, will be not be picked, say in a webserver-based app). When returning to one's user space, to re-activate Perlbrew, execute the following command:
Prequisites: to have the custom but basic Dancer2 Myexample App functional and rendered by the Apache2 webserver as described earlier on this website - with the iRedmail app setup using one's own domain.
For an office that requires the sharing of information to staff, there is a useful plugin: Dancer2::Plugin::Auth::Extensible whereby staff usernames, passwords and even roles can be configured through the app's config.yml file. A straighforward but simple example is explained at: PerlMaven-Protecting Pages in Dancer2. Note that the encrypted password facility doesn't function.
Lastly for the email function, create via 'iredadmin' two users: self and info based on your domain (eg. self@myexample.com and info@myexample.com). In the myexample(2) app in the myexample.pm file, change the default email addresses accordingly.
For a functioning example, download the myexample2.zip, upload to your server, and after setting its permissions (775), the setup goes as follows:
Enter in the browser, one's domain at port:5000 (eg. http://[MySeverIP]:5000), the result should the appearance of the 3-page website. Type in the PuTTY console: 'ctl'+c to exit
For deployment, see the link below.
After ensuring a successful run with the Plackup server, switch it off and, with no change in the previous settings of Apache2 for the myexample app, restart the webserver.
For a simple usage example, see Alternative Dancer2 Templating Engines
Some useful constructions using the Template-Toolkit (note: /docs directory was added):
For images: img src="[% request.uri_base %]/images/mypic.jpg" alt="mypic" class="w3-image"
For docs: a href="[% request.uri_base %]/docs/sometext.txt" target="_blank"> sometext.txt /a
For a discussion on the template engine choices, consider this reference: MasonBook-Ch1
Note: If one chooses to use Mason2, Dancer2::Template::Mason2 is required to be installed and the line in config.yml is: template "mason2"
Dancer2 | Dancer-PartB |
Dancer-Deploy | Dancer-Extras |