Some time ago, I wrote a guide on how to create an online eBook library, accessible from a browser or Android/iPhone device. The benefits are many. You always have access to all your books, anywhere. You can directly share them with your friends. You don’t have to manage local libraries on your devices.
Since I wrote my first post, a number of better tools have come along which make this easier. Here is the new way to do it.
You will need:
- A personal web server capable of running PHP applications. You can use a real server or a virtual machine as long as it has a public IP address you can access. Or you could use your desktop PC, accessible only within your private LAN when you’re at home. Dropbox is no longer an option, as only serves static content (not PHP apps). I use the latest Ubuntu LTS release with Apache and PHP 5.3, on my own server with a public IP address.
- Calibre, to manage your eBook library. Calibre is awesome. It converts between virtually all eBook formats, can strip DRM, and stores and manages your books in a way you can easily access with a file browser.
- ownCloud, to synchronise your Calibre data to your server automatically. Alternatively, you can use any file synchronisation tool.
- COPS, a PHP application which can read Calibre’s metadata and generate OPDS and HTML catalogs. OPDS is an interchangeable format for describing and sharing eBooks – such as in a personal library.
- An eBook reader with OPDS support, such as FBReader or MegaReader.
How to do it:
Install Calibre
Installing Calibre is easy. On Ubuntu, just run:
apt-get install calibre
Run it for the first time, add some eBooks to your library, and close the application. For this example, I assume that you will save your eBooks to ~/Library
.
Calibre can also serve its own books directly as an OPDS library. However, Calibre is a GUI application, so I run it only on my desktop.
Install ownCloud on your server
Install ownCloud according to the instructions. For this example, I assume you will configure owncloud at www.example.com/owncloud
, and that you will create a user called “tyler”.
Install owncloud-client on your desktop
Like Calibre, you can install the ownCloud desktop client easily:
apt-get install owncloud-client
Start it and add ~/Library
as a new share. It will be uploaded to a directory on the server such as:
~/public_html/owncloud/data/tyler/files/ownCloud/Library/
Install COPS
Download and install COPS according to the instructions. For this example, I assume you will install COPS in ~/public_html/cops
, and will create a symbolic link to point to your Library folder in ownCloud folder for ease of use. I have configured this as so:
cd ~/public_html/cops ln -s ../owncloud/data/tyler/files/ownCloud/Library
This symbolic link works around ownCloud’s htaccess restrictions to make the eBook files readable.
Now edit config_local.php with your preferred settings. Be sure to configure $config['calibre_directory']
to point to your Calibre folder:
$config['calibre_directory'] = 'Library/';
COPS’s author, Sébastien, is a nice guy who would appreciate any patches, translations, or beer you have for him.
You should now be able to browse to your library. For example:
http://www.example.com/cops
Safety tip: click the “gear” icon for a very useful search dialog.
Install an eBook reader with OPDS support
I prefer to read with FBReader on Android devices. On Apple iOS, consider MegaReader. Kindle users can’t use OPDS, but can download eBooks via the web interface or “side-load” them via USB from a PC. Here are the instructions for FBReader; other software is similar.
- Install FBReader from Google Play and open it.
- Press “Network library” button
- Press “Add catalog”
- Select “Enter URL manually”
- Enter the URL to your library, appended with “/feed.php”. For example, “http://www.example.com/cops/feed.php”.
- Press OK twice. Your catalog will now appear in the list.
You can now browse your catalog within FBReader, select any book, and download it, and read it without navigating out again.
Updating the library
Once you have all this set up, updating your library is easy. Just add the book in Calibre and quit. ownCloud will synchronise the new files to your server in the background. The new books will be available in COPS as soon as it completes.
-
Tyler as discussed in the emails, I am posting all the emails that we exchanged shere so that others can learn from my experience and benefit from your guidance further.
Email String Timeline (Ascending):
Email 1 (Reply to my Comment by Tyler): tolaris.com
Jun 11 (7 days ago)to me
There is a new comment on the post “My OPDS library”.
http://www.tolaris.com/2012/02/13/my-opds-library/Author: Tyler Wagner
Comment:
Sorry, Rishi, I can’t help you. I’m no longer using Calibre2OPDS, and I’ve never used GDrive or Dropbox for sync. Nor have I used Calibre Cloud Pro. In fact, I now use Calibre+ownCloud+COPS:http://www.tolaris.com/2014/04/25/a-better-way-to-share-ebooks-or-my-opds-library-version-2-0/
My first suggestion is to test against another eBook reader with OPDS support like FBReader. Every reader has odd quirks of what it can support and what it cannot. If you find a solution, please let me know.
See all comments on this post here:
http://www.tolaris.com/2012/02/13/my-opds-library/#commentsTo manage your subscriptions or to block all notifications from this site, click the link below:
http://www.tolaris.com/?wp-subscription-manager=1&email=rishsaran%40gmail.com&key=63e0d66aa8346c682982557a0d27e7c9Email 2 (My Response): Rishi Saran
Jun 11 (7 days ago)to tolaris.com
Thank you.This is a bit technical for me. Is Google Drive static too, so I presume it will not help with php files. Is Owncloud free or does it cost money? Wish Dropbox had worked as per your previous write up. Unfortunately, the option for having a Public folder is only available to Pro or Business users. And the current e-book readers are a pain when it comes to library management.
Thanks.
Kind regards,
Rishi Saran.
Email 3 (Tyler’s Response):
Tyler J. Wagner
Jun 12 (6 days ago)to me
Yes, all the free-service cloud filesharing services allow only static
content. If you want to use PHP, you need to run your own website. What
I’ve set up is very technical.I suggest starting over. Use just Calibre, Calibre Cloud Pro, and any
sharing service. You won’t need OPDS if you use Calibre Cloud Pro; it reads
Calibre’s files directly.Regards,
TylerEmail 4 (My Response): Rishi Saran
Jun 17 (1 day ago)to Tyler
Hi Tyler,Thank you for your guidance. I have finally gone ahead with the technical route. I have made my Caliber libraries, Fiction and Non Fiction on my Laptop. I have set up a domain and registered with a web hosting service. I have successfully downloaded and installed owncloud webphp and desktop apps. What I am now struggling with is getting COPS php to work.
Please would you be able to email a step by step guide to install COPS only as Sebastien’s instructions on his blog are not very clear from my layman perspective. Also attached is an error log that was generated by owncloud when uploading my ebooks to my web hosting domain. Some books were not uploaded. Not sure why. I have highlighted some of these errors in bold. Please if you can guide me on this one too. Many thanks.
Kind regards,
Rishi Saran.
Email 5 (My Further Response): I forgot to mention in my previous email, the 2 libraries, fiction and non-fiction, created by Calibre, have been uploaded by owncloud on the hosting site within ‘/public_html/owncloud/data/saransorb/files’. The two folders Fiction (‘/public_html/owncloud/data/saransorb/files/f7n5/’) and Non Fiction (‘/public_html/owncloud/data/saransorb/files/nf795/’) are the folders within which the two types of books have been uploaded.
Does this then mean that in the config_local.php.example file, the command should read:
$config[‘files_directory’] = array (“Fiction” => “/public_html/owncloud/data/saransorb/files/F7N5/”, “Non Fiction” => “/public_html/owncloud/data/saransorb/files/NF7N5/”);
before I rename the example file to config_local.php?
Sorry I should have mentioned this before.
Kind regards,
Rishi Saran.
Email 6 (Tyler’s response): Tyler J. Wagner
Jun 17 (1 day ago)to me
Rishi,One problem is that ownCloud isn’t syncing all files. This is the clue:
Request Entity Too Large
Check the sizes on all objects saying this. I’ll bet they are above a PHP
upload threshold. I have these php.ini customisations:upload_max_filesize = 50M
post_max_size = 50M
expose_php = Off
memory_limit = 256MSolve that first. Then for COPS, I’ve attached an example config_local.php.
In my case, I just made a symlink to the owncloud folder:
$ cd cops
$ ln -s ../owncloud/data/tyler/files/ownCloud/Books/Library
$ ls -l
…. Library -> ../owncloud/data/tyler/files/ownCloud/Books/LibraryThis bypasses the ownCloud permissions (.htaccess file), so COPS can serve
these files.I’m happy to help, but please post your experiences somewhere. You are
welcome to write a long comment to my blog post. I’d like to help not just
you, but the next person who is looking for answers.Regards,
TylerEmail 7 (My Response):
Rishi Saran
1:59 PM (23 hours ago)to Tyler
Thank you so very much.I will start shooting my future issues on your blog and I will copy paste these emails there as well for all to see.
Much appreciated.
Kind regards,
Rishi Saran.
Email 8 (Tyler’s response): Try the symlink technique I used, also mentioned in the blog. I found that
telling COPS to use ownCloud data didn’t work because of the htaccess
restrictions employed by ownCloud.One way to test is to upload one of your libraries outside of ownCloud,
like in cops/Library, and make COPS work with that. If it works, then you
just need to get the COPS/ownCloud part working. Having two unknown parts
at the same time is no fun.Regards,
Tyler -
Tyler,
I don’t know how to create a symbolic link. So I went ahead with your 2nd suggestion. This is what I have done:
I created a small library of 6 or 7 books just to try it out. I then uploaded this library/directory outside of owncloud and within COPS folder as per this “/public_html/cops-1.0.0RC1/calibre/COPS”
I then renamed config_local.php.example to config_local.php and edited the following changes within this renamed file:
<?php
if (!isset($config))
$config = array();/*
* The directory containing calibre's metadata.db file, with sub-directories
* containing all the formats.
* BEWARE : it has to end with a /
*/
$config['calibre_directory'] = '/public_html/cops-1.0.0RC1/calibre/COPS/';/*
* Catalog's title
*/
$config['cops_title_default'] = "COPS";/*
* use URL rewriting for downloading of ebook in HTML catalog
* See README for more information
* 1 : enable
* 0 : disable
*/
$config['cops_use_url_rewriting'] = "0";After editing the path directory and saving it, I then ran config.php first. I got a blank browser screen. The details are as below:
<?php
/**
* COPS (Calibre OPDS PHP Server) class file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas
*/require_once ‘config_default.php’;
if (file_exists(dirname(__FILE__). ‘/config_local.php’) && (php_sapi_name() !== ‘cli’))
require_once ‘config_local.php’;I then ran checkconfig.php and got the following details in my browser window (link: http://saransorb.url.ph/cops-1.0.0RC1/checkconfig.php):
COPS Configuration Check
Check if GD is properly installed and loaded
OKCheck if Sqlite is properly installed and loaded
OKCheck if libxml is properly installed and loaded
OKCheck if the rendering will be done on client side or server side
Client side renderingCheck if Calibre database path is not an URL
OKCheck if Calibre database file exists and is readable
File /public_html/cops-1.0.0RC1/calibre/COPS/metadata.db not found, Please check Value of $config[‘calibre_directory’] in config_local.phpValue of open_basedir in your php.ini The access rights of the Calibre Database Synology users please read this
I get exactly the same error message when I change the Calibre directory path to Owncloud. Now this metadata.db file is on the server. I am using web hosting by hostinger.co.uk. So firstly, I am not sure why is it not being found when it is already there. Secondly, how and where do I locate this php.ini file and do I have to? Lastly, the symlink commands that you shared in your email:
$ cd cops
$ ln -s ../owncloud/data/tyler/files/ownCloud/Books/Library
$ ls -l
…. Library -> ../owncloud/data/tyler/files/ownCloud/Books/LibraryDo I use them exactly as above with the following changes:
$ cd cops
$ ln -s ../owncloud/data/saransorb/files/ownCloud/’My Folder Name’/’My Calibre Library’
$ ls -l
…. Library -> ../owncloud/data/saransorb/files/ownCloud/’My Folder Name’/’My Calibre Library’If yes, where in config_local.php do I add these commands? Do I add them before this line or after:
$config[‘calibre_directory’] = ‘/public_html/cops-1.0.0RC1/calibre/COPS/’;
Please advise. I look forward to your response. Many thanks.
PS: On the web hosting service that I am using, PHP version was set to PHP 5.3. I have today changed it to PHP 5.5.
Kind regards,
Rishi Saran.
-
This is the script of config_local.php file at my end…is this correct?
../owncloud/data/saransorb/files/F7N5; $config['calibre_directory'] = 'F7N5/'; /* * Catalog's title */ $config['cops_title_default'] = "COPS"; /* * use URL rewriting for downloading of ebook in HTML catalog * See README for more information * 1 : enable * 0 : disable */ $config['cops_use_url_rewriting'] = "0";
-
Sorry, this one…please ignore the previous one…
../owncloud/data/saransorb/files/F7N5; $config['calibre_directory'] = 'F7N5/'; /* * Catalog's title */ $config['cops_title_default'] = "COPS"; /* * use URL rewriting for downloading of ebook in HTML catalog * See README for more information * 1 : enable * 0 : disable */ $config['cops_use_url_rewriting'] = "0";
-
Don’t know what’s going wrong, the left bit is getting deleted when posting these comments to you,
../owncloud/data/saransorb/files/F7N5; $config['calibre_directory'] = 'F7N5/'; /* * Catalog's title */ $config['cops_title_default'] = "COPS"; /* * use URL rewriting for downloading of ebook in HTML catalog * See README for more information * 1 : enable * 0 : disable */ $config['cops_use_url_rewriting'] = "0";
-
34 comments
Comments feed for this article
Trackback link: https://www.tolaris.com/2014/04/25/a-better-way-to-share-ebooks-or-my-opds-library-version-2-0/trackback/