How to Migrate an Apache Website to ServBay
ServBay comes with a built-in web server called Caddy, known for its simple configuration and automatic HTTPS. Caddy is already configured with default rewrite rules, so users typically do not need to add any additional rules. This article will detail how to migrate an Apache website to ServBay, using Laravel and WordPress as examples.
Overview
Migrating a website involves transferring existing configurations and files to a new server environment. ServBay uses Caddy as the web server, and for most PHP frameworks and CMS systems, ServBay works out-of-the-box without additional rewrite rule configurations.
Preparation Before Migration
Before starting the migration, ensure that you have backed up all website files and databases. Various issues may occur during the migration process, so having a backup is very important.
Migrating 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 create 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 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 create 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 very straightforward without any configuration changes. Users just need to add their website in ServBay. Caddy’s configuration file syntax is simple and readable, and ServBay has pre-configured rewrite rules and PHP handling, so users typically do not need to add any extra configurations. This article has explained how to migrate Laravel and WordPress websites to ServBay.