Folio The Lexarii blog
How to run a free, self-hosted ebook library and reader
Start in a minute.
If you would rather your library lived on your own hardware, Lexarii's community edition is free software under the GNU AGPL: the same library, reader and research assistant as lexarii.com, on your own server, with your own model, or none.
What you need
- A machine that runs Docker, from a spare computer at home to a small cloud server. Lexarii is one Go binary and Postgres with pgvector; ARM and x86 both work.
- Your books, in a folder Lexarii only ever reads, or uploaded through the browser.
- A model, if you want the assistant: any OpenAI-compatible endpoint, such as llama.cpp, Ollama, vLLM or LM Studio. Without one, the library and the reader work completely; only the questions and the automatic descriptions wait.
- A little time for updates and backups. They are yours to look after.
Start it
Get the source, then:
cp .env.example .env # set LEXARII_LIBRARY_DIR
# and POSTGRES_PASSWORD
docker compose --profile full up -d
Open http://localhost:8080 and create the first account, which becomes the administrator.
Bring your books in
Two ways, and you can use both:
- Point it at a folder. The folder in
LEXARII_LIBRARY_DIRis scanned and never written to, so it can be mounted read-only. Best for a collection you already keep on disk, synced by rsync or Syncthing. - Upload through the browser. Uploads are kept apart from your folder, and a file Lexarii already has is recognised, so an interrupted batch can simply be uploaded again.
EPUB and PDF are read, searched and used to answer questions. MOBI, AZW3, CBZ and CBR are catalogued and shelved. Scanned PDFs with no text layer are shelved and readable as page images, but not searched, since Lexarii does not do OCR.
Read on your e-reader
Your library is an OPDS catalogue. Point KOReader, Librera, Thorium, Foliate or most other reading apps at http://your-server:8080/opds and sign in with your username and password.
Add a model, if you want one
The assistant answers questions from your books with citations to the passage, and can describe books whose metadata is thin. It works with any OpenAI-compatible endpoint: run a small model locally with llama.cpp or Ollama, or point it at a hosted API you choose. The model is optional by design: with it switched off, the library and the reader lose nothing.
Let other people in
The first account is the administrator. Others can have local accounts, or sign in through what you already run: OpenID Connect, LDAP or Active Directory, or a trusted reverse proxy such as oauth2-proxy or Authelia. Local passwords keep working alongside, so a misconfigured provider cannot lock you out. For a household where each person brings their own books, let everyone upload with LEXARII_UPLOAD_POLICY=users.
Look after it
Back up the Postgres database and the directory uploads go to; your own book folder you back up as you always have. Updates are a new image and a restart. The README covers every setting.
Or let us keep it
If you would rather not be a library's system administrator, lexarii.com runs the same software for you, model included. Self-host it, or let us keep it weighs the two honestly.