From 1148ed74b0e38047b9e3e87c740cfb3af51de820 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sun, 7 Feb 2021 13:12:30 -0600 Subject: [PATCH] Fix installation instructions in readme to actually work, and add missing PHP config file --- .gitignore | 1 - README.md | 19 +++++++++++++------ config/php/fpm/standardebooks.org.ini | 17 +++++++++++++++++ lib/OpdsFeed.php | 2 +- www/opds/subjects/.gitignore | 4 ++++ 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 config/php/fpm/standardebooks.org.ini create mode 100644 www/opds/subjects/.gitignore diff --git a/.gitignore b/.gitignore index 760ee273..fed117e7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ ebooks/* www/ebooks/* www/images/covers/* www/opds/*.xml -www/opds/subjects www/rss/*.xml vendor/ composer.lock diff --git a/README.md b/README.md index af12fee5..453c3e85 100644 --- a/README.md +++ b/README.md @@ -5,26 +5,28 @@ PHP 7+ is required. ## Installing on Ubuntu 20.04 (Focal) ```shell -# Create the site root and clone this repo into it. +# Install Apache, PHP, PHP-FPM, and various other dependencies. +sudo apt install -y git composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl apache2 apache2-utils libfcgi0ldbl task-spooler + +# Create the site root and logs root and clone this repo into it. sudo mkdir /standardebooks.org/ +sudo chown $(whoami): /standardebooks.org +sudo mkdir /var/log/local/ cd /standardebooks.org/ git clone https://github.com/standardebooks/web/ -# Install Apache, PHP, PHP-FPM, and various other dependencies. -sudo apt install -y composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl apache2 apache2-utils libfcgi0ldbl task-spooler - # Install dependencies using Composer. cd /standardebooks.org/web/ composer install # Add standardebooks.test to your hosts file. -echo "127.0.0.1\tstandardebooks.test" | sudo tee -a /etc/hosts +echo -e "127.0.0.1\tstandardebooks.test" | sudo tee -a /etc/hosts # Create a self-signed SSL certificate for use with the local web site installation. openssl req -x509 -nodes -days 99999 -newkey rsa:4096 -subj "/CN=standardebooks.test" -keyout /standardebooks.org/web/config/ssl/standardebooks.test.key -sha256 -out /standardebooks.org/web/config/ssl/standardebooks.test.crt # Enable the necessary Apache modules. -sudo a2enmod {headers, expires, ssl, rewrite, proxy} +sudo a2enmod headers expires ssl rewrite proxy proxy_fcgi # Link and enable the SE Apache configuration file. sudo ln -s /standardebooks.org/web/config/apache/standardebooks.test.conf /etc/apache2/sites-available/ @@ -32,8 +34,13 @@ sudo a2ensite standardebooks.test sudo systemctl restart apache2.service # Link and enable the SE PHP-FPM pool. +sudo ln -s /standardebooks.org/web/config/php/fpm/standardebooks.org.ini /etc/php/*/cli/conf.d/ +sudo ln -s /standardebooks.org/web/config/php/fpm/standardebooks.org.ini /etc/php/*/fpm/conf.d/ sudo ln -s /standardebooks.org/web/config/php/fpm/standardebooks.test.conf /etc/php/*/fpm/pool.d/ sudo systemctl restart "php*-fpm.service" + +# Download the OPDS index template +wget -O /standardebooks.org/web/www/opds/index.xml https://standardebooks.org/opds ``` If everything went well you should now be able to open your web browser and visit `https://standardebooks.test/`. However, you won’t see any ebooks if you visit `https://standardebooks.test/ebooks/`. To install some ebooks, first you have to clone their source from GitHub, then deploy them to your local website using the `./scripts/deploy-ebook-to-www` script: diff --git a/config/php/fpm/standardebooks.org.ini b/config/php/fpm/standardebooks.org.ini new file mode 100644 index 00000000..b2ca4241 --- /dev/null +++ b/config/php/fpm/standardebooks.org.ini @@ -0,0 +1,17 @@ +error_log = "/var/log/local/php-error.log" +display_errors = Off +display_startup_errors = Off +html_errors = Off +log_errors = On +short_open_tag = On +error_reporting = E_ALL +max_execution_time = 120 +allow_url_fopen = false +allow_url_include = false +expose_php = off + +[Date] +date.timezone = Etc/UTC + +[opcache] +opcache.validate_timestamps = off diff --git a/lib/OpdsFeed.php b/lib/OpdsFeed.php index 26d3dd9d..972d2559 100644 --- a/lib/OpdsFeed.php +++ b/lib/OpdsFeed.php @@ -58,7 +58,7 @@ class OpdsFeed{ protected function SaveIfChanged(string $path, string $feed, string $updatedTimestamp): void{ $tempFilename = tempnam('/tmp/', 'se-opds-'); file_put_contents($tempFilename, $feed); - exec('se clean ' . escapeshellarg($tempFilename)); + exec('se clean ' . escapeshellarg($tempFilename) . ' 2>&1', $output); // Capture the result in case there's an error, otherwise it prints to stdout // Did we actually update the feed? If so, write to file and update the index if(!is_file($path) || ($this->Sha1Entries($feed) != $this->Sha1Entries(file_get_contents($path)))){ diff --git a/www/opds/subjects/.gitignore b/www/opds/subjects/.gitignore new file mode 100644 index 00000000..5e7d2734 --- /dev/null +++ b/www/opds/subjects/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore