in reply to NGINX Unit + PSGI + Perl

The regular build instructions for Perl were a wash for me: http://unit.nginx.org/installation/. My guess is that something about the darwin verison of Perl I have made it impossible for the configure to find/use and I didn't want to mess with it or try to perlbrew it to see if worked better.

This, however, seems to install fine and easily: https://github.com/skaji/nginx-unit-example-perl. I'm not going to mess around more tonight but the following got it together in a standalone dir.

git clone git@github.com:skaji/nginx-unit-example-perl.git cd nginx-unit-example-perl/ ./build.sh # perl 5.26.1 to ./perl/bin/perl # nginx unit to ./unit/build/unitd /unit/build/unitd --modules ./unit/build --no-daemon # ... 2019/02/23 00:41:35 [info] 85210#15065386 unit started

Replies are listed 'Best First'.
Re^2: NGINX Unit + PSGI + Perl
by tbusch (Sexton) on Feb 23, 2019 at 09:07 UTC
    Thanks! I got it to work on CentOS7. Here are my steps:

    sudo su -
    Create /etc/yum.repos.d/unit.repo:
    [unit] name=unit repo baseurl=https://packages.nginx.org/unit/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
    Install unit and unit-perl
    yum install -y unit unit-perl
    In /etc/unit/ create two files:

    start.json
    { "type": "perl", "processes": 5, "script": "/etc/unit/app.psgi" }
    app.psgi
    use strict; use warnings; use Plack::Builder; my $app = sub { my $env = shift; [200, [], ["Hello world from PSGI!\n"]]; }; builder { enable 'ContentLength'; $app; };
    Then start unit:
    service unit start
    Configure unit using the following commands:
    curl -X PUT --data-binary @/etc/unit/start.json --unix-socket /var/run +/control.unit.sock http://localhost/config/applications/psgiapp curl -X PUT --data-binary '{"application":"psgiapp"}' --unix-socket /v +ar/run/control.unit.sock 'http://localhost/config/listeners/*:8000'
    .. and check the resulting config:
    curl --unix-socket /var/run/control.unit.sock http://localhost/
    ... and finally do the Hello World test:
    curl -v http://127.0.0.1:8000/
    Voila!
      The question is now, how do you get a Mojolicious::Lite app to work ?