How to install Calibre Server on Ubuntu 16.04
I love using calibre to manage my ebook collection. I have installed calibre desktop app on all my devices with windows or mac and store the library on a network share.
\\MEDIASRV\data\calibre_library
In order to easily share the library with someone else or access it over web I use calibre server. On official site it is mentioned that package provided by distributions are outdated so I check on ubuntuupdates site for other versions of “calibre” in Xenial:
Repository
Area
Version
PPA: Kubuntu-ppa Backports
2.55.0+dfsg-1build1~~xenialoverlay1~1
PPA: GetDeb Apps
As stated here, “GetDeb is an unofficial project with the mission to provide the latest open source and freeware applications for the current Ubuntu Linux release, in an easy to install manner.”
To setup the GetDeb Apps repositories:
wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu xenial-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'sudo apt-get update
To install calibre run:
sudo apt-get update
sudo apt-get install calibre
To check for installed version
romeo@mediasrv:~$ sudo apt-show-versions calibre
calibre:all/xenial-getdeb 2.79.1-1~getdeb1 uptodate
I use a systemd service to automaticaly start calibre server:
sudo nano /lib/systemd/system/calibre.service
[Unit]
Description=Calibre Service
After=network.target
[Service]
User=calibre
Group=calibre
Type=forking
PIDFile=/var/run/calibre-server.pid
ExecStart=/usr/bin/calibre-server \
--daemonize \
--max-cover=600x800 \
--max-opds-items=30 \
--max-opds-ungrouped-items=100 \
--username=calibre \
--url-prefix /calibre \
--port=8080 \
--pidfile=/var/run/calibre-server.pid \
--with-library=/media/data/calibre_library/
[Install]
WantedBy=multi-user.target
To start Calibre Server run:
systemctl start calibre.service
To check if Calibre Server start up correctly:
systemctl status calibre.service
To enable the service to run on every start up:
systemctl enable calibre.service
To be able to access it outside of my home network I will configure appache to proxy calibre directory to the internal site http://127.0.0.1:8080/calibre/:
sudo nano /etc/apache2/conf-available/calibre.conf
Insert the text:
<IfModule mod_proxy.c>
<IfModule mod_ssl.c>
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyPass /calibre/ http://127.0.0.1:8080/calibre/
<Location /calibre/>
Order deny,allow
Allow from all
ProxyPassReverse http://127.0.0.1:8080/calibre/
SSLRequireSSL
</Location>
</IfModule>
</IfModule>
To enable new apache directory configuration:
sudo a2enconf calibre
sudo service apache2 reload
The result:
To easily secure public site I opt for one of the choices:
- add
--password='calibre'
switch when starting the calibre server by editing the/lib/systemd/system/calibre.service
file. - use basic authentication in apache
Use htpasswd comand to manage users to authenticate:
sudo apt-get update
sudo apt-get install apache2-utils
Use htpasswd
command to generate / edit the file which stores usenames and passwords:
sudo htpasswd -c /etc/apache2/.htpasswd romeo
Edit the apache config:
sudo nano /etc/apache2/conf-available/calibre.conf
Locate for <Location /calibre>
and append the folowing config:
<Location /calibre/>
...
AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/etc/apache2/.htpasswd"
Require valid-user
...
</Location>