Attic

This section contains some older texts that need revision.

Lino directory structure

TODO: review

At the end of this document you will have the following recommenced directory structure on your Lino production server:

/usr/local/lino/
│
├── shared/
│   ├── settings.py   # shared Django settings
│   ├── master/ # a shared virtualenv named "master"
│   │   ├── repositories/ # git repositories used by master
│   │   │   ├─── lino
│   │   │   ├─── xl
│   │   │   ├─── noi
│   │   │   └─── ...
│   └── ...
└── lino_local/
    ├── __init__.py
    ├── prj1 # project directory of site "prj1"
    │   ├── __init__.py
    │   ├── settings.py  # Site specific settings
    │   ├── env/ # either a link to some shared virtualenv, or a subdir with a site-specific virtualenv
    │   ├── log/ -> /var/log/lino/prj1/
    │   ├── manage.py
    │   ├── media/
    │   ├── static/
    │   ├── wsgi.py
    │   └── ...
    └── prj2
        ├─── ...
        └─── ...

This structure is recommended even if you have only one Lino site on your server because you never know whether the site operator some day change their mind and ask e.g. for a preview site as well.

It is possible to use symbolic links for the env and repositories in order to have several sites working on the same virtual environment.

Project directories

The following is done automatically by getlino.

Every new project directory must have at least four files:

  • an empty __init__.py file so that Python processes can import your settings:

    $ touch /usr/local/src/lino/prod_sites/prj1/__init__.py
    
  • a file settings.py Note: Replace the 'prj1' in this file with the name of the project:

    # -*- coding: UTF-8 -*-
    from lino.projects.std.settings import *
    
    import logging
    logging.getLogger('weasyprint').setLevel("ERROR") # see #1462
    
    
    class Site(Site):
        title = "Lino@prj1"
        # server_url = "https://prj1.mydomain.com"
        
    SITE = Site(globals())
    
    # locally override attributes of individual plugins
    # SITE.plugins.finan.suggest_future_vouchers = True
    
    # MySQL
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'mysite', #database name
            'USER': 'django',
            'PASSWORD': 'my cool password',
            'HOST': 'localhost',                  
            'PORT': 3306,
            'OPTIONS': {
               "init_command": "SET storage_engine=MyISAM",
            }
        }
    }
    
  • a file manage.py:

    #!/usr/bin/env python
    if __name__ == "__main__":
        import sys ; sys.path.append('/usr/local/src/lino')
        from lino_local import manage ; manage(__file__, 'settings')
    
  • a file wsgi.py. Note: Replace the 'prj1' in this file with the name of the project:

    import sys ; sys.path.append('/usr/local/src/lino')
    from lino_local import wsgi ; wsgi(globals(), 'lino_sites.prj1.settings')
    

We recommend the convention of having in each project a symbolic link named env which points to the virtualenv.

Initialize the database

::

$ go prj1 $ python manage.py prep

Collecting static files

Create two empty directories media and config:

$ mkdir media
$ mkdir config

One part of your cache directory are the static files. When your LINO_CACHE_ROOT is set, you should run Django's collectstatic command:

$ cd /usr/local/src/lino/prod_sites/prj1/
$ python manage.py collectstatic

The output should be something like this:

You have requested to collect static files at the destination
location as specified in your settings:

    /usr/local/src/lino/prod_sites/prj1/static/

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes

4688 static files copied to '/usr/local/src/lino/prod_sites/prj1/static/', 0 unmodified.

Which database backend to use

Our example assumes you are using Django's MySQL backend. For other backends, adapt your DATABASES accordingly.

The database backend of your choice is not automatically installed. If you plan to use Django's MySQL backend, see MySQL cheat sheet.

Follow the Django documentation at Get your database running

How to install mysql on your site:

$ sudo apt install mysql-server
$ sudo apt install libmysqlclient-dev
$ sudo apt install python-dev
$ sudo apt install libffi-dev libssl-dev
$ sudo apt install mysql-server

$ sudo mysql_secure_installation