Recently, I have been organizing my collection of e-books to make them accessible online. Although the Calibre desktop application is powerful and can enable local HTTP services, the HTTP interface is rather simplistic.
I discovered an open-source project called Calibre Web, which has a very nice interface, supports multi-user management, and can be deployed directly on a Raspberry Pi home server without a desktop environment!
Calibre Web GitHub repository: https://github.com/janeczku/calibre-web
This article serves as a deployment guide for Calibre Web on the Raspberry Pi, ultimately mapping the HTTP service to the public network, allowing us to read and share our e-book library anytime, anywhere via computer or mobile phone!
Create a Folder for Calibre Configuration and Data
cd /opt/
mkdir /opt/calibre-web
Create Configuration Folder and Books Folder
mkdir /opt/calibre-web/config
mkdir /opt/calibre-web/books
sudo chmod 777 -R /opt/calibre-web/
Create Docker Compose File
touch /opt/calibre-web/docker-compose.yml
Write the following content into the docker-compose.yml file
version: "2.1"
services:
calibre-web:
image: lscr.io/linuxserver/calibre-web:latest
container_name: calibre-web
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- DOCKER_MODS=linuxserver/mods:universal-calibre #optional
- OAUTHLIB_RELAX_TOKEN_SCOPE=1 #optional
volumes:
- /opt/calibre-web/config:/config
- /opt/calibre-web/books:/books
ports:
- 8083:8083
restart: unless-stopped
If you do not need to modify the above configurations, you can write the configurations directly with the following command:
sudo bash -c 'cat > /opt/calibre-web/docker-compose.yml' <<-'EOF'
version: "2.1"
services:
calibre-web:
image: lscr.io/linuxserver/calibre-web:latest
container_name: calibre-web
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- DOCKER_MODS=linuxserver/mods:universal-calibre #optional
- OAUTHLIB_RELAX_TOKEN_SCOPE=1 #optional
volumes:
- /opt/calibre-web/config:/config
- /opt/calibre-web/books:/books
ports:
- 8083:8083
restart: unless-stopped
EOF
Start Calibre Web
Run /opt/calibre-web/
directory with sudo docker-compose up -d
cd /opt/calibre-web/
sudo docker-compose up -d
Access the Calibre Web interface by visiting http://Raspberry_Pi_Local_IP:8083
Log in with the default username admin and password admin123, then click Login
Login successful
Go to /opt/calibre-web/config
to download metadata.db
cd /opt/calibre-web/config
wget https://raw.githubusercontent.com/janeczku/calibre-web/master/library/metadata.db
Select the recently downloaded metadata.db
/config/metadata.db
Modify the login username and password, then save
Modification successful
How to Manage Books
Calibre Web currently does not provide a function to manage books. We need to install the Calibre desktop client to manage the Calibre Web database.
Calibre download: https://calibre-ebook.com/zh_HK/download
The /opt/calibre-web/config/metadata.db
file exists on the Raspberry Pi. The locally installed Calibre client cannot directly read and write the /opt/calibre-web/config/metadata.db
. We can enable the SMB service on the Raspberry Pi (refer to the previous tutorial “Raspberry Pi 4B Home Server Setup Guide” Part 2: The Future Technology of Cloud Storage, add SMB service and complete internal network penetration, achieving file sharing across all devices https://www.v2fy.com/p/2021-10-03-pi-smb-1633231650000/) to mount the Raspberry Pi /opt/
folder locally, thereby allowing the local Calibre client to read and write the /opt/calibre-web/config/metadata.db
file.
After mounting via SMB, we can access the Raspberry Pi’s files as if accessing a local disk.
Install Calibre
Select language
Next step
Completion
Manage Using Calibre Client
-
Switch book library
Drag and drop to upload to the Raspberry Pi
Upload successful
-
Open Calibre Web, and you can see the recently uploaded books in the web browser
-
Click on the book to read online
-
Supports PC and mobile, the experience is quite good
-
You can adjust the font and background color through settings, and you can also jump chapters directly through the directory
-
If you want to use it publicly, just add the port opening rule for 8083 in the Raspberry Pi’s frpc.ini
[books-frp-v2fy-com-8083]
type = tcp
local_ip = 127.0.0.1
local_port = 8083
remote_port = 8083
After setting, remember to restart the frpc on the Raspberry Pi and open the 8083 port on the cloud server.
For specific settings of frp’s internal network penetration, you can refer to episodes 001 and 004 of Raspberry Pi that won’t gather dust, the frp setting methods are the same, and I won’t elaborate here.
001 “Raspberry Pi 4B Home Server Setup Guide” Episode 1: Flash Ubuntu Server 20.04, bind public domain name, provide HTTP services to the public network, SSH login service https://www.v2fy.com/p/2021-10-01-pi-server-1633066843000/
004 “Raspberry Pi 4B Home Server Setup Guide” Episode 4: Build a public personal download platform aria2-pro with Raspberry Pi, recommend 6 high-quality torrent resource sites.
Successfully Access Calibre Web Publicly
-
Public access via PC browser
-
Public access via mobile browser
Add More Books for an E-Book Poster Wall Feel
Some Practical Experiences
Calibre Web currently has not implemented cross-device progress synchronization. When logging in with the same account, the reading progress on mobile and PC cannot be synchronized; it only records the last reading position on the same device. The bookmarks in Calibre Web support cross-device progress synchronization. When we stop reading on device A, we can add a bookmark, and on device B, we can open the bookmark to jump to the corresponding position.
If Calibre Web reports a 500 error (the database is easily deadlocked when operated by several Calibre clients simultaneously), restarting the Calibre Web Docker service usually resolves the issue.
This article uses the macOS version of Calibre as an example, but the Windows version of Calibre is actually more user-friendly. The Traditional Chinese version of the Calibre client has some strange translations, so I recommend using the English version of Calibre, which makes all operational commands clear.
Conclusion
Calibre is an old but powerful e-book management tool, and the open-source project Calibre Web utilizes Calibre’s database to convert e-books into a web service accessible over the public network, which is indeed a great idea for an internet product.
This article is the sixteenth in the “Raspberry Pi Won’t Gather Dust” series. The GitHub update address for “Raspberry Pi Won’t Gather Dust” is https://github.com/zhaoolee/pi. It provides resources for those who love tinkering with Raspberry Pi, opening up ideas, and educating while entertaining, allowing Raspberry Pi to benefit humanity.
Leave a Comment
Your email address will not be published. Required fields are marked *