Setting up your own Raspberry Pi eBook Server

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

Raspberry Pi eBook Server

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.

This software works as a fantastic middleman for your eBooks 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 would find that this is a pretty handy tutorial if you wanted to the host an eBook 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.



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.

Preparing your Raspberry Pi for COPS

1. Before we begin, let’s bring all our packages on Raspberry PI OS are up to date by running the following command in the terminal.

sudo apt update
sudo apt 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.

sudo apt-get install git php8.2-gd php8.2-cli php8.2-sqlite3 php8.2-intl php8.2-xml php8.2-mbstring php8.2-zip composer

On older versions of Raspberry Pi OS, you may run into an error indicating that APT did not find a package. This issue can be worked around by adding a third-party PHP repository that contains these missing packages.

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 the terminal on your Raspberry Pi to restart NGINX.

sudo systemctl reload nginx

Setting up the eBook Server on your Raspberry Pi

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, and this serves your eBooks to any device that connects to it.

Before we clone the latest versions of COPS to our Raspberry Pi, let use create a directory to store it on our Raspberry Pi.

You can create this directory by using the mkdir command within the terminal.

sudo mkdir -p /var/www/html/ebooks

5. After creating the directory we must change into it by using the cd command.

cd /var/www/html/ebooks

6. Now that we are in our new “ebooks” folder, we can use the following command to clone the COPS repository. We are using a fork by Mike’s Pub as it offers better support for modern versions of PHP and Composer.

Make sure you type in the dot (.) 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 git clone .

7. We now need to use Composer to install any of the PHP libraries that COPS relies on to work.

Luckily, this is as easy as running the following command within the terminal.

sudo composer install --no-dev -o

You will get a warning about running Composer as a root/super user, type “yes” to proceed.

Creating a Storage Location for your eBooks

8. 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 a folder called “/storage/eBooks/” in your home directory by running the command below.

mkdir -p ~/storage/eBooks

By starting the path with the tilde (~) symbol, we are referencing the current users home directory.

Configuring the COPS eBook Server for your Raspberry Pi

9. With our folder now created let’s work on setting up the configuration file of COPS.

Our first task is to copy over the example configuration file, so we have something to start with.

sudo cp config_local.php.example config_local.php

10. After copy over the example configuration, we can begin editing the config file by using

sudo nano config_local.php

11. Within this file make the following changes.

a. The first option we must configure is the location of your eBooks

First look for the following line within the config file.

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

Once you find the above line, change it so that it looks a bit like what we have shown here.

Ensure that you replace “<USERNAME>” with your own username.

$config['calibre_directory'] = '/home/<USERNAME>/storage/eBooks/';

b. The next thing you will want to do is give your new Raspberry Pi eBook server a beter name. At the moment it is set to “COPS”.

Within this file, look for the following line.

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

Once you have found the above line, replace “COPS” with the title you want assigned to your server.

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

12. 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 click “Open containing folder” (2.).

Raspberry Pi eBook Calibre Library

2. This process should open the file explorer in the location of where that book is, in the address bar you should see “Calibre Libraryclick 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/<USERNAME>/storage/eBooks/ folder.

COPS will automatically find all these files and be displayed on the web interface. If you are unsure of 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. It 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/<USERNAME>/storage/eBooks/ and then press ENTER.

This process 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.

It will immediately begin the transfer process, and when it’s complete, you can continue to our last step.

Raspberry Pi Mobaxterm copy files

Checking out COPS

1. To check out 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 hostname command into the terminal.

hostname -I

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

You can also use this URL with various 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 set up your very own Raspberry Pi eBook server and have learned 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.


  1. Avatar for Roulio
    Roulio on

    Thank you, that’s the most detailed tutorial I’ve found to achieve this !
    I’ve successfully did every step described, but I’m stuck while loading myraspberryIP/ebooks : I’m facing an HTTP error 500…

    If I try to go to myraspberryIP/ebooks/login.html i’m facing a login page, but i don’t know what cred should i use to enter (raspi credentials are not working, neither admin/admin nor admin/admin123 etc…)

    I’m not sure what should i do that’s my first time playing with a nginx webserver. I know this tutorial is quite old, but does anybody can help me with this situation ?

    1. Avatar for Emmet
      Emmet on

      Hi Roulio,

      I’ve combed back through the tutorial and hopefully have fixed everything that might have possibly been going wrong with your installation.
      You might have to start fresh since I’ve also changed the repository, we are using to a more maintained fork. The main repository hadn’t been touched in over 4 years.

      Please let me know if you are still running into issues after the changes.

      Kind regards,

  2. Avatar for Rodrigo
    Rodrigo on

    Just FYI, to get it to work I used the following commands instead of the ones listed on step 5 of “Setting up your eBook Server with COPS”

    sudo wget
    sudo php composer.phar global require "fxp/composer-asset-plugin:~1.1"
    sudo php composer.phar install --no-dev --optimize-autoloader
  3. Avatar for Eddie
    Eddie on

    After installing the php packages from step 2, I attempted to run the “sudo /etc/init.d/nginx reload” from step 3 and received the following error “sudo: /etc/init.d/nginx: command not found” — After checking, I see nginx hasn’t installed to that directory. Any idea why nginx hasn’t installed to there and where it may have installed to?

    1. Avatar for Emmet
      Emmet on

      Hi Eddie,

      Just verifying, did you follow our installing NGINX On a Raspberry Pi guide before following this tutorial?

      If you have, can you please try using the following command instead. This uses the more modern systemctl to reload the service rather than the old “init.d” file call.

      sudo systemctl reload nginx


  4. Avatar for Thomas
    Thomas on

    When I run:
    sudo php composer.phar global require “fxp/composer-asset-plugin:~1.1”

    I get:
    Package fxp/composer-asset-plugin at version ~1.1 has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version

    Any help would be appreciated!


    1. Avatar for Emmet
      Emmet on

      Hi Thomas,

      I have now fixed up the issue that was occuring here.

      Within the tutorial we were downloading the latest non stable release of Composer that the required packages did not support.

      We have updated the tutorial to download the latest stable release.

      Let me know if that fixes the issue for you.


  5. Avatar for Schuyler Sandheinrich
    Schuyler Sandheinrich on

    I ran the php script…

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

    Server down???

    Reading state information… Done
    E: Unable to locate package php7.3-gd
    E: Couldn’t find any package by glob ‘php7.3-gd’
    E: Couldn’t find any package by regex ‘php7.3-gd’

    1. Avatar for Emmet
      Emmet on

      Hi Schuyler,

      Are you running Raspbian Buster? These packages should be available on Raspbian Buster and later.
      If you are then try running sudo apt update again.


    2. Avatar for Schuyler Sandheinrich
      Schuyler Sandheinrich on

      That may have been the issue. I upgraded to Buster and I’ll let you know how it goes.


  6. Avatar for Kevin
    Kevin on

    I am receiving the following error
    MESSAGE pi@raspberrypi:/var/www/html/ebooks $ sudo php composer.phar install –no-dev –optimize-autoloader
    Do not run Composer as root/super user! See for details
    Composer could not find a composer.json file in /var/www/html/ebooks
    To initialize a project, please create a composer.json file as described in the “Getting Started” section

    When I run sudo php composer.phar install –no-dev –optimize-autoloader from step 5

    Please let me know what I am missing, Thanks

    1. Avatar for Gus
      Gus on

      Hey Kevin,

      Make sure that you are running the command in the correct directory and that you actually cloned the repository into /ebook/ folder and not /ebook/cops/ folder.


    2. Avatar for Paul
      Paul on

      Make sure when you do the git clone, you include the “.” at the end. Otherwise, you will be copying everything into another subdirectory called “cops,” and as mentioned below, that will cause this scenario.

  7. Avatar for Brendan
    Brendan on

    I keep getting configuration errors telling me to check if all the packages are installed which they are. Mainly database error. I’m just wandering if it’s because the books are in a SAMBA directory on the pi and the permissions are incorrect?

    1. Avatar for Gus
      Gus on

      Hey Brendan,

      Seeing the actual errors would help us work out what the actual problem is.


Leave a Reply

Your email address will not be published. Required fields are marked *