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 generally do not need to configure rewrite rules additionally. This article will detail how to migrate an Apache website to the Caddy server provided with ServBay, using Laravel and WordPress as examples.
NGINX and Apache Support
ServBay will soon support Apache, please pay attention to the official announcements.
Overview
Migrating a website involves transferring existing configurations and files to a new server environment. ServBay supports users using Caddy as the web server, and for most PHP frameworks and CMS systems, ServBay is ready to use without additional configuration of rewrite rules.
Preparation Before Migration
Before starting the migration, please ensure you have backed up all website files and databases. Various issues may arise during the migration, so backups are crucial.
Migrating Laravel Website
Apache Configuration
The following 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, the rewrite rules and PHP handling rules are already configured by default, users do not need to manually write configuration files.
The following 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 WordPress Website
Apache Configuration
The following 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, the rewrite rules and PHP handling rules are already configured by default, users do not need to manually write configuration files.
The following 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 ServBay's Caddy server is very simple, requiring no configuration changes; users just need to add the website in ServBay. The configuration file syntax of Caddy is simple and easy to read, and ServBay has already configured the rewrite rules and PHP handling, typically requiring no additional configuration. Through this article, you can learn how to migrate Laravel and WordPress websites to Caddy.