277 lines
6.3 KiB
Markdown
277 lines
6.3 KiB
Markdown
# README - Script di Migrazione NetGescon su Linux
|
|
|
|
## Panoramica
|
|
|
|
Questa directory contiene script automatizzati per facilitare la migrazione completa di NetGescon da ambiente Windows a Linux Ubuntu Server 22.04 LTS.
|
|
|
|
## File Inclusi
|
|
|
|
### 📋 Documentazione
|
|
- `GUIDA-MIGRAZIONE-LINUX-COMPLETA.md` - Guida completa step-by-step
|
|
- `README.md` - Questo file
|
|
|
|
### 🔧 Script di Setup
|
|
- `setup-netgescon.sh` - Installazione ambiente Linux completo
|
|
- `setup-laravel.sh` - Configurazione progetto Laravel
|
|
- `nginx-config.sh` - Configurazione Nginx automatica
|
|
|
|
### 💾 Script di Manutenzione
|
|
- `backup-netgescon.sh` - Backup completo automatico
|
|
- `monitor-netgescon.sh` - Monitoraggio sistema e salute
|
|
|
|
## Utilizzo Rapido
|
|
|
|
### 1. Preparazione VM Linux
|
|
```bash
|
|
# Crea VM Ubuntu Server 22.04 LTS con:
|
|
# - RAM: 4-8 GB
|
|
# - Storage: 80 GB
|
|
# - Network: Bridge/NAT con port forwarding
|
|
```
|
|
|
|
### 2. Setup Ambiente (su Linux)
|
|
```bash
|
|
# Copia setup-netgescon.sh sulla VM Linux
|
|
chmod +x setup-netgescon.sh
|
|
./setup-netgescon.sh
|
|
```
|
|
|
|
### 3. Configurazione Database
|
|
```bash
|
|
sudo mysql_secure_installation
|
|
sudo mysql -u root -p
|
|
|
|
# Esegui i comandi SQL mostrati dallo script
|
|
```
|
|
|
|
### 4. Trasferimento Progetto
|
|
```bash
|
|
# Da Windows: copia netgescon-laravel/ in /var/www/netgescon/
|
|
# Metodi: SCP, SFTP, WinSCP, FileZilla, USB, etc.
|
|
|
|
# Su Linux: setup Laravel
|
|
chmod +x setup-laravel.sh
|
|
./setup-laravel.sh
|
|
```
|
|
|
|
### 5. Configurazione Web Server
|
|
```bash
|
|
chmod +x nginx-config.sh
|
|
./nginx-config.sh
|
|
```
|
|
|
|
### 6. Test Finale
|
|
```bash
|
|
# Test applicazione
|
|
php artisan serve --host=0.0.0.0 --port=8000
|
|
|
|
# Accedi via browser:
|
|
# http://IP_VM:8000
|
|
```
|
|
|
|
## Script Dettagliati
|
|
|
|
### setup-netgescon.sh
|
|
**Cosa fa:**
|
|
- Aggiorna sistema Ubuntu
|
|
- Installa PHP 8.2 + estensioni Laravel
|
|
- Installa Composer, Node.js, MySQL, Nginx
|
|
- Configura firewall UFW
|
|
- Crea directory progetto con permessi corretti
|
|
|
|
**Requisiti:**
|
|
- Ubuntu Server 22.04 LTS
|
|
- Connessione internet
|
|
- Utente con privilegi sudo
|
|
|
|
**Tempo:** ~10-15 minuti
|
|
|
|
### setup-laravel.sh
|
|
**Cosa fa:**
|
|
- Configura permessi Laravel
|
|
- Installa dipendenze PHP (composer install)
|
|
- Installa dipendenze frontend (npm install)
|
|
- Configura file .env automaticamente
|
|
- Genera APP_KEY
|
|
- Esegue migrazioni e seeder
|
|
- Ottimizza cache Laravel
|
|
|
|
**Requisiti:**
|
|
- Progetto Laravel in /var/www/netgescon/netgescon-laravel/
|
|
- Database MySQL configurato
|
|
- Dipendenze di sistema installate
|
|
|
|
**Tempo:** ~5-10 minuti
|
|
|
|
### nginx-config.sh
|
|
**Cosa fa:**
|
|
- Crea virtual host Nginx ottimizzato per Laravel
|
|
- Configura PHP-FPM integration
|
|
- Abilita gzip compression
|
|
- Aggiunge security headers
|
|
- Configura asset caching
|
|
- Testa e riavvia servizi
|
|
|
|
**Tempo:** ~2-3 minuti
|
|
|
|
### backup-netgescon.sh
|
|
**Cosa fa:**
|
|
- Backup database MySQL
|
|
- Backup file applicazione (tar.gz)
|
|
- Backup configurazioni sistema
|
|
- Crea manifest dettagliato
|
|
- Rimuove backup vecchi (>7 giorni)
|
|
- Log operazioni
|
|
|
|
**Configurazione crontab automatica:**
|
|
```bash
|
|
sudo crontab -e
|
|
# Aggiungi: 0 2 * * * /path/to/backup-netgescon.sh
|
|
```
|
|
|
|
### monitor-netgescon.sh
|
|
**Cosa fa:**
|
|
- Verifica stato servizi (Nginx, PHP-FPM, MySQL)
|
|
- Controlla uso risorse (CPU, RAM, Disk)
|
|
- Testa connessione database
|
|
- Verifica risposta HTTP
|
|
- Analizza log errori
|
|
- Controlla backup recenti
|
|
- Genera report dettagliato
|
|
|
|
**Uso raccomandato:**
|
|
```bash
|
|
# Controllo manuale
|
|
./monitor-netgescon.sh
|
|
|
|
# Controllo automatico ogni ora
|
|
crontab -e
|
|
# Aggiungi: 0 * * * * /path/to/monitor-netgescon.sh >> /var/log/netgescon/monitor.log
|
|
```
|
|
|
|
## Troubleshooting Comune
|
|
|
|
### Errore: Permission Denied
|
|
```bash
|
|
sudo chown -R $USER:www-data /var/www/netgescon
|
|
sudo chmod -R 755 /var/www/netgescon
|
|
sudo chmod -R 775 /var/www/netgescon/netgescon-laravel/storage
|
|
```
|
|
|
|
### Errore: Database Connection Failed
|
|
```bash
|
|
# Verifica MySQL
|
|
sudo systemctl status mysql
|
|
|
|
# Test connessione
|
|
mysql -u netgescon_user -p netgescon
|
|
|
|
# Verifica .env
|
|
cat /var/www/netgescon/netgescon-laravel/.env | grep DB_
|
|
```
|
|
|
|
### Errore: Nginx 502 Bad Gateway
|
|
```bash
|
|
# Verifica PHP-FPM
|
|
sudo systemctl status php8.2-fpm
|
|
|
|
# Log errori
|
|
sudo tail -f /var/log/nginx/error.log
|
|
|
|
# Riavvio servizi
|
|
sudo systemctl restart nginx php8.2-fpm
|
|
```
|
|
|
|
### Errore: Laravel 500 Internal Server Error
|
|
```bash
|
|
# Log Laravel
|
|
tail -f /var/www/netgescon/netgescon-laravel/storage/logs/laravel.log
|
|
|
|
# Verifica permessi storage
|
|
sudo chmod -R 775 /var/www/netgescon/netgescon-laravel/storage
|
|
|
|
# Reset cache
|
|
cd /var/www/netgescon/netgescon-laravel
|
|
php artisan cache:clear
|
|
php artisan config:clear
|
|
```
|
|
|
|
## File di Configurazione
|
|
|
|
### Nginx Virtual Host
|
|
- Percorso: `/etc/nginx/sites-available/netgescon`
|
|
- Document root: `/var/www/netgescon/netgescon-laravel/public`
|
|
- PHP-FPM socket: `/var/run/php/php8.2-fpm.sock`
|
|
|
|
### Database
|
|
- Nome: `netgescon`
|
|
- Utente: `netgescon_user`
|
|
- Password: `NetGescon2024!` (modificabile)
|
|
|
|
### Directory Progetto
|
|
- Base: `/var/www/netgescon/`
|
|
- Laravel: `/var/www/netgescon/netgescon-laravel/`
|
|
- Storage: `/var/www/netgescon/netgescon-laravel/storage/`
|
|
|
|
## Performance e Sicurezza
|
|
|
|
### Ottimizzazioni Incluse
|
|
- PHP OPcache abilitato
|
|
- Nginx gzip compression
|
|
- Asset caching (1 anno)
|
|
- Security headers
|
|
- Database connection pooling
|
|
|
|
### Backup e Monitoraggio
|
|
- Backup automatico giornaliero (2:00 AM)
|
|
- Retention 7 giorni
|
|
- Monitoraggio health check
|
|
- Log centralizzati
|
|
|
|
## Supporto
|
|
|
|
### Log Principali
|
|
- Laravel: `/var/www/netgescon/netgescon-laravel/storage/logs/laravel.log`
|
|
- Nginx: `/var/log/nginx/error.log`
|
|
- MySQL: `/var/log/mysql/error.log`
|
|
- Sistema: `/var/log/syslog`
|
|
|
|
### Comandi Utili
|
|
```bash
|
|
# Status servizi
|
|
sudo systemctl status nginx php8.2-fpm mysql
|
|
|
|
# Riavvio servizi
|
|
sudo systemctl restart nginx php8.2-fpm mysql
|
|
|
|
# Test configurazione
|
|
sudo nginx -t
|
|
php artisan config:cache
|
|
|
|
# Monitoring real-time
|
|
htop
|
|
iotop
|
|
netstat -tlnp
|
|
```
|
|
|
|
## Versioni Supportate
|
|
|
|
- **Ubuntu:** 22.04 LTS (Jammy Jellyfish)
|
|
- **PHP:** 8.2.x
|
|
- **Laravel:** 10.x/11.x
|
|
- **MySQL:** 8.0.x
|
|
- **Nginx:** 1.22.x
|
|
- **Node.js:** 18.x LTS
|
|
|
|
## Note di Sicurezza
|
|
|
|
- Firewall UFW configurato automaticamente
|
|
- Password database sicura (modificabile)
|
|
- Permessi file Laravel ottimizzati
|
|
- Security headers Nginx
|
|
- Debug mode disabilitato in produzione
|
|
|
|
---
|
|
|
|
**Per supporto tecnico dettagliato, consultare `GUIDA-MIGRAZIONE-LINUX-COMPLETA.md`**
|