standardebooks / web

The source code for the Standard Ebooks website.
https://standardebooks.org
Creative Commons Zero v1.0 Universal
234 stars 61 forks source link

Installation

PHP 8+ is required.

Installing on Ubuntu 22.04

# 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 php-curl php-zip apache2 apache2-utils libfcgi0ldbl task-spooler ipv6calc mariadb-server attr libapache2-mod-xsendfile libimage-exiftool-perl

# 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 dependencies using Composer.
cd /standardebooks.org/web/
composer install

# Add standardebooks.test to your hosts file.
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 proxy_fcgi xsendfile

# Link and enable the SE Apache configuration file.
sudo ln -s /standardebooks.org/web/config/apache/standardebooks.test.conf /etc/apache2/sites-available/
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.test.ini /etc/php/*/cli/conf.d/
sudo ln -s /standardebooks.org/web/config/php/fpm/standardebooks.test.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"

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:

# First, install the SE toolset, which will make the `se build` command-line executable available to the `deploy-ebook-to-www` script:
# https://standardebooks.org/tools

# Install the SE toolset as a library so we can use it in some automated scripts.
pip install standardebooks

# The `se` command must be in your $PATH, but installing it via `pip` might not do that automatically.
# If `which se` doesn't say anything, then either add the `pip` installation of the `se` executable to your $PATH manually, # or install it again using `pipx`; this will create a duplicate installation,
# but it will also install it in your $PATH for you:
pipx install standardebooks

# Once the toolset is installed and in your $PATH, clone a book and deploy it to your local SE site:
mkdir /standardebooks.org/ebooks/
cd /standardebooks.org/ebooks/
git clone --bare https://github.com/standardebooks/david-lindsay_a-voyage-to-arcturus
/standardebooks.org/web/scripts/deploy-ebook-to-www david-lindsay_a-voyage-to-arcturus.git

If everything went well, https://standardebooks.test/ebooks will show the one ebook you deployed.

Installation using Docker

We provide a Dockerfile for testing code changes. You can create a container with:

docker build . --tag standardebooks --file vms/docker/Dockerfile

Then run the built image with:

docker run --detach --publish 443:443 --volume "$(pwd):/standardebooks.org/web" standardebooks:latest

The site will now be available at https://localhost/, although as it’s a self-signed certificate you’ll need to accept whatever browser security warnings come up.

Filesystem layout

Testing

This repository includes PHPStan to statically analyze the codebase and Safe PHP to replace old functions that don’t throw exceptions.

To run PHPStan, execute:

$> <REPO-ROOT>/vendor/bin/phpstan analyse -c <REPO-ROOT>/config/phpstan/phpstan.neon

If run successfully, it should output [OK] No errors.

Contributing

Before submitting design contributions, please discuss them with the Standard Ebooks lead. While we encourage discussion and contributions, we can’t guarantee that unsolicited design contributions will be accepted. You can open an issue to discuss potential design contributions with us before you begin.

Help wanted/todo

Main website

PHP code style