in reply to Re: NGINX Unit + PSGI + Perl
in thread NGINX Unit + PSGI + Perl

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!

Replies are listed 'Best First'.
Re^3: NGINX Unit + PSGI + Perl
by tbusch (Sexton) on Feb 23, 2019 at 09:30 UTC
    The question is now, how do you get a Mojolicious::Lite app to work ?