Installing Booktype on Ubuntu 12.04
  • Vote Up0Vote Down Micz FlorMicz Flor
    Posts: 184Administrator
    Hi everybody,

    I installed Booktype on 10.04 last week. Now I am going through my notes and try to install it on 12.04. But once I have done all the steps below, the server just tells me the usual: "It works!". What have I done wrong?

    ----------------------------------------------------------

    INSTALL BOOKTYPE
    ----------------

    sudo apt-get install git-core

    sudo apt-get install python-pip libxml2-dev libxslt-dev libapache2-mod-wsgi python-lxml redis-server

    mkdir Booktype_Source
    cd Booktype_Source/
    git clone https://github.com/sourcefabric/Booktype.git

    sudo pip install Django==1.3
    sudo pip install South==0.7.5
    sudo pip install unidecode lxml
    cd Booktype/
    ./scripts/createbooki --database sqlite /home/sourcefabric/Booktype_Source/booktypeserver
    cd ../booktypeserver/
    nano booki.wsgi
    # make sure this line is in the file or you need to add it (anywhere BEFORE application=...)
    sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/')
    # important: no space at the beginning of the line

    sudo cp wsgi.apache /etc/apache2/sites-available/
    cd /etc/apache2/sites-available/
    sudo nano wsgi.apache
         ServerName booktype.local 
         SetEnv HTTP_HOST "booktype.local"
    sudo mv wsgi.apache booktype-vhost
    sudo a2ensite booktype-vhost
    # add newscoop.local to the hosts list
    sudo nano /etc/hosts
    # add the following line to the file
    127.0.1.1       booktype.local
    cd /home/sourcefabric/Booktype_Source/booktypeserver/
    . booki.env
    django-admin.py  syncdb --noinput
    django-admin.py  migrate
    django-admin.py loaddata documentation_licenses
    sudo chown -R sourcefabric:www-data /home/sourcefabric/Booktype_Source/booktypeserver/
    sudo chmod -R 775 /home/sourcefabric/Booktype_Source/booktypeserver/
    django-admin.py createsuperuser
      Username (Leave blank to use 'sourcefabric'):
      E-mail address: contact@sourcefabric.org
      Password:
      Password (again):
      Superuser created successfully.
    # Now start Booktype in browser: booktype.local
    # log in
    # import books, e.g.: http://booki.flossmanuals.net/booktype/


    ----------------------------------------------------------
  • 5 Comments sorted by
  • Did you get some kind of error? Do you get any kind of errors in the Apache error log?

    Ubuntu 12.04 comes with Python 2.7 and i Django 1.3.1 so that magic with sys.path.insert is not important and would not work anyways. You had to do it only because Calibre was installing not supported Django 1.1 from the repository.

  • Vote Up0Vote Down Micz FlorMicz Flor
    Posts: 184Administrator
    during the installation, there were no errors, as far as i can see.

    /var/log/apache2/booktype-error.log
    is empty

    here the tail of my installation procedure:

    sourcefabric@Sourcefabric-LiveCD:~$ sudo apt-get install python-pip
    [sudo] password for sourcefabric:
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    The following extra packages will be installed:
      python-setuptools
    The following NEW packages will be installed:
      python-pip python-setuptools
    0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
    Need to get 536 kB of archives.
    After this operation, 1,467 kB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get:1 http://cz.archive.ubuntu.com/ubuntu/ precise/main python-setuptools all 0.6.24-1ubuntu1 [441 kB]
    Get:2 http://cz.archive.ubuntu.com/ubuntu/ precise/universe python-pip all 1.0-1build1 [95.1 kB]
    Fetched 536 kB in 1s (273 kB/s) 
    Selecting previously unselected package python-setuptools.
    (Reading database ... 164048 files and directories currently installed.)
    Unpacking python-setuptools (from .../python-setuptools_0.6.24-1ubuntu1_all.deb) ...
    Selecting previously unselected package python-pip.
    Unpacking python-pip (from .../python-pip_1.0-1build1_all.deb) ...
    Processing triggers for man-db ...
    Setting up python-setuptools (0.6.24-1ubuntu1) ...
    Setting up python-pip (1.0-1build1) ...
    sourcefabric@Sourcefabric-LiveCD:~$ sudo apt-get install python-pip libxml2-dev libxstl-dev libapache2-mod-wsgi python-lxml redis-server
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    E: Unable to locate package libxstl-dev
    sourcefabric@Sourcefabric-LiveCD:~$ sudo apt-get install python-pip libxml2-dev libxslt-dev libapache2-mod-wsgi python-lxml redis-server
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
    python-lxml is already the newest version.
    python-lxml set to manually installed.
    python-pip is already the newest version.
    Suggested packages:
      apache2-mpm-worker apache2-mpm-event
    The following NEW packages will be installed:
      libapache2-mod-wsgi libxml2-dev libxslt1-dev redis-server
    0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,564 kB of archives.
    After this operation, 5,187 kB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get:1 http://cz.archive.ubuntu.com/ubuntu/ precise/main libapache2-mod-wsgi i386 3.3-4build1 [71.0 kB]
    Get:2 http://cz.archive.ubuntu.com/ubuntu/ precise-updates/main libxml2-dev i386 2.7.8.dfsg-5.1ubuntu4.1 [760 kB]
    Get:3 http://cz.archive.ubuntu.com/ubuntu/ precise/main libxslt1-dev i386 1.1.26-8ubuntu1 [528 kB]
    Get:4 http://cz.archive.ubuntu.com/ubuntu/ precise/universe redis-server i386 2:2.2.12-1build1 [205 kB]
    Fetched 1,564 kB in 3s (516 kB/s)
    Selecting previously unselected package libapache2-mod-wsgi.
    (Reading database ... 164263 files and directories currently installed.)
    Unpacking libapache2-mod-wsgi (from .../libapache2-mod-wsgi_3.3-4build1_i386.deb) ...
    Selecting previously unselected package libxml2-dev.
    Unpacking libxml2-dev (from .../libxml2-dev_2.7.8.dfsg-5.1ubuntu4.1_i386.deb) ...
    Selecting previously unselected package libxslt1-dev.
    Unpacking libxslt1-dev (from .../libxslt1-dev_1.1.26-8ubuntu1_i386.deb) ...
    Selecting previously unselected package redis-server.
    Unpacking redis-server (from .../redis-server_2%3a2.2.12-1build1_i386.deb) ...
    Processing triggers for man-db ...
    Processing triggers for doc-base ...
    Processing 1 added doc-base file...
    Registering documents with scrollkeeper...
    Processing triggers for ureadahead ...
    ureadahead will be reprofiled on next reboot
    Setting up libapache2-mod-wsgi (3.3-4build1) ...
     * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
     ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                                                                             [ OK ]
    Setting up libxml2-dev (2.7.8.dfsg-5.1ubuntu4.1) ...
    Setting up libxslt1-dev (1.1.26-8ubuntu1) ...
    Setting up redis-server (2:2.2.12-1build1) ...
    Starting redis-server: redis-server.
    sourcefabric@Sourcefabric-LiveCD:~$ mkdir Booktype_Source
    sourcefabric@Sourcefabric-LiveCD:~$ cd Booktype_Source/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ mkdir Booktype_Source
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ ls
    Booktype_Source
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ rm -rf Booktype_Source/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ git clone https://github.com/sourcefabric/Booktype.git
    Cloning into 'Booktype'...
    remote: Counting objects: 10688, done.
    remote: Compressing objects: 100% (4578/4578), done.
    remote: Total 10688 (delta 5921), reused 10601 (delta 5851)
    Receiving objects: 100% (10688/10688), 5.01 MiB | 913 KiB/s, done.
    Resolving deltas: 100% (5921/5921), done.
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ sudo pip install Django==1.3Downloading/unpacking Django==1.3
      Downloading Django-1.3.tar.gz (6.5Mb): 6.5Mb downloaded
      Running setup.py egg_info for package Django
       
    Installing collected packages: Django
      Running setup.py install for Django
        changing mode of build/scripts-2.7/django-admin.py from 644 to 755
       
        changing mode of /usr/local/bin/django-admin.py to 755
    Successfully installed Django
    Cleaning up...
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ sudo pip install South==0.7.5
    Downloading/unpacking South==0.7.5
      Downloading South-0.7.5.tar.gz (90Kb): 90Kb downloaded
      Running setup.py egg_info for package South
       
    Installing collected packages: South
      Running setup.py install for South
       
    Successfully installed South
    Cleaning up...
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ sudo pip install unidecode lxml
    Downloading/unpacking unidecode
      Downloading Unidecode-0.04.9.tar.gz (196Kb): 196Kb downloaded
      Running setup.py egg_info for package unidecode
       
    Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/lib/python2.7/dist-packages
    Installing collected packages: unidecode
      Running setup.py install for unidecode
       
    Successfully installed unidecode
    Cleaning up...
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source$ cd Booktype/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/Booktype$ ./scripts/createbooki --database sqlite /home/sourcefabric/Booktype_Source/booktypeserver
    + Creating data directory.   [OK]
    + Creating logs directory.   [OK]
    + Creating static directory.   [OK]
    + Creating templates directory.   [OK]
    + Creating lib directory.   [OK]
    + Creating locale directory.   [OK]
    + Creating data/books directory.   [OK]
    + Creating data/profile_images directory.   [OK]
    + Creating data/cover_images directory.   [OK]
    + Creating booki.env file.   [OK]
    + Creating __init__.py file.   [OK]
    + Creating settings.py file.   [OK]
    + Creating booki.wsgi file.   [OK]
    + Creating wsgi.apache file.   [OK]
    + Creating gunicorn.nginx file.   [OK]
    + Creating factcgi.nginx file.   [OK]

    Check [/home/sourcefabric/Booktype_Source/booktypeserver] directory for config files:
       booki.env      -  Environment variables
       booki.wsgi     -  WSGI file for Apache
       wsgi.apache    -  Apache config file
       gunicorn.nginx -  Nginx config file
       fastcgi.nginx  -  Nginx config file
       settings.py    -  Booki settings file

       templates/     -  Local Booki template files
       locale/        -  Local directory with translations
       static/        -  Local web files
       lib/           -  Local python libraries
       data/          -  Place for attachments

    For further instructions read INSTALL file.

    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/Booktype$ cd ../booktypeserver/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ nano booki.wsgi
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ sudo cp wsgi.apache /etc/apache2/sites-available/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ cd /etc/apache2/sites-available/
    sourcefabric@Sourcefabric-LiveCD:/etc/apache2/sites-available$ sudo nano wsgi.apache
    sourcefabric@Sourcefabric-LiveCD:/etc/apache2/sites-available$ sudo mv wsgi.apache booktype-vhost
    sourcefabric@Sourcefabric-LiveCD:/etc/apache2/sites-available$ sudo a2ensite booktype-vhost
    Enabling site booktype-vhost.
    To activate the new configuration, you need to run:
      service apache2 reload
    sourcefabric@Sourcefabric-LiveCD:/etc/apache2/sites-available$ cd /home/sourcefabric/Booktype_Source/booktypeserver/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ . booki.env
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ django-admin.py  syncdb --noinput
    Syncing...
    Creating tables ...
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_user_permissions
    Creating table auth_user_groups
    Creating table auth_user
    Creating table auth_message
    Creating table django_content_type
    Creating table django_session
    Creating table django_site
    Creating table django_admin_log
    Creating table south_migrationhistory
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.

    Synced:
     > django.contrib.auth
     > django.contrib.contenttypes
     > django.contrib.sessions
     > django.contrib.sites
     > django.contrib.admin
     > django.contrib.messages
     > south
     > booki.reader
     > booki.portal

    Not synced (use migrations):
     - booki.editor
     - booki.account
     - booki.messaging
     - booktypecontrol
    (use ./manage.py migrate to migrate these)
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ django-admin.py  migrate
    Running migrations for editor:
     - Migrating forwards to 0007_auto__add_unique_publishwizzard_book_user_wizz_type.
     > editor:0001_initial
     > editor:0002_auto__add_field_book_hidden
     > editor:0003_attributionexclude
     > editor:0004_book_permission
     > editor:0005_auto__add_field_book_cover__add_field_book_description
     > editor:0006_auto__add_publishwizzard
     > editor:0007_auto__add_unique_publishwizzard_book_user_wizz_type
     - Loading initial data for editor.
    No fixtures found.
    Running migrations for account:
     - Migrating forwards to 0001_initial.
     > account:0001_initial
     - Loading initial data for account.
    No fixtures found.
    Running migrations for messaging:
     - Migrating forwards to 0003_auto__add_endpointconfig__add_field_endpoint_config.
     > messaging:0001_initial
     > messaging:0002_auto__add_field_post_snippet__add_field_post_context_url
     > messaging:0003_auto__add_endpointconfig__add_field_endpoint_config
     - Loading initial data for messaging.
    No fixtures found.
    Running migrations for booktypecontrol:
     - Migrating forwards to 0002_static_user_css.
     > booktypecontrol:0001_initial
     > booktypecontrol:0002_static_user_css
     - Migration 'booktypecontrol:0002_static_user_css' is marked for no-dry-run.
     - Loading initial data for booktypecontrol.
    No fixtures found.
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ django-admin.py loaddata documentation_licenses
    Installed 10 object(s) from 1 fixture(s)
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ sudo chown -R sourcefabric:www-data /home/sourcefabric/Booktype_Source/booktypeserver/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ sudo chmod -R 775 /home/sourcefabric/Booktype_Source/booktypeserver/
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ django-admin.py createsuperuser
    Username (Leave blank to use 'sourcefabric'):
    E-mail address: contact@sourcefabric.org
    Password:
    Password (again):
    Superuser created successfully.
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ sudo nano /etc/hosts
    sourcefabric@Sourcefabric-LiveCD:~/Booktype_Source/booktypeserver$ sudo /etc/init.d/apache2 reload
     * Reloading web server config apache2                                          apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

  • Considering the last line "Could not reliably determine..." could you check your /etc/apache2/sites-available/booktype-vhost config file and check ServerName configuration matches whatever you have in /etc/hosts file. You could also get this warning if you have default enabled default apache option which has no ServerName but it is worth to check :)

  • Hi Aleksandar,

    I am having the same "Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName" issue.  When I try to go to the ServerName in my browser I get an HTTP 500 error.  In my case, the ServerName is set to jeremy-desktop and I am using SQLite.  This is on Ubuntu 12.04.  I tried to disable the default apache site, but that hasn't helped.  My /etc/hosts file has:

    127.0.0.1    localhost.localdomain    localhost
    ::1    jeremy-desktop    localhost6.localdomain6    localhost6
    127.0.1.1    jeremy-desktop

    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback

    So, do you know if this is an issue with my apache configuration or my booktype install?  The booktype install ran fine up until I had to sudo service apache2 restart

    EDIT:  Also, I wasn't able to use the built-in server.  Though I didn't try after I had disabled my default apache site.

    EDIT2:  Just tried running the built-in server while apache was stopped.  Got a big scary error when I ran django-admin.py runserver 0.0.0.0:8080

    (mybooktype)jeremy@jeremy-desktop:~/workspace$ cd mybooktype
    (mybooktype)jeremy@jeremy-desktop:~/workspace/mybooktype$ source bin/activate
    (mybooktype)jeremy@jeremy-desktop:~/workspace/mybooktype$ source mybook/booki.env
    (mybooktype)jeremy@jeremy-desktop:~/workspace/mybooktype$ django-admin.py runserver 0.0.0.0:8080
    Traceback (most recent call last):
      File "/home/jeremy/workspace/mybooktype/bin/django-admin.py", line 5, in <module>
        management.execute_from_command_line()
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/core/management/base.py", line 209, in execute
        translation.activate('en-us')
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 100, in activate
        return _trans.activate(language)
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 43, in __getattr__
        if settings.USE_I18N:
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
        self._wrapped = Settings(settings_module)
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/home/jeremy/workspace/mybooktype/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/home/jeremy/workspace/mybooktype/mybook/settings.py", line 208, in <module>
        init_logging()
      File "/home/jeremy/workspace/mybooktype/mybook/settings.py", line 199, in init_logging
        ch = logging.handlers.RotatingFileHandler('%s/logs/booki.log' % BOOKI_ROOT, maxBytes=100000, backupCount=5)
      File "/usr/lib/python2.7/logging/handlers.py", line 118, in __init__
        BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
      File "/usr/lib/python2.7/logging/handlers.py", line 65, in __init__
        logging.FileHandler.__init__(self, filename, mode, encoding, delay)
      File "/usr/lib/python2.7/logging/__init__.py", line 897, in __init__
        StreamHandler.__init__(self, self._open())
      File "/usr/lib/python2.7/logging/__init__.py", line 916, in _open
        stream = open(self.baseFilename, self.mode)
    IOError: [Errno 13] Permission denied: '/home/jeremy/workspace/mybooktype/mybook/logs/booki.log'

    Post edited by Jeremy VanGelder at 2013-04-20 00:11:25
  • I encountered the exact same error...

    IOError: [Errno 13]Permission denied: 'mybooktype/mybook/logs/booki.log'

    ...on a virgin Centos 6.5 install, in spite of setting permissions to apache (chown -R apache:apache mybooktype).

    After confirming that the booki.log file existed and that I could access and write to it as apache user (via su apache -s /bin/bash), I figured out that the problem is with SElinux.

    The quick fix was to edit /etc/selinux/config and set SELINUX=permissive (instead of SELINUX=targeted), which is OK for testing but may not be OK for production. After rebooting the system to let the SElinux changes take effect, the booki.log permission error no longer appeared.
    Post edited by Ruedi Aschwanden at 2014-03-30 19:49:09