To explain some more details about the Dancer documentation for Apache, where they say

As a CGI Script
...
AddHandler cgi-script .cgi
...

They are suggesting that each incoming request would launch a new one-shot call to perl running your Dancer app to serve a single request. This is slow and nobody wants to do it like this.

Where the documentation says

As a FastCGI Script
...
You will still need to enable mod_rewrite, but will need to use a FastCGI module instead of a CGI module. There are 3 available: mod_fcgid, mod_fastcgi and mod_proxy_fcgi. For this example, we will use mod_fastcgi (a2enmod fastcgi in Debian).
...
FastCgiServer /srv/www.example.com/public/dispatch.fcgi
...
AddHandler fastcgi-script .fcgi

they are saying that your apache hosting provider needs to have one of those three fastcgi modules installed (you'll have to ask them if any are available). That module will see your .htaccess file and load a long-running copy of your application, consuming server resources based on how many workers you configure. This is what you want, but may not be something your hosting provider wants.

Checking with ChatGPT,

No, the FastCgiServer directive is not typically allowed in an .htaccess file.
which agrees with the general lack of google results for that example.

I will second the opinion of others that shared hosting providers are not something you want to use for perl web apps. The shared-hosting-behind-apache model was popular 20 years ago, but it has numerous problems and everyone generally hated it, and we've all moved on (except PHP folks, for whom it still kind of works)

There's a bigger learning curve, but I recommend getting comfortable with managing your own virtual machine on a cloud platform like Linode or Digital Ocean. Their small instances are $5/mo and are plenty for running a perl web app with small userbase. Having your own VM puts you in full control of apache, or you could ditch apache and use nginx, or Traefik. Traefik gives you free SSL certs and is a fairly nice experience compared to apache; it doesn't serve static files though.

If you've never managed your own host before and want to skip the learning curve, DigitalOcean also has the App service which deploys one of your GitHub repos directly into a VM for you, so all you have to do is push changes to your GitHub repo and poof, they're available with SSL served from a VM. Here's a blog article I found that sums it up.


In reply to Re^2: Dancer newbie question by NERDVANA
in thread Dancer newbie question by erickp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.