How to Migrate an Apache Website to ServBay
ServBay comes with Caddy as its web server, known for its simple configuration and automatic HTTPS. Caddy has pre-configured Rewrite rules, so users typically do not need to set additional Rewrite rules. This article explains in detail how to migrate an Apache website to ServBay, using Laravel and WordPress as examples.
Support for NGINX and Apache
ServBay will soon support NGINX. Please stay tuned for official announcements.
Overview
Migrating a website involves transferring existing configurations and files to a new server environment. ServBay uses Caddy as the web server, which works out-of-the-box for most PHP frameworks and CMS systems without needing additional Rewrite rule configurations.
Preparation Before Migration
Before starting the migration, please ensure that you have backed up all your website files and databases. Backup is crucial as various issues may arise during the migration process.
Migrating a Laravel Website
Apache Configuration
Below is a typical Apache configuration file for a Laravel website:
<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
Caddy Configuration
Important Note
In ServBay, Rewrite rules and PHP handling rules are already pre-configured, 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
Apache Configuration
Below is a typical Apache configuration file for a WordPress website:
<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
Caddy Configuration
Important Note
In ServBay, Rewrite rules and PHP handling rules are already pre-configured, 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
Conclusion
Migrating an Apache website to ServBay's Caddy server is straightforward, with no configuration changes needed. Users only need to add the website to ServBay. Caddy's configuration syntax is simple and readable; ServBay has pre-configured Rewrite and PHP handling, usually requiring no additional setup. Through this guide, you can learn how to migrate Laravel and WordPress websites to ServBay.