Skip to content

Deploying on Lighttpd with FastCGI

kapouik edited this page Mar 22, 2017 · 5 revisions

Deploying on lighttpd with FastCGI

While lighttpd may not be in vogue (yes, there are documented memory leak problems - although I've never run into them myself) it is fairly straight forward to wire it up to serve a Mojolicious app via FastCGI.

Native FastCGI support was removed from Mojolicious with version 1.98. To still be able to run your apps using FastCGI you have to install the module Mojo::Server::FastCGI separately.

$ cpan cpan> install Mojo::Server::FastCGI

Installation of FastCGI

Mojo::Server::FastCGI is maintained by Árpád Szász. If you discover any problems with it, you can, however, ask for support using the official Mojo channels.

First, make sure that script/my_app has the permissions 755. Out-of-the-box it seems to have 744, or at least that was the way I found it when I looked.

Secondly, enable FastCGI in lighttpd and insert the following rules (assuming you want lighttpd to manage the FastCGI process for you - I find this handy):

$HTTP["host"] == "yourhost.com" {
    fastcgi.server = ("/" => (( 
        "bin-path" => "/path/to/script/my_app fastcgi",
        "check-local" => "disable",
        "fix-root-scriptname" => "enable",
        "port" => 1027))
    )
}

Obviously you will need to adjust yourhost.com, /path/to and perhaps the port number.

Clone this wiki locally