Raspberry Pi eBook Server Header Image

In this project, we will be showing you how to setup your very own Raspberry Pi eBook server by utilizing the COPS (Calibre OPDS (and html) PHP Server) PHP software.

This software acts as a web interface on your Raspberry Pi where you can access all your eBooks either through its web interface, or by downloading them directly from your Raspberry Pi to your devices.

Ultimate Books of Pi

This works as a fantastic middle man for your eBook’s especially if you often share your eBooks among a wide number of devices. It’s also a nice interface to sort your eBooks by author and other things.

You will find that this is a pretty handy tutorial if you wanted to the host a Raspberry Pi project book on a server so you can access it anywhere in your house.

Equipment List

Below are all the bits and pieces that I used for this Raspberry Pi eBook Server tutorial.


Raspberry Pi 2 or 3

Micro SD Card

Ethernet Network Connection or Wifi dongle (The Pi 3 has WiFi inbuilt)


Raspberry Pi Case

Setting up your eBook Server with COPS

Before you begin this tutorial please make sure that you have followed our “Setting up NGINX” guide and installed PHP. We will be using that as a base for our Raspberry Pi eBook server, due to its speed and memory efficiency.

1. Before we begin let’s bring all our packages on Raspbian up to date by running the following command in the terminal.

sudo apt-get update
sudo apt-get upgrade

2. With our Raspberry Pi now up to date we can now install the extra PHP packages that we need to run the COPS PHP software. We will be assuming you have already installed PHP before you follow this guide. Run the following command on your Raspberry Pi to install the extra packages.

Raspbian Stretch and Later

sudo apt-get install php7.0-gd php7.0-sqlite3 php7.0-json php7.0-intl php7.0-xml php7.0-mbstring php7.0-zip

Raspbian Jessie and Earlier

sudo apt-get install php5-gd php5-sqlite3 php5-json php5-intl php5-xml php5-mbstring php5-zip

3. With our new PHP packages installed we will first have to restart NGINX for it to load in the new modules. Simply type the following command into terminal on your Raspberry Pi to restart NGINX.

sudo /etc/init.d/nginx reload

4. With the PHP modules, we need now installed and NGINX restarted we can move onto setting up COPS (Calibre OPDS (and html) PHP Server). COPS is the PHP software that we will be using as our library maintainer, this basically serves your eBooks to any device that connects to it.

Let’s clone the software from its Github page to our Raspberry Pi by running the following commands. The first command makes a folder in your www folder to store the eBook library. Make sure you type in the . after the git clone command as this makes it clone to the current directory and not create a new one. If you would like to know more about COPS you can visit their website by going to the COPS github page.

sudo mkdir -p /var/www/html/ebooks
cd /var/www/html/ebooks
sudo git clone https://github.com/seblucas/cops.git .

5. Now that we have cloned the COPS software into our eBooks directory we will need to make use of composer to grab all its dependencies and set up the software for use.

To do this we will be running the following commands on our Raspberry Pi.

sudo wget https://getcomposer.org/composer.phar
sudo php composer.phar global require "fxp/composer-asset-plugin:~1.1"
sudo php composer.phar install --no-dev --optimize-autoloader

6. Now before we go configuring our Raspberry Pi eBook Server we must first create one more folder. This folder is where you will keep your eBook library itself and its where COPS will read the files from once we configure it.

Let’s create the folder by running the following command on our Raspberry Pi:

mkdir -p /home/pi/storage/eBooks

7. With our folder now created let’s work on setting up the configuration file of COPS. We will do this by copying the example file and immediately start to edit it by running a command for nano.

Type the following two commands in terminal to begin editing the file

sudo cp config_local.php.example config_local.php
sudo nano config_local.php

8. Within this file make the following changes.


$config['calibre_directory'] = './';

Replace With

$config['calibre_directory'] = '/home/pi/storage/eBooks/';


$config['cops_title_default'] = "COPS";

Replace With

$config['cops_title_default'] = "My Raspberry Pi eBook Server";

Once you have made the changes, save the file by pressing Ctrl + X then Y and lastly press Enter.

Copying your library from Calibre to COPS

1. In this segment of the tutorial we will be explaining what you must do to be able to get your Calibre library to show up through COPS. While in this tutorial we will be utilizing SFTP through mobaxterm you can use multiple other methods of getting your eBooks to your Raspberry Pi. Such as using FTP, or a SAMBA share.

Begin by opening Calibre on your computer, once it has opened up right click on any book (1.) and clickOpen containing folder" (2.).

Raspberry Pi eBook Calibre Library

2. This should open the file explorer in the location of where that book is, in the address bar you should see "Calibre Library" click it to skip to that directory.

Raspberry Pi Find calibre folder

3. Now you have found the location of all your Calibre Library files, copy these files and folders to your /home/pi/storage/eBooks/ folder. All these files will be automatically found by COPS and displayed on the web interface. If you are unsure on how to get these files to your Raspberry Pi continue with this tutorial.

Raspberry Pi Calibre copy all within

4. Now to get all of our Calibre files and folders to our Raspberry Pi we will be making use of the piece of software called MobaXterm. This is a great piece of software that offers support for a wide variety of protocols, one of these being SFTP. You can grab MobaXterm for free from the MobaXterm's official website.

Begin by downloading, installing and then running MobaXterm.

5. Open running MobaXterm you should be greeted with the following screen. Begin by clicking the button in the top right hand corner labeled "Session".

Raspberry PI mobaxterm session

6. On this next screen first click the SFTP tab (1.) then type in both your Raspberry Pi's local IP Address and type in your Pi users username, pi is the username of the default user (2.) Finally press the "Ok" button to initiate the connection (3.).

Raspberry Pi Mobaxterm select SFTP

7. On this next screen click on the address bar as shown below, and type in /home/pi/storage/eBooks/ and then press enter. This will allow us to jump directly to the folder we need.

Raspberry Pi Mobaxterm change directory

8. Finally, we can copy the files from your computer to the Raspberry Pi by dragging them from the folder onto the MobaXterm SFTP window like that we have shown below. This will immediately begin the transfer process, when its complete you can continue to our last step.

Raspberry Pi Mobaxterm copy files

Checking out COPS

1. To checkout the Pi's eBook server you will need to browse to your Raspberry Pi's IP address with /ebooks at the end of it. To grab your Raspberry Pi's local IP address you can type the following command into terminal.

hostname -I

2. Once you have your Raspberry Pi's local IP address then go to it in your favourite web browser with /ebooks tagged at the end of it.

You can also use this URL with various different eBook readers so you can access all the data through there interface.

The URL you visit should look something like below, of course replacing with your own IP Address.

You should be greeted with a web page like below when you browse to the URL.

We hope by the time you have gotten to this point you have successfully setup your very own Raspberry Pi eBook server and have learnt how to copy your Calibre library over to it using SFTP. If you have enjoyed this tutorial or have any feedback feel free to drop a comment below!

Ultimate Books of Pi Bottom
Pi My Life Up's Crash Course
to the Raspberry Pi

Pi My Life Up's Crash Course

to the Raspberry Pi

Subscribe to our email list to get the

Crash Course delivered straight to your inbox

Please check your inbox for a confirmation email!