How to Migrate an Apache Website to Caddy
ServBay comes with Caddy, NGINX, and Apache as web servers, and has default URL Rewrite rules configured for Caddy and NGINX, so users typically do not need to configure Rewrite rules additionally. This article will detail how to migrate an Apache website to the Caddy server included with ServBay, using Laravel and WordPress as examples.
NGINX and Apache Support
ServBay supports Apache. Please refer to how to switch the default web server to Apache.
Overview
Migrating a website involves transferring the existing configurations and files to a new server environment. ServBay supports users using Caddy as a web server, and for most PHP frameworks and CMS systems, ServBay is ready to use out of the box, with no additional configuration of Rewrite rules required.
Preparation Before Migration
Before starting the migration, make sure you have backed up all website files and databases. Various issues may arise during the migration process, so backups are essential.
Migrating a Laravel Website
Apache Configuration
Here 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 processing rules are already pre-configured, and users do not need to write configuration files manually.
Here is a theoretical example of Caddy configuration 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
Here 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 processing rules are already pre-configured, and users do not need to write configuration files manually.
Here is a theoretical example of Caddy configuration 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 the Caddy server of ServBay is very simple, requiring no configuration changes; users just need to add the site in ServBay. The Caddy configuration file syntax is straightforward and readable, with ServBay pre-configured for Rewrite rules and PHP processing, meaning users typically do not need to configure anything additional. Through this article, you can learn how to migrate Laravel and WordPress websites to Caddy.