Set up a Calibre eBook Server on Debian 10
Calibre is a popular free, open-source eBook management software. Calibre offers a local client but also provides a server for access on other devices. This tutorial explains how to create a Calibre eBook server on a Vultr Debian 10 cloud server instance. A cloud server instance is sometimes called a Virtual Private Server or VPS.
Prerequisites
- Deploy a new Vultr Debian 10 cloud server instance.
- Follow the best practices guide for Debian to update the server.
- Create a sudo user named calibre. Use the calibre user for the rest of the steps in this tutorial.
1. Install Calibre
Install Calibre with the following command:
$ sudo apt install calibre
2. Create a Library
Make a folder for the new Calibre library in the home directory.
$ cd ~
$ mkdir calibre
3. Add Books to the Library
Download Shakespeare's Romeo and Juliet from Project Gutenberg.
$ wget "http://gutenberg.org/ebooks/1112.kindle.noimages" -O book.mobi
Add it to the Calibre library.
$ calibredb add book.mobi --with-library calibre
4. List the Library's Contents
Get a list of all the books in the library.
$ calibredb list --with-library calibre
id title authors
1 The Tragedy of Romeo and Juliet William Shakespeare
5. Remove Books from the Library
calibredb
requires the ID number to remove a book. For example, to remove book ID 1:
$ calibredb remove 1 --with-library calibre
To add the book again:
$ calibredb add book.mobi --with-library calibre
6. Run the Calibre Server
Start the server. Your IP address is different than the example shown.
$ calibre-server calibre calibre server listening on 0.0.0.0:8080 OPDS feeds advertised via BonJour at: 192.0.2.123 port: 8080
In your web browser, navigate to the server at the IP address and port reported by calibre-server. For example:
http://192.0.2.123:8080
Select "calibre" as the library, and the server displays a list of books.
From the terminal, press Ctrl-C to exit the server.
7. Create the Calibre Startup Service
Create a systemd service for Calibre, so that it can automatically start.
Use nano to create a new service file.
$ sudo nano /etc/systemd/system/calibre-server.service
Add the following contents to the calibre-server.service.
[Unit] Description=Calibre Server After=network.target [Service] Type=simple User=calibre Group=calibre ExecStart=/usr/bin/calibre-server --enable-local-write /home/calibre/calibre [Install] WantedBy=multi-user.target
Start the service and enable it to run when the server boots.
$ sudo systemctl enable calibre-server $ sudo systemctl start calibre-server
8. Add Authentication
Add authentication to prevent unauthorized access to the eBook library.
Stop the server.
$ sudo systemctl stop calibre-server
Run the user management script:
$ calibre-server --manage-users
Follow the prompts to make a new user named calibreuser and choose a secure password. Verify you see the confirmation message:
User calibreuser added successfully!
Edit the Calibre service file to enable authentication.
$ sudo nano /etc/systemd/system/calibre-server.service
Replace this line:
ExecStart=/usr/bin/calibre-server --enable-local-write /home/calibre/calibre
With:
ExecStart=/usr/bin/calibre-server --enable-auth --enable-local-write /home/calibre/calibre
Reload the service files with systemd and restart the service.
$ sudo systemctl daemon-reload $ sudo systemctl start calibre-server
Authentication is now required to access the server.
Conclusion
This completes the Calibre eBook server installation on a Vultr Debian 10 cloud server instance. Use the Calibre companion apps for Android or iOS to access the server.