np FastCGI runtime
(work in progress)
The fcgi/bin folder contains the actual runtime, use srv.sh to start the server. To configure nginx to use np, follow this recipe:
-
open /etc/nginx/nginx.conf in a text editor
-
add this FCGI handler to your config. There should already be one for PHP, np's will be just the same and you can add it directly below that:
location ~ .np$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.np; fastcgi_param SCRIPT_FILENAME /srv/www/htdocs/$host$fastcgi_script_name; include fastcgi_params; }
Important: change "/srv/www/htdocs/$host$fastcgi_script_name" to wherever your docs are served from. If in doubt, just copy the same line from your existing PHP config.
-
locate your "index" directive and add "index.np" to that. Afterwards, it should look similar (but not necessarily identical) to this:
index index.php index.np index.html index.htm;
-
if you have a try_files directive, add index.np to that as well. For example, like this:
try_files $uri $uri/ index.php index.np;
-
save, and restart nginx with "/etc/init.d/nginx reload" or whatever is appropriate for your system. Review and then start fcgi/bin/srv.sh. If you plan to keep np running for some time, use the Unix "screen" command to generate a persistent session or resort to making a regular service script for it (not included here at this time).
-
keep in mind that for this to work, the np server has to be actually running. As long as srv.sh isn't running, you'll get a "Bad Gateway" message from nginx.
As the runtime matures, I'll update tutorials and documentation at http://np-lang.org/