A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Webserver experiment 2019

Rough draft notes:


DNS
  • http://freedns.afraid.org
Platform
  • Digital Ocean
  • Ubuntu 16.04
Application container
  • UWSGI
  • https://uwsgi-docs.readthedocs.io/en/latest/Install.html
  • https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
  • wget https://projects.unbit.it/downloads/uwsgi-2.0.17.1.tar.gz
  • apt-get install libperl-dev
  • python uwsgiconfig.py --build
  • ./uwsgi --plugins psgi -s :3031 -M -p 4 --wsgi-file /path/to/foobar.py -m # for python. Works
    • But it breaks if you do "python uwsgiconfig.py --plugin plugins/psgi core" afterwards?
    • ./uwsgi: unrecognized option '--wsgi-file'
    • touch buildconf/python.ini
    • python uwsgiconfig.py --build python
      • core/plugins.c:153:35: error: ‘UWSGI_PLUGIN_DIR’ undeclared (first use in this function)
      • plugin_filename = uwsgi_concat3(UWSGI_PLUGIN_DIR, "/", plugin_name);
    • # Rebuilt from scratch and problem went away
  • apt-get install libperl-dev
  • python uwsgiconfig.py --build psgi core
  • python uwsgiconfig.py --plugin plugins/psgi
  • python uwsgiconfig.py --build http
  • python uwsgiconfig.py --plugin plugins/http
  • ./uwsgi --plugins psgi -s :3031 -M -p 4 --psgi /path/to/hello.pl -m # for perl. Fails with...
    • "no python application found"
    • tail -f /var/log/nginx/error.log
    • ./uwsgi --plugins psgi --http-socket 127.0.0.1:3031 --http-socket-modifier1 5 --psgi /path/to/hello.pl
      • Fails with 502 bad gateway after timeout 
      • cat buildconf/http.ini
        • [uwsgi]
        • plugin_dir = .
        • # Rebuild
        • python uwsgiconfig.py --build http
          • ...
          • AttributeError: 'NoneType' object has no attribute 'find'
        • # Try again
          • ./uwsgi --plugins http,psgi --http-socket 127.0.0.1:3031 --http-socket-modifier1 5 --psgi /srv/web1/hello.pl
Webserver Nginx
  • https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html
  • /etc/nginx/sites-available/default
  • location / {
    • uwsgi_pass 127.0.0.1:3031;
    • include uwsgi_params;
  • }
  • nginx -s reload
  • # App should now be available on port 80, via Nginx
  • # Python - works well
  • # Perl - couldn't get it to work
  • # Ruby - to try
Webserver Lighttpd
  • /etc/lighttpd/lighttpd.conf
  • CGI
    • server.modules += ( "mod_cgi" )
    • $HTTP["url"] =~ "/cgi-bin/" {
      • cgi.assign = ( ".pl" => "/usr/bin/perl" )
    • }
    • # Put CGI script in server.document-root + /cgi-bin/
    • # Works
  • PSGI
    • server.modules += ( "mod_scgi" )
    • scgi.protocol = "uwsgi"
    • scgi.server = (
      • "/" => (( "host" => "127.0.0.1", "port" => 3031, "check-local" => "disable" )),
    • )
    • # Doesn't work.
    • Python only?
FastCGI
  • # Try with nginx or lighttpd
  • https://nginxlibrary.com/perl-fastcgi/
Webserver Apache 2
  • # This might be a better choice for Perl