Cómo Migrar un Sitio Web de NGINX a ServBay
ServBay viene con el servidor web Caddy, conocido por su configuración sencilla y HTTPS automático. ServBay ya tiene configuradas las reglas de reescritura predeterminadas, por lo que los usuarios generalmente no necesitan configuraciones adicionales. Este artículo explicará en detalle cómo migrar un sitio web de NGINX a ServBay, usando Laravel y WordPress como ejemplos.
Resumen
La migración del sitio web implica transferir la configuración y los archivos existentes a un nuevo entorno de servidor. ServBay utiliza Caddy como servidor web y, para la mayoría de los frameworks PHP y sistemas CMS, ServBay está listo para usar sin necesidad de configuraciones adicionales de reglas de reescritura.
Preparación antes de la migración
Antes de empezar la migración, asegúrese de haber realizado una copia de seguridad de todos los archivos y la base de datos del sitio web. Pueden surgir varios problemas durante el proceso, por lo que la copia de seguridad es muy importante.
Migración de un Sitio Web de Laravel
Configuración de NGINX
A continuación se muestra un archivo de configuración típico de NGINX para un sitio web de 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
Configuración de Caddy
Importante
En ServBay, las reglas de reescritura y las reglas de procesamiento de PHP ya están configuradas por defecto, el usuario no necesita escribir manualmente el archivo de configuración.
A continuación se muestra un ejemplo teórico de configuración de Caddy, para comparación y comprensión:
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
Migración de un Sitio Web de WordPress
Configuración de NGINX
A continuación se muestra un archivo de configuración típico de NGINX para un sitio web de 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
Configuración de Caddy
Importante
En ServBay, las reglas de reescritura y las reglas de procesamiento de PHP ya están configuradas por defecto, el usuario no necesita escribir manualmente el archivo de configuración.
A continuación se muestra un ejemplo teórico de configuración de Caddy, para comparación y comprensión:
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
Conclusión
Migrar un sitio web de NGINX al servidor Caddy de ServBay es muy sencillo, no es necesario hacer ninguna modificación de configuración, el usuario solo necesita agregar el sitio web en ServBay. La sintaxis de los archivos de configuración de Caddy es simple y fácil de leer, ServBay ya tiene configuradas las reglas de reescritura y el procesamiento de PHP por defecto, por lo que generalmente no se necesita configuración adicional. A través de esta introducción, podrá entender cómo migrar sitios web de Laravel y WordPress a ServBay.