diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 52a3689..1bf705b 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -51,7 +51,7 @@ ## 3. Einmalige Einrichtung bei Strato bash scripts/deploy.sh production artisan db:seed --class=ProductionSeeder --force bash scripts/deploy.sh production artisan make:filament-user ``` -10. **Domain-Zielverzeichnis** (Domains › Domain verwalten › Ziel) auf `/current/public` setzen; SSL-Zertifikat aktivieren. +10. **Domain-Zielverzeichnis** auf den Ordner `` selbst setzen (Strato kann kein Symlink-Ziel wählen). `setup` legt dort eine `.htaccess` an, die alles intern nach `current/public` leitet, interne Dateien sperrt (403) und per `AddType application/x-httpd-php84 .php` die Web-PHP-Version **nur für diesen Ordner** auf die CLI-Version setzt – andere Anwendungen im Paket bleiben unberührt. SSL-Zertifikat für die Domain aktivieren. 11. **Cronjob** (Kundenlogin › Cronjobs), jede Minute: ``` /opt/RZphp84/bin/php-cli //current/artisan schedule:run @@ -82,4 +82,6 @@ ## 6. Getestet / offen - Lokal im Testmodus (`DEPLOY_HOST=local`) erfolgreich: Build (~19 MB), Upload, Entpacken, alle Migrationen auf frischer Datenbank, `optimize`, Ersteinrichtung per `ProductionSeeder`, alle Seiten und Admin-Login liefern 200. - **Nicht** unter Windows prüfbar: der Symlink-Wechsel von `current` (Git Bash legt Kopien statt Symlinks an). Unter Linux (Strato) ist das Standardverhalten; der erste Lauf auf dem Testbetrieb bestätigt es – bei Fehler greift der automatische Rollback. -- Bei Strato zu prüfen: SSH im Tarif, PHP-CLI-Pfad, ob das Domain-Ziel einem Symlink (`current`) folgt, minütliche Cronjobs. +- **Auf Strato erfolgreich (22.10.2026, test.fewo-stommer.de):** SSH mit Schlüssel (paketspezifischer Server), PHP-CLI `/opt/RZphp84/bin/php-cli`, Migrationen auf MariaDB, Symlink-Umschaltung, `.htaccess`-Weiterleitung, Web-PHP 8.4 per `AddType`, `ProductionSeeder`; alle Seiten 200. +- Noch offen: SSL für die Subdomain, Cronjob, Gesundheitscheck über HTTPS. +- Erstes Deployment auf ein neues Ziel: `SKIP_HEALTH_CHECK=1 bash scripts/deploy.sh deploy` (die Domain zeigt da noch nicht auf die neue Installation). diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 0cb9853..05122e9 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -59,6 +59,23 @@ switch_to() { case "$cmd" in setup) mkdir -p releases shared/storage/app/public shared/storage/framework/cache/data shared/storage/framework/sessions shared/storage/framework/views shared/storage/logs + # For hosting panels that cannot point a domain at a symlink: the domain points at this folder, + # everything is served from current/public and all internal files are blocked. + # Strato: the web server's PHP version can be chosen per folder; use the same version as the CLI. + web_php="$(printf '%s' "$php" | grep -oE 'RZphp[0-9]+' | grep -oE '[0-9]+' || true)" + { [[ -n "$web_php" ]] && echo "AddType application/x-httpd-php$web_php .php"; cat <<'HTACCESS' + + RewriteEngine On + RewriteRule ^(releases|shared|current/(?!public/)|\.|upload-) - [F,L] + RewriteCond %{REQUEST_URI} !^/current/public/ + RewriteRule ^(.*)$ current/public/$1 [L] + + + Require all denied + +HTACCESS + } > .htaccess + echo ".htaccess angelegt (Domain-Ziel: $base${web_php:+, Web-PHP $web_php})." if [[ -f shared/.env ]]; then echo "shared/.env vorhanden."; else echo "HINWEIS: Bitte $base/shared/.env anlegen (Vorlage: .env.production.example)."; fi echo "PHP: $("$php" -v | head -n 1)" ;; @@ -164,6 +181,8 @@ build() { health_check() { [[ -n "$DEPLOY_URL" ]] || { echo "Kein DEPLOY_URL gesetzt – Gesundheitscheck übersprungen."; return 0; } + # First deployment: the domain does not point to current/public yet. + [[ "${SKIP_HEALTH_CHECK:-}" == "1" ]] && { echo "SKIP_HEALTH_CHECK=1 – Gesundheitscheck übersprungen."; return 0; } say "Prüfe $DEPLOY_URL/up" for attempt in 1 2 3 4 5; do if curl -fsS --max-time 15 "$DEPLOY_URL/up" > /dev/null; then