Install / URL Problems
  • I just followed the INSTALL, but the part about setting it up as a daemon needs some serious work. I've been trying to get this to work for hours now. I found a Django init script and it starts Booktype now, and I am using FastCGI with Nginx to serve it.

    The problem I am having is that all the requested resources (CSS, JS, etc) are all trying to connect to http://site_static. For example, the first CSS file is trying to connect to this URL: http://site_static/css/booki.css. I realized that I forgot to set BOOKI_URL in, so I updated it with the full URL, then I restarted the FastCGI process, cleared the redis cache and even did a syncdb, yet it is still not using the updated BOOKI_URL setting. 

    Is there anyway to fix this?
  • 5 Comments sorted by
  • Hi Ross,

    at the moment i am doing nginx + gunicorn instructions and code for createbooki script, so you get nginx config also for that. You should just set BOOKI_URL really, configure nginx where to fetch the static files and restart fastcgi process. Can you please post your nginx configuration so i could test it on our test server?  You can change some things you don't want to be public or you can send me to

  • I don't think it has anything to do with Nginx. This is part of the <head> that Booktype returns when you visit it:

    <link type="text/css" href="//site_static/css/booki.css" rel="Stylesheet" >
    <link rel="SHORTCUT ICON" href="//site_static/images/favicon.ico" type="image/x-icon">
    <link type="text/css" href="//site_static/js/jquery/themes/base/jquery.ui.all.css" rel="Stylesheet" >
    <link type="text/css" href="//site_static/js/jquery/themes/smoothness/jquery.ui.all.css" rel="Stylesheet" >
    <script type="text/javascript" src="//site_static/js/jquery/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="//site_static/js/jquery/ui/jquery-ui-1.8.10.custom.js"></script>
    <script type="text/javascript" src="//site_static/js/jquery.json-1.3.js"></script>
    <script type="text/javascript" src="//site_static/js/booki.js"></script>
    <script src="//site_static/js/messaging.js" type="text/javascript"></script>   
    <script type="text/javascript" src="//site_static/js/general.js"></script>
    <link href="//site_static/css/jquery.bubblepopup.v2.3.1.css" rel="stylesheet" type="text/css" />
    <link type="text/css" href="//site_static/css/jquery-ui_overrides.css" rel="Stylesheet" >
    <script src="//site_static/js/jquery.bubblepopup.v2.3.1.min.js" type="text/javascript"></script>

    As you can see, Booktype is specifically setting the path to "//site_static". Running with "runserver" works fine. It's only when run through FastCGI.

    Just for reference, this is my nginx config (I'm using Ubuntu 11.10 and modified the default site):

    server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to index.html
    # try_files $uri $uri/ /index.html;
    include fastcgi_params;

    location /site_static {
    root /var/booktype-setup/lib/booki/site_static;
    autoindex off;

    location /doc {
    root /usr/share;
    autoindex on;
    deny all;

    location /images {
    root /usr/share;
    autoindex off;
  • I was able to reproduce this issue by wiping out the Booktype installation and cloning the git repo again. I am also using this init.d script to start Booktype:

    By the way, the repo is laid out in a very strange way. I have to use a bunch of symlinks to get this to run at all. I had to symlink everything from the repo's Booktype/lib/* folder into the root of my installation folder (/var/booktype). I also had to copy Booktype/lib/booki/ to /var/booktype in order to even use the init.d script mentioned above.

    Since there is no documentation on what the resulting directory structure is supposed to look like, I can only assume that laying out the repo in this way was a design mistake. Once you run ./createbooki, you now have two install folders: the one cloned from the repo and the one created by createbooki. This directory structure is very confusing and lead to a lot of issues just getting this far, since they both depend on each other.

    So as of now, this is my directory structure:

    /var/booktype (created by createbooki)
    /var/booktype/Booktype (cloned from repo)
    /var/booktype/booki -> /var/booktype/Booktype/lib/booki (symlink)
    /var/booktype/redis -> /var/booktype/Booktype/lib/redis (symlink)
    /var/booktype/sputnik -> /var/booktype/Booktype/lib/sputnik (symlink)
    /var/booktype/ (copied from /var/booktype/Booktype/lib/booki/

    Along with the nginx config file from my previous comment, you should have all the information you need to reproduce this problem. I'm tempted to remove {{ request.META.SCRIPT_NAME }} from the base.html template so that I can actually use Booktype, but I'm waiting for a response before I do that. Thanks.
  • Just a quick follow-up, I backed up the base.html file, then removed all instances of {{ request.META.SCRIPT_NAME }} and everything worked perfectly. So I don't know what that variable is, but FastCGI does not like it.
  • Hi Ross,

    so i tried to run it on ngix as fastcgi and works fine for me. There are couple of things. First of all, you don't need to copy anything. Your Booktype source and Booktype project don't need to be at the same place or in the same directory structure. After you have created Booktype project with createbooki you will get file booki.env in project directory. You MUST load that file before running fastcgi process. Your Django settings and PATH is defined there. You MUST use django-admin command and not manage because we have customized settings file, as things are set you can have more then one install of Booktype on your system. So.... that initd script should have:

    somewhere at start load variables:
         source /var/booktype/booki.env
    this line:
    $SITES_PATH/$SITE/ runfcgi 
    method=$FCGI_METHOD \   
    should be:
   runfcgi method=$FCGI_METHOD

    Also... this was my nginx configuration:

    server {
       # this depends where is your django installed and you need it for django admin web
       location /media/ {
            alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/;

        location /static/ {
            alias /var/booktype/static/;

        location /site_static/ {
            alias /var/booktype/Booktype/booki/site_static/;

     location / {
          # host and port to fastcgi server
          fastcgi_param PATH_INFO $fastcgi_script_name;
          fastcgi_param REQUEST_METHOD $request_method;
          fastcgi_param QUERY_STRING $query_string;
          fastcgi_param CONTENT_TYPE $content_type;
          fastcgi_param CONTENT_LENGTH $content_length;
          fastcgi_pass_header Authorization;
          fastcgi_intercept_errors off;