How to Migrate NGINX Websites to ServBay
ServBay's built-in web server is Caddy, known for its simple configuration and automatic HTTPS. ServBay has defaulted the Rewrite rules so users typically do not need to configure additional Rewrite rules. This article details how to migrate an NGINX website to ServBay, using Laravel and WordPress as examples.
Support for NGINX and Apache
NGINX support is coming to ServBay, please watch for official announcements.
Overview
Migrating a website involves transferring the existing configuration and files to a new server environment. ServBay uses Caddy as the web server, and for most PHP frameworks and CMS systems, ServBay is ready to use, with no need to configure extra Rewrite rules.
Preparation Before Migration
Before starting the migration, ensure you have backed up all website files and databases. Various issues may arise during the migration, so backups are very important.
Migrating a Laravel Website
NGINX Configuration
Here is a typical NGINX configuration file for a Laravel website:
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
Caddy Configuration
Important Tip
In ServBay, the Rewrite rules and PHP handling rules have been defaulted, so users do not need to manually write configuration files.
Below is a theoretical Caddy configuration example for comparison and understanding:
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
Migrating a WordPress Website
NGINX Configuration
Here is a typical NGINX configuration file for a WordPress website:
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
Caddy Configuration
Important Tip
In ServBay, the Rewrite rules and PHP handling rules have been defaulted, so users do not need to manually write configuration files.
Below is a theoretical Caddy configuration example for comparison and understanding:
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
Summary
Migrating an NGINX website to ServBay's Caddy server is very simple and requires no configuration changes. Users only need to add the website to ServBay. Caddy's configuration file syntax is straightforward and easy to read, and ServBay has defaulted the Rewrite rules and PHP processing, so users typically do not require additional configurations. This article helps you understand how to migrate Laravel and WordPress websites to ServBay.