# Guide de déploiement — VPS OVH

## Architecture cible

```
vandes-web.com       → /var/www/vandes-web.com/       (fichiers statiques)
admin.vandes-web.com → /var/www/admin.vandes-web.com/ (Laravel)
```

## 1. Prérequis VPS

```bash
apt update && apt upgrade -y
apt install -y nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-mbstring \
               php8.3-xml php8.3-curl php8.3-zip unzip git certbot python3-certbot-nginx
```

## 2. DNS OVH (zone DNS du domaine)

Dans le manager OVH, ajouter :
```
A     @      → IP_DE_TON_VPS
A     www    → IP_DE_TON_VPS
A     admin  → IP_DE_TON_VPS
```

## 3. Site vitrine statique

```bash
mkdir -p /var/www/vandes-web.com
# Copier les fichiers de other/v1/
scp -r other/v1/* user@ton-vps:/var/www/vandes-web.com/
```

## 4. Application Laravel

```bash
mkdir -p /var/www/admin.vandes-web.com
cd /var/www/admin.vandes-web.com

# Cloner / copier le projet
git clone <repo> . # ou rsync

# Permissions
chown -R www-data:www-data /var/www/admin.vandes-web.com
chmod -R 755 /var/www/admin.vandes-web.com
chmod -R 775 /var/www/admin.vandes-web.com/storage
chmod -R 775 /var/www/admin.vandes-web.com/bootstrap/cache

# Dépendances
composer install --no-dev --optimize-autoloader

# Config production
cp .env.example .env
# Éditer .env :
#   APP_ENV=production
#   APP_DEBUG=false
#   APP_URL=https://admin.vandes-web.com
#   LOCATION_TESTING=false
php artisan key:generate

# Base de données
php artisan migrate --force

# Cache production
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

## 5. Nginx

```bash
cp docs/deploy/nginx-vandes-web.com.conf /etc/nginx/sites-available/vandes-web.com
cp docs/deploy/nginx-admin.vandes-web.com.conf /etc/nginx/sites-available/admin.vandes-web.com

ln -s /etc/nginx/sites-available/vandes-web.com /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/admin.vandes-web.com /etc/nginx/sites-enabled/

nginx -t && systemctl reload nginx
```

## 6. SSL (Let's Encrypt)

```bash
certbot --nginx -d vandes-web.com -d www.vandes-web.com
certbot --nginx -d admin.vandes-web.com
```

## 7. Scheduler Laravel (cron pour purge RGPD mensuelle)

```bash
crontab -e -u www-data
# Ajouter :
* * * * * cd /var/www/admin.vandes-web.com && php artisan schedule:run >> /dev/null 2>&1
```

## 8. Sécurité complémentaire recommandée

```bash
# Fail2ban (bloque les IPs après trop d'échecs)
apt install -y fail2ban
# Configurer /etc/fail2ban/jail.local pour nginx-http-auth

# UFW (pare-feu)
ufw allow 22/tcp   # SSH
ufw allow 80/tcp   # HTTP
ufw allow 443/tcp  # HTTPS
ufw enable
```

## Checklist production Laravel

- [ ] `APP_DEBUG=false` dans `.env`
- [ ] `APP_ENV=production` dans `.env`
- [ ] `LOCATION_TESTING=false` dans `.env`
- [ ] `php artisan config:cache` exécuté
- [ ] Permissions `storage/` correctes (775, www-data)
- [ ] SSL actif sur les deux domaines
- [ ] Cron scheduler actif
