chore: complete update

This commit is contained in:
2025-07-17 16:38:55 +02:00
parent 64a7051137
commit ec5526e2b2
46 changed files with 3139 additions and 1 deletions

View File

@@ -0,0 +1,165 @@
# PHP Projekt Setup für Netcup
## Projektstruktur
Das Deployment erwartet diese Struktur in deinem Hauptprojekt:
```
dein-projekt/ # Hauptordner
├── ansible/ # Hier sind wir jetzt
│ └── netcup-simple-deploy/
├── docker/ # Docker-Konfiguration
│ ├── Dockerfile # (optional, wird sonst automatisch erstellt)
│ └── docker-compose.yml # (optional)
├── src/ # PHP Framework/Library Dateien
│ ├── classes/
│ ├── includes/
│ └── ...
├── public/ # Web-Root (öffentlich zugänglich)
│ ├── index.php # Haupteinstiegspunkt
│ ├── css/
│ ├── js/
│ ├── images/
│ └── ...
├── storage/ # (optional) Logs, Cache, etc.
├── cache/ # (optional) Cache-Dateien
├── logs/ # (optional) Log-Dateien
└── .env # (optional) Umgebungsvariablen
```
## Quick Setup
### 1. Konfiguration
```bash
cd ansible/netcup-simple-deploy
vim inventory/hosts.yml
```
**Ändere diese Werte:**
```yaml
ansible_host: DEINE-NETCUP-IP
domain: "deine-domain.com"
ssl_email: "deine@email.com"
local_app_path: "../.." # Zeigt auf dein Hauptprojekt
php_version: "8.2" # PHP Version
```
### 2. Deployment
```bash
make deploy
```
Das war's! Deine PHP-App läuft unter `https://deine-domain.com`
## Was passiert beim Deployment?
1. **Dateien übertragen:** `public/`, `src/`, `docker/` → Server
2. **Dockerfile erstellen:** Falls keins in `docker/` vorhanden
3. **Docker Container bauen:** PHP + Apache + deine App
4. **Nginx Proxy:** SSL-Termination und Weiterleitung
5. **SSL-Zertifikat:** Automatisch mit Let's Encrypt
## Für verschiedene PHP-Setups
### Eigenes Dockerfile verwenden
Lege dein Dockerfile in `docker/Dockerfile`:
```dockerfile
FROM php:8.2-apache
# Deine spezifischen PHP Extensions
RUN docker-php-ext-install pdo pdo_mysql
# Custom Apache Config
COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
# App Dateien
COPY public/ /var/www/html/
COPY src/ /var/www/src/
EXPOSE 80
```
### Mit Composer Dependencies
```dockerfile
FROM php:8.2-apache
# Composer installieren
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Dependencies installieren
COPY composer.json composer.lock /var/www/
WORKDIR /var/www
RUN composer install --no-dev --optimize-autoloader
# App kopieren
COPY public/ /var/www/html/
COPY src/ /var/www/src/
```
### Mit Database
Erweitere `inventory/hosts.yml`:
```yaml
app_env:
APP_ENV: "production"
DATABASE_HOST: "your-db-host"
DATABASE_NAME: "your-db-name"
DATABASE_USER: "your-db-user"
DATABASE_PASS: "your-db-password"
```
## Nützliche Befehle
```bash
# Logs anschauen
make logs
make error-logs
# Cache löschen
make clear-cache
# Permissions reparieren
make fix-permissions
# Composer auf Server ausführen
make composer-install
# Live logs verfolgen
make tail-logs
# SSH auf Server
make ssh
```
## Troubleshooting
### App lädt nicht?
```bash
# Apache Fehler-Logs prüfen
make error-logs
# Allgemeine Logs
make logs
# Container Status
make status
```
### Permissions-Probleme?
```bash
# Permissions reparieren
make fix-permissions
```
### Nach Code-Änderungen?
```bash
# Einfach neu deployen
make deploy
```
### Database-Verbindung?
```bash
# Umgebungsvariablen prüfen
ansible all -m shell -a "docker exec \$(docker ps -q | head -1) env | grep DATABASE"
```
Das Setup ist optimiert für deine bestehende Projektstruktur - keine Änderungen an deinem Code nötig! 🎉