10-26-2010, 03:03 PM | #1 |
Grand Sorcerer
Posts: 11,948
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
PHP+Apache web server for calibre ...
EDIT: 2012/02/15: V0.2.8 has been released. See this post.
My personal web + email server is a VPS, living in a data center somewhere. I want to have my calibre library available on that web server. I am running Debian Lenny, which means installing calibre is a right bother. The server is also headless, and I don't want to deal with the framebuffer stuff. For quite some time I have been using calibre2opds + dropbox. These work quite adequately, but there are three things that are mildly irksome. The first is that calibre2opds doesn't support custom fields. The second (more serious for me) is that I must remember to regenerate the library (and I forget). The third is that calibre2opds creates a mess of files in my library (yes, I know I can copy it, but that means duplicating my library). Couple these with the question 'how hard would it be ...' and I started playing. I now have a PHP-based Apache plugin implementing a calibre content server. It uses the calibre database and library directly, generating html as needed. The pages are template-driven (smarty, overkill but I wanted to learn it). It supports calibre custom columns, searches, sorting, and per-user restrictions, amongst other things. Either web server and internal authentication can be used. Requirements: the implementation requires a web server (Apache and IIS should both work), PHP 5.2 or 5.3 with some modules such as SQLite and GD, and Smarty. I am using both PHP 5.2 and PHP5.3, smarty 2.6 and Apache 2.2. See the README and INSTALL files included in the distribution for more information. Last edited by chaley; 02-15-2012 at 03:51 AM. |
10-26-2010, 03:15 PM | #2 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Slightly tangential, but as far as I know, the calibre content server no longer requires X to function, so no need for framebuffer, and if you do a binary calibre install, then it should be trivial to install calibre on debian (the only thing you may have to do is compile a modern glibc by hand and put it into the /opt/calibre directory).
|
Advert | |
|
10-26-2010, 04:07 PM | #3 |
Grand Sorcerer
Posts: 11,948
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Actually, not tangential at all. Using the standard content server is certainly preferable to what I have done.
I am running Lenny, which has old everything. I tried the binary install, but the installer fails to run because of glibc. I checked backports, but would have more-or-less forced a full upgrade. It never occurred to me to compile a full glibc and provide that when running the installer, thinking that the prerequisites would be too much trouble. I am still having some trouble figuring out exactly how it will work when running the installer, because /opt/calibre doesn't exist yet. I will take a look at that tomorrow. Suggestions are welcome. |
10-26-2010, 04:45 PM | #4 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
|
10-26-2010, 04:57 PM | #5 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Don't run the installer. Just download the binary tarball, extract it into /opt/calibre and put glibc into /opt/calibre. You should then be able to run
/opt/calibre/calibre-server All the installer does is install symlinks in /usr/bin, manpages, bash completion and other guff. |
Advert | |
|
10-26-2010, 08:56 PM | #6 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
10-26-2010, 09:16 PM | #7 | ||
US Navy, Retired
Posts: 9,865
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
Last edited by DoctorOhh; 10-26-2010 at 09:22 PM. |
||
10-27-2010, 08:48 AM | #8 | |
Grand Sorcerer
Posts: 11,948
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
After several hours of work and once nuking my system (fortunately I had made a backup onto a spare partition), I got it to work on Debian Lenny. I was never successful with using a compiled glibc. First problem: compiling glibc 10 and above requires a newer version of binutils because of some multi-arch stuff. It was while working around that when I nuked my system; at one point dpkg nicely removed /sbin/ldconfig, breaking everything. OK, I put that back, then successfully compiled glibc. Second problem: putting the resulting .so into /opt/calibre/libc.so.6 led to immediate segfaults during loading. After the 'export LDD_LIBRARY_PATH ...', no program would run, even 'ls'. To make a very long story short, the only way I could make this work without upgrading most of my server was to grab the 'testing' version of the libc6 package (libc6_2.11.2), extract the contents to a temp directory, then copy everything from temp/lib to /opt/calibre. I am sure that a subset of the 43 copied libraries would work, but I don't have the patience to delete things one by one until it breaks. Related notes (really off-topic, but as I am here): -- getting calibre-server to run in reverse-proxy mode with SSL wasn't fun. The major problem is the non-relative URLs, making URL remapping impossible. Working around that (creating another SSL host) causes SSL certificate mismatches, but I can live with that. -- The reference src="http://calibre-ebook.com/site_media//img/button-donate.png" in the donate form causes mixed-security mode errors in IE when running under SSL. It would be better if the button image came from calibre-server instead of the external site. -- Regarding upgrading the server: I will do it when debian stops doing security upgrades to lenny. Life is too short to spend a week on essentially useless work (it really did take me a week to upgrade from sarge to lenny). For example, simply changing from PHP5.2 to PHP5.3 breaks every web application that uses MySQL. PHP5.3 no longer permits old-style password encryption, which means that the applications cannot log in. I don't need passwords at all, really, because of how the server runs, so the change simply breaks things without adding any security. Backing out PHP5.3 was a major reason I went through the bother of making calibre-server work. |
|
10-27-2010, 09:40 AM | #9 |
Grand Sorcerer
Posts: 11,948
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
In fact, I didn't get it to work. Once I finished cleaning up the dregs from the experiments and restoring my system to clean 'lenny', the segfaults came back.
I give up. I will take my PHP implementation to the point where I have what I want. |
10-27-2010, 09:49 AM | #10 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Glad you got it to work I've fixed the server to use a local copy of the image.
Are you using the Apache reverse proxy for finer grained authentication? On your server troubles, these all or nothing upgrades were the primary reason I switched from binary to source linux distros on all my computers (including the servers). For example, with gentoo you have this nifty feature called slots which allow you to have two (or more) major versions of software installed side by side. So for example you could have PHP 5.2 and 5.3 installed side by side. And you can do more frequent (but less intensive) upgrades. |
10-27-2010, 10:05 AM | #11 | |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
Create a chroot and install the binutils and libc, tar, gzip debs in the chroot. Then install calibre in the chroot and run the server from the chroot. |
|
10-27-2010, 11:23 AM | #12 |
Grand Sorcerer
Posts: 11,948
Karma: 7225107
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Did that.
Now I get Code:
Traceback (most recent call last): File "/tmp/init.py", line 46, in <module> File "/home/kovid/build/calibre/src/calibre/library/server/main.py", line 12, in <module> File "/home/kovid/build/calibre/src/calibre/library/server/base.py", line 20, in <module> File "/home/kovid/build/calibre/src/calibre/library/server/content.py", line 14, in <module> File "/home/kovid/build/calibre/src/calibre/library/caches.py", line 15, in <module> ImportError: cannot import name QImage I have not installed python. My understanding is that I should not need to. Edit: Have tried chroots of both squeeze and sid. In both cases I had to install libglib2. In both cases I get the above error. Last edited by chaley; 10-27-2010 at 11:37 AM. |
10-27-2010, 11:32 AM | #13 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
This is when running
/opt/calibre/calibre-server (in the chroot?) |
10-27-2010, 11:34 AM | #14 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
An import error usually means that a python module could not be found probably because the directory tree it is in is not in sys.path
It may be that the code in calibre that sets up sys.path in the binary install does not play nice with chrooting. Try this calibre-debug -c "import sys; print sys.path" |
10-27-2010, 11:40 AM | #15 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
And can we move this to email.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre Command Line usage with PHP | artoros | Related Tools | 13 | 07-01-2010 09:57 AM |
Web Content Server | mezme | Calibre | 7 | 01-08-2010 09:59 PM |
Calibre web server on MAC I cant get to work.. any help appreciated. | stustaff | Calibre | 5 | 01-06-2010 06:05 PM |
Calibre - web server problems | eclpmb | Calibre | 9 | 11-28-2008 02:04 PM |