Last modified 3 years ago
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.
- Create a new folder /var/zine/yourblog where yourblog is a name that make sense for you.
- Copy the zine.fcgi file from /usr/share/zine/servers into /usr/bin/ and open it with an editor.
- Modify the INSTANCE_FOLDER variable to point to the yourblog folder.
- Change the line srv = WSGIServer(app) to
srv = WSGIServer(app, bindAddress=('127.0.0.1', 8091))to use TCP socket on 8091 port, orsrv = WSGIServer(app, bindAddress=('/tmp/fcgi_wsgi.socket'))to use UNIX socket at /tmp/fcgi_wsgi.socket. - Add the ability to run zine.fcgi via
$ sudo chmod +x /usr/bin/zine.fcgi
- 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; } - 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. - Note that it's usually not a good idea to run Zine as root.
- 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).
- Note that the user Zine is run should have read/write access to INSTANCE_FOLDER.
- Reload Nginx and go to the URL of your blog and follow the installation instructions.
FAQ
- Why should I write so complicated nginx config?
- The problem with Nginx is that it doesn't pass PATH_INFO to FastCGI, so we should setup it manually.
- I want to have my blog at site root. How to do it?
- 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; }
