Deployment: .htaccess-Weiterleitung für Strato (kein Symlink-Ziel), Web-PHP pro Ordner, erstes Deployment ohne Gesundheitscheck

Erfolgreich getestet auf Strato (test.fewo-stommer.de).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 16:22:27 +02:00
1 parent cb1e4cbc63
commit 92c796de2e
2 files changed
+23 -2

No files matched your search

+4 -2
View File
@@ -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 `<DEPLOY_PATH>/current/public` setzen; SSL-Zertifikat aktivieren.
10. **Domain-Zielverzeichnis** auf den Ordner `<DEPLOY_PATH>` 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 <home>/<DEPLOY_PATH>/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 <env> deploy` (die Domain zeigt da noch nicht auf die neue Installation).
+19
View File
@@ -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'
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(releases|shared|current/(?!public/)|\.|upload-) - [F,L]
RewriteCond %{REQUEST_URI} !^/current/public/
RewriteRule ^(.*)$ current/public/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
Require all denied
</IfModule>
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