netgescon-day0/docs/00-MASTER-DOCS-UNIFICATI/03-MANUALI-OPERATIVI/INSTALLATION.md

279 lines
5.5 KiB
Markdown
Executable File

# 🔧 Installazione Sistema Debug NetGescon
## 📋 Prerequisiti
### Software Richiesto
- **PHP**: 8.2+
- **Laravel**: 11+
- **Node.js**: 18+ (per asset)
- **Composer**: 2.0+
### Permessi Sistema
```bash
# Verifica permessi storage
chmod -R 775 storage/
chmod -R 775 bootstrap/cache/
# Verifica proprietario
chown -R www-data:www-data storage/
chown -R www-data:www-data bootstrap/cache/
```
---
## 🚀 Installazione
### 1. File già presenti
I file del sistema debug sono già installati in:
```
app/Debug/ # Sistema completo
resources/views/admin/debug/ # Dashboard
docs/debug/ # Documentazione
```
### 2. Verifica Service Provider
Il `DebugServiceProvider` è registrato in `bootstrap/providers.php`:
```php
return [
App\Providers\AppServiceProvider::class,
App\Debug\DebugServiceProvider::class, // ✅ Presente
];
```
### 3. Verifica Route
Le route debug sono in `routes/web.php`:
```php
// Sistema Debug
Route::prefix('debug')->name('debug.')->group(function () {
Route::get('/', [App\Debug\Controllers\SystemDebugController::class, 'index'])
->name('index');
// ... altre route
});
```
### 4. Test Comandi
```bash
# Verifica comandi disponibili
php artisan list | grep netgescon
# Output atteso:
# netgescon:debug Sistema di debug avanzato
# netgescon:find-duplicates Trova e gestisce view duplicate
```
---
## 🧪 Test Installazione
### 1. Test Console
```bash
# Test base
php artisan netgescon:debug --help
# Test scansione veloce
php artisan netgescon:debug --duplicates
```
### 2. Test Dashboard Web
```bash
# Avvia server
php artisan serve
# Visita dashboard
# http://localhost:8000/admin/debug
```
### 3. Test Permessi
```bash
# Test scrittura log
php artisan netgescon:debug --report
# Verifica file creato
ls -la storage/logs/netgescon_debug_*.json
```
---
## ⚙️ Configurazione
### 1. Variabili Ambiente
Aggiungi a `.env`:
```bash
# Debug avanzato
DEBUG_SYSTEM_ENABLED=true
DEBUG_AUTO_CLEAN=false
DEBUG_BACKUP_KEEP_DAYS=30
```
### 2. Configurazione Laravel
In `config/app.php`:
```php
'debug' => env('APP_DEBUG', false), // Prod: false
'log_level' => env('LOG_LEVEL', 'debug'),
```
### 3. Personalizzazione Path
Se usi directory personalizzate, modifica in `SystemAnalyzer.php`:
```php
protected $directories = [
'resources/views' => 'active',
'tua-directory-backup' => 'backup', // Personalizza
];
```
---
## 🔐 Sicurezza
### 1. Protezione Route
Le route debug sono già protette:
```php
Route::middleware(['role:admin|amministratore'])
->prefix('admin')
->group(function () {
// Route debug qui
});
```
### 2. Backup Directory
```bash
# Crea directory backup sicura
mkdir -p _DUPLICATES_MOVED/
chmod 750 _DUPLICATES_MOVED/
chown -R www-data:www-data _DUPLICATES_MOVED/
```
### 3. Log Rotation
Configura in `/etc/logrotate.d/netgescon`:
```
/var/www/netgescon/storage/logs/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 644 www-data www-data
}
```
---
## 🚨 Troubleshooting Installazione
### Errore: "Class not found"
```bash
# Rigenera autoload
composer dump-autoload
# Clear cache
php artisan config:clear
php artisan cache:clear
```
### Errore: "Route not defined"
```bash
# Verifica route esistenti
php artisan route:list | grep debug
# Clear route cache
php artisan route:clear
```
### Errore: "Permission denied"
```bash
# Fix permessi
sudo chown -R $USER:www-data storage/
sudo chmod -R 775 storage/
```
### Dashboard non carica
1. Verifica server attivo: `php artisan serve`
2. Controlla URL: `http://localhost:8000/admin/debug`
3. Verifica login come admin
4. Check log: `tail -f storage/logs/laravel.log`
---
## 📊 Verifica Post-Installazione
### Checklist Completa
- [ ] ✅ Service Provider registrato
- [ ] ✅ Route debug funzionanti
- [ ] ✅ Comandi console disponibili
- [ ] ✅ Dashboard web accessibile
- [ ] ✅ Permessi directory corretti
- [ ] ✅ Log system scrivibile
- [ ] ✅ Backup directory creata
### Test Funzionale
```bash
#!/bin/bash
echo "🔍 Test Sistema Debug NetGescon"
echo "1. Test comando base..."
php artisan netgescon:debug --help > /dev/null && echo "✅ OK" || echo "❌ FAIL"
echo "2. Test scansione..."
php artisan netgescon:debug --duplicates > /dev/null && echo "✅ OK" || echo "❌ FAIL"
echo "3. Test report..."
php artisan netgescon:debug --report > /dev/null && echo "✅ OK" || echo "❌ FAIL"
echo "4. Test dashboard (richiede browser)..."
curl -s http://localhost:8000/admin/debug > /dev/null && echo "✅ OK" || echo "⚠️ Server offline"
echo "🎉 Installazione verificata!"
```
---
## 🔄 Aggiornamenti
### Procedura Update
```bash
# Backup configurazione
cp -r app/Debug/ app/Debug_backup/
# Pull nuovi file (se da repository)
git pull origin main
# Aggiorna dipendenze
composer dump-autoload
# Clear cache
php artisan config:clear
php artisan view:clear
# Test funzionamento
php artisan netgescon:debug --scan
```
### Versioning
```
v1.0 - Release iniziale con dashboard e comandi base
v1.1 - Aggiunta report JSON e analytics
v1.2 - Integrazione CI/CD e monitoraggio automatico
```
---
## 📞 Supporto
### In caso di problemi:
1. **Controlla log**: `storage/logs/laravel.log`
2. **Verifica configurazione**: `php artisan config:show`
3. **Test ambiente**: `php artisan about`
4. **Debug modalità**: `APP_DEBUG=true` in `.env`
### Risorse utili:
- 📚 Documentazione: `docs/debug/README.md`
- 🐛 Debug log: `storage/logs/netgescon_debug_*.json`
- 🔧 Test script: `docs/debug/test-installation.sh`
---
**🎯 Sistema Debug installato e pronto all'uso!**