Come migrare un sito NGINX su ServBay
Il server web integrato di ServBay è Caddy, noto per la sua configurazione semplice e l'HTTPS automatico. ServBay ha già configurato le regole di riscrittura di base, quindi gli utenti solitamente non devono configurare ulteriormente. Questo articolo spiega come migrare un sito NGINX su ServBay, utilizzando Laravel e WordPress come esempi.
Panoramica
La migrazione di un sito comporta il trasferimento delle configurazioni e dei file esistenti a un nuovo ambiente server. ServBay utilizza Caddy come server web e, per la maggior parte dei framework PHP e dei sistemi CMS, non richiede configurazioni aggiuntive.
Preparazione prima della migrazione
Prima di iniziare la migrazione, assicurati di avere un backup di tutti i file del sito e del database. Durante la migrazione potrebbero verificarsi vari problemi, pertanto il backup è molto importante.
Migrare il sito Laravel
Configurazione NGINX
Ecco un tipico file di configurazione NGINX per un sito Laravel:
server {
listen 80;
server_name laravel.demo;
root /Applications/ServBay/www/laravel/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/Applications/ServBay/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Configurazione Caddy
Avviso importante
Su ServBay, le regole di riscrittura e di gestione PHP sono già preconfigurate, non è necessario creare file di configurazione manualmente.
Di seguito un esempio teorico di configurazione Caddy, per confronto e comprensione:
laravel.demo {
root * /Applications/ServBay/www/laravel/public
php_fastcgi unix//Applications/ServBay/tmp/php-cgi.sock
file_server
@notStatic {
not {
file {
try_files {path} {path}/ /index.php?{query}
}
}
}
rewrite @notStatic /index.php
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Migrare il sito WordPress
Configurazione NGINX
Ecco un tipico file di configurazione NGINX per un sito WordPress:
server {
listen 80;
server_name wordpress.demo;
root /Applications/ServBay/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/Applications/ServBay/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Configurazione Caddy
Avviso importante
Su ServBay, le regole di riscrittura e di gestione PHP sono già preconfigurate, non è necessario creare file di configurazione manualmente.
Di seguito un esempio teorico di configurazione Caddy, per confronto e comprensione:
wordpress.demo {
root * /Applications/ServBay/www/wordpress
php_fastcgi unix//Applications/ServBay/tmp/php-cgi.sock
file_server
@notStatic {
not {
file {
try_files {path} {path}/ /index.php?{query}
}
}
}
rewrite @notStatic /index.php
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Conclusione
Migrare un sito NGINX al server Caddy di ServBay è molto semplice, senza la necessità di modificare configurazioni. Gli utenti devono solo aggiungere il sito in ServBay. La sintassi del file di configurazione di Caddy è semplice e leggibile; le regole di riscrittura e gestione PHP sono già preconfigurate in ServBay, quindi ulteriori configurazioni sono solitamente non necessarie. Con questo articolo, puoi comprendere come migrare un sito Laravel e WordPress su ServBay.