Ver código fonte

Support distro-default PHP packages on Raspberry Pi

master
Daniel Covington 1 semana atrás
pai
commit
605b27efe9
2 arquivos alterados com 15 adições e 16 exclusões
  1. +3
    -4
      docs/deploy-raspberry-pi.md
  2. +12
    -12
      scripts/deploy-raspi.sh

+ 3
- 4
docs/deploy-raspberry-pi.md Ver arquivo

@@ -6,7 +6,7 @@ This app can run directly on a Raspberry Pi with **nginx + php-fpm** instead of


`scripts/deploy-raspi.sh` runs from your local machine and connects over SSH to the Pi. On the Pi it will: `scripts/deploy-raspi.sh` runs from your local machine and connects over SSH to the Pi. On the Pi it will:


- install `nginx`, `git`, `composer`, and PHP 8.2 packages
- install `nginx`, `git`, `composer`, and the distro-default PHP packages
- clone or update the repository - clone or update the repository
- create/update `.env` - create/update `.env`
- install Composer dependencies - install Composer dependencies
@@ -44,7 +44,6 @@ Arguments:
```bash ```bash
DEPLOY_REF=main \ DEPLOY_REF=main \
DEPLOY_PATH=/var/www/warehouse \ DEPLOY_PATH=/var/www/warehouse \
PHP_VERSION=8.2 \
scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com
``` ```


@@ -52,7 +51,7 @@ scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.


- browse to `http://DietPi.ntp.kentcommunications.com` - browse to `http://DietPi.ntp.kentcommunications.com`
- check nginx with `sudo systemctl status nginx` - check nginx with `sudo systemctl status nginx`
- check php-fpm with `sudo systemctl status php8.2-fpm`
- check php-fpm with `systemctl list-units --type=service | grep php.*fpm`
- check the queue worker with `sudo systemctl status warehouse-queue.service` - check the queue worker with `sudo systemctl status warehouse-queue.service`


## Notes ## Notes
@@ -60,4 +59,4 @@ scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.
- the app serves from `public/`, so the nginx root must stay pointed there - the app serves from `public/`, so the nginx root must stay pointed there
- low-stock emails are always queued in this app, so the queue worker service matters in production - low-stock emails are always queued in this app, so the queue worker service matters in production
- this script sets up **HTTP only**; add TLS separately with `certbot` or another reverse-proxy setup if you want HTTPS - this script sets up **HTTP only**; add TLS separately with `certbot` or another reverse-proxy setup if you want HTTPS
- if you prefer MySQL instead of SQLite, update `.env` and the script before rerunning it
- if you prefer MySQL instead of SQLite, update `.env` and the script before rerunning it

+ 12
- 12
scripts/deploy-raspi.sh Ver arquivo

@@ -12,20 +12,16 @@ repo_url="$3"
domain="${4:-DietPi.ntp.kentcommunications.com}" domain="${4:-DietPi.ntp.kentcommunications.com}"
deploy_path="${DEPLOY_PATH:-/var/www/warehouse}" deploy_path="${DEPLOY_PATH:-/var/www/warehouse}"
deploy_ref="${DEPLOY_REF:-main}" deploy_ref="${DEPLOY_REF:-main}"
php_version="${PHP_VERSION:-8.2}"


ssh "${ssh_user}@${ssh_host}" bash -s -- "$repo_url" "$domain" "$deploy_path" "$deploy_ref" "$php_version" <<'REMOTE'
ssh "${ssh_user}@${ssh_host}" bash -s -- "$repo_url" "$domain" "$deploy_path" "$deploy_ref" <<'REMOTE'
set -euo pipefail set -euo pipefail


repo_url="$1" repo_url="$1"
domain="$2" domain="$2"
deploy_path="$3" deploy_path="$3"
deploy_ref="$4" deploy_ref="$4"
php_version="$5"
owner="$(id -un)" owner="$(id -un)"
group="$(id -gn)" group="$(id -gn)"
php_fpm_service="php${php_version}-fpm"
php_fpm_socket="/run/php/${php_fpm_service}.sock"


set_env() { set_env() {
file="$1" file="$1"
@@ -39,11 +35,13 @@ set_env() {
} }


sudo apt-get update sudo apt-get update
sudo apt-get install -y git nginx composer \
"php${php_version}" "php${php_version}-cli" "php${php_version}-fpm" \
"php${php_version}-mbstring" "php${php_version}-xml" \
"php${php_version}-curl" "php${php_version}-zip" \
"php${php_version}-sqlite3" "php${php_version}-mysql"
sudo apt-get install -y \
git nginx composer \
php php-cli php-fpm php-mbstring php-xml php-curl php-zip php-sqlite3 php-mysql

php_version="$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;')"
php_fpm_service="php${php_version}-fpm"
php_fpm_socket="/run/php/${php_fpm_service}.sock"


sudo mkdir -p "$(dirname "$deploy_path")" sudo mkdir -p "$(dirname "$deploy_path")"
if [ ! -d "$deploy_path/.git" ]; then if [ ! -d "$deploy_path/.git" ]; then
@@ -56,7 +54,9 @@ else
fi fi


cd "$deploy_path" cd "$deploy_path"
if [ ! -f .env ] && [ -f .env.example ]; then cp .env.example .env; fi
if [ ! -f .env ] && [ -f .env.example ]; then
cp .env.example .env
fi
set_env .env APP_ENV prod set_env .env APP_ENV prod
set_env .env DB_CONNECTION sqlite set_env .env DB_CONNECTION sqlite
set_env .env DB_SQLITE_PATH "$deploy_path/database/database.sqlite" set_env .env DB_SQLITE_PATH "$deploy_path/database/database.sqlite"
@@ -123,4 +123,4 @@ sudo systemctl restart nginx
sudo systemctl restart warehouse-queue.service sudo systemctl restart warehouse-queue.service


echo "Deployment complete: http://${domain}" echo "Deployment complete: http://${domain}"
REMOTE
REMOTE

Carregando…
Cancelar
Salvar

Powered by TurnKey Linux.