Zine

open source content publishing system


Zine on Nginx

The following example shows how to set up Zine for Nginx via FastCGI.

Note, that you have to

$ ./configure --prefix=/usr && make install

first.

  1. Create a new folder /var/zine/yourblog where yourblog is a name that make sense for you.
  2. Copy the zine.fcgi file from /usr/share/zine/servers into /usr/bin/ and open it with an editor.
  3. Modify the INSTANCE_FOLDER variable to point to the yourblog folder.
  4. Change the line srv = WSGIServer(app) to
    srv = WSGIServer(app, bindAddress=('127.0.0.1', 8091))
    
    to use TCP socket on 8091 port, or
    srv = WSGIServer(app, bindAddress=('/tmp/fcgi_wsgi.socket'))
    
    to use UNIX socket at /tmp/fcgi_wsgi.socket.
  5. Add the ability to run zine.fcgi via
    $ sudo chmod +x /usr/bin/zine.fcgi
    
  6. Add the following lines to your nginx server cofiguration:
    location /yourblog/ {
            include fastcgi_params;
            if ($uri ~ ^/yourblog(.*)?) {
                    set $path_url $1;
            }
            fastcgi_param PATH_INFO $path_url;
            fastcgi_param SCRIPT_NAME /yourblog;
            fastcgi_pass    127.0.0.1:8091;
            #fastcgi_pass unix:/tmp/fcgi_wsgi.socket;
    }
    
  7. Since Nginx doesn't load FastCGI apps, you have to do it by yourself like
    $ sudo -u www-data /usr/bin/zine.fcgi &
    
    Or, you can create an init.d script like the attached one.
  8. Note that it's usually not a good idea to run Zine as root.
  9. Note that if you use Unix socket, Nginx should have read and write access to it: Run Zine as the same user Nginx is run (usually it's www-data) or setup rights access to this socket (See WSGIServer documentation).
  10. Note that the user Zine is run should have read/write access to INSTANCE_FOLDER.
  11. Reload Nginx and go to the URL of your blog and follow the installation instructions.

FAQ

  1. Why should I write so complicated nginx config?
  1. The problem with Nginx is that it doesn't pass PATH_INFO to FastCGI, so we should setup it manually.


  1. I want to have my blog at site root. How to do it?
  1. You can use the following config then:
    location / {
            include fastcgi_params;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param SCRIPT_NAME "";
            fastcgi_pass    127.0.0.1:8091;
            #fastcgi_pass unix:/tmp/fcgi_wsgi.socket;
    }
    

Attachments