Comment migrer un site Apache vers ServBay
Le serveur Web fourni avec ServBay est Caddy, réputé pour sa configuration simple et l'activation automatique de HTTPS. Caddy est déjà configuré avec des règles de réécriture (Rewrite) par défaut, et les utilisateurs ne nécessitent généralement pas de configuration supplémentaire. Cet article explique en détail comment migrer un site Apache vers ServBay, en utilisant Laravel et WordPress comme exemples.
Vue d'ensemble
La migration de site implique de transférer les configurations existantes et les fichiers vers le nouvel environnement serveur. ServBay utilise Caddy comme serveur Web, et pour la majorité des frameworks PHP et systèmes CMS, ServBay fonctionne par défaut sans nécessiter de configuration supplémentaire pour les règles de réécriture.
Préparation à la migration
Avant de commencer la migration, assurez-vous d'avoir sauvegardé tous les fichiers de votre site et les bases de données. Des problèmes peuvent survenir lors de la migration, c'est pourquoi il est crucial d'avoir des sauvegardes.
Migration d'un site Laravel
Configuration Apache
Voici un exemple typique de fichier de configuration Apache pour un site Laravel :
<VirtualHost *:80>
ServerName laravel.demo
DocumentRoot /Applications/ServBay/www/laravel/public
<Directory /Applications/ServBay/www/laravel/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/Applications/ServBay/tmp/php-cgi.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
2
3
4
5
6
7
8
9
10
11
12
13
14
Configuration Caddy
Important
Dans ServBay, les règles de réécriture et le traitement PHP sont déjà configurés par défaut, les utilisateurs n'ont pas besoin de rédiger de fichiers de configuration manuellement.
Voici un exemple théorique de configuration Caddy pour comparaison et compréhension :
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
Migration d'un site WordPress
Configuration Apache
Voici un exemple typique de fichier de configuration Apache pour un site WordPress :
<VirtualHost *:80>
ServerName wordpress.demo
DocumentRoot /Applications/ServBay/www/wordpress
<Directory /Applications/ServBay/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/Applications/ServBay/tmp/php-cgi.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
2
3
4
5
6
7
8
9
10
11
12
13
14
Configuration Caddy
Important
Dans ServBay, les règles de réécriture et le traitement PHP sont déjà configurés par défaut, les utilisateurs n'ont pas besoin de rédiger de fichiers de configuration manuellement.
Voici un exemple théorique de configuration Caddy pour comparaison et compréhension :
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
Conclusion
La migration d'un site Apache vers le serveur Caddy de ServBay est très simple et ne nécessite aucune modification de configuration. Les utilisateurs doivent simplement ajouter leur site sur ServBay. La syntaxe du fichier de configuration de Caddy est simple et lisible, et ServBay configure par défaut les règles de réécriture et le traitement PHP, de sorte que les utilisateurs n'ont généralement pas besoin de configuration supplémentaire. Grâce à cet article, vous pouvez comprendre comment migrer des sites Laravel et WordPress vers ServBay.