This guide was created to address the issue of resource hogging by
Calibre built-in Server on my Raspberry Pi, and replacing it with the COPS as an alternative. COPS is coded by Mr. Sebastien Lucas. The reason I choose to run
COPS on the PHP Embedded Server is because it is for use in a small network,
and I don’t need a heavy duty webserver.
My Raspberry Pi 4 was installed with Raspbian Buster.
Update your Raspberry Pi
sudo apt-get update
&& sudo apt-get upgrade -y
Install all the additional modules for PHP
sudo apt-get install php-gd php-sqlite3 php-json php-intl
php-xml php-mbstring php-zip
Create directory to download COPS
cd /var/www
sudo mkdir cops
cd cops
Decompress the downloaded file
sudo unzip
cops-1.1.3.zip
Do not copy Calibre Library into COPS directory, but make a link to it
sudo ln -s "/home/pi/Calibre Library" library
Create a config_local.php file
sudo nano config_local.php
It should open nano editor with a blank file. Paste the following into the editor:
It should open nano editor with a blank file. Paste the following into the editor:
<?php
if
(!isset($config))
$config =
array();
$config['calibre_directory'] = './library/';
$config['cops_title_default']
= "COPS";
$config['cops_use_url_rewriting'] =
"0";
CTRL-O to save the
file
CTRL-X to exit the
editor
Create the COPS Service
sudo
nano /etc/systemd/system/cops.service
It should open nano editor with
a blank file.
Paste the following into the editor:
[Unit]
Description=Cops
Service
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/php
-S 192.168.50.1:8080 -t /var/www/cops/
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
CTRL-O to save the
file
CTRL-X to exit the
editor
I
am using the Raspberry Pi IP number as 192.168.50.1 and on port 8080.
My
Raspberry wifi is running as an AP and a client using RaspAP, the AP has the IP
Address
range from 192.168.50.1 to 192.168.50.250.
The client IP Address is
dependent
on the router DHCP for connection to the internet.
Enable COPS Service (automatically run when Raspberry Pi boots up)
sudo
systemctl enable cops.service
To understand more of the
command, you go to https://fedoramagazine.org/what-is-an-init-system/
or you can type the following in the command prompt
man systemctl
To start the COPS Service
sudo systemctl start cops.service
That’s it. I hope you find this guide useful.
Useful Resources:
No comments:
Post a Comment