Share your love
Easy Steps To Install and Configure Caddy on AlmaLinux 8

In this article, we want to teach you How To Install and Configure Caddy on AlmaLinux 8. Caddy is an alternative to an Apache web server that is easy to configure and use. Caddy is the first web server to acquire and renew SSL/TLS certificates automatically using Let’s Encrypt.
You can now follow the guide steps on the Orcacore website to Install and Configure Caddy on AlmaLinux 8.
Table of Contents
Install and Configure Caddy on AlmaLinux 8
To install the Caddy web server on AlmaLinux 8, log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our article the Initial Server Setup with AlmaLinux 8.
Also, you need a domain name that is pointed to your server’s IP address.
Now follow the steps below to Install and Configure Caddy on AlmaLinux 8.
Step 1 – Enable Copr Repository on AlmaLinux 8
First, you need to update your local package index with the following command:
sudo dnf update -y
By default, Caddy is not available in the default AlmaLinux 8 repository. So you need to add the Copr repository to your server and then Install and Configure Caddy on AlmaLinux 8.
The Copr (Cool Other Package Repo) is a Fedora project to help make building and managing third-party package repositories easy.
To do this, run the following command:
sudo dnf install 'dnf-command(copr)'
Then, enable the Caddy repository on AlmaLinux 8 with the following command:
sudo dnf copr enable @caddy/caddy
Again run the system update:
sudo dnf update
Once you are done, you can proceed to the next step to Install and Configure Caddy on AlmaLinux 8.
Step 2 – Install and Enable Caddy on AlmaLinux 8
Now use the following command to install Caddy on your server:
sudo dnf install caddy -y
Next, start and enable your Caddy service with the commands below:
$ sudo systemctl start caddy
$ sudo systemctl enable caddy
Verify that your Caddy service is active and running on your AlmaLinux 8 with the command below:
sudo systemctl status caddy
In your output you will see:
Output
caddy.service - Caddy
Loaded: loaded (/usr/lib/systemd/system/caddy.service; enabled; vendor prese>
Active: active (running) since Sun 2022-02-06 05:00:27 EST; 9s ago
Docs: https://caddyserver.com/docs/
Main PID: 88587 (caddy)
Tasks: 7 (limit: 11409)
Memory: 18.8M
CGroup: /system.slice/caddy.service
└─88587 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
Now that you have Caddy installed and running on your AlmaLinux 8, let’s see how to create a new site on the Caddy web server.
Step 3 – Create a new site on the Caddy Web Server
This step is similar to the Apache virtual hosts or Nginx server blocks. First, create a directory for your site with the command below:
sudo mkdir -p /var/www/your-domain/html
Then, create a directory for the logs:
sudo mkdir /var/log/caddy
Set the correct ownership for both directories with the commands below:
$ sudo chown caddy:caddy /var/www/your-domain/html -R
$ sudo chown caddy:caddy /var/log/caddy
Now you need to create an index.html file in your new site directory with your favorite text editor like the Vi Editor or Nano Editor:
sudo vi /var/www/your-domain/html/index.html
Add the following content to the file:
<!DOCTYPE html>
<html>
<head>
<title>Hi</title>
</head>
<body>
<h1>Welcome to orcacore</h1>
</body>
</html>
When you are done, save and close the file.
Here you need to edit the Caddy configuration file. Open the file with your favorite text editor, here we use vi:
sudo vi /etc/caddy/Caddyfile
Remove all the contents of the file and add the following contents to the file:
your-domain {
root * /var/www/your-domain/html
file_server
encode gzip
log {
output file /var/log/caddy/your-domain.log
}
@static {
file
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.pdf *.webp
}
header @static Cache-Control max-age=5184000
tls admin@your-domain
}
When you are done, save and close the file.
Then, you need to validate your configuration with the command below:
caddy validate --adapter caddyfile --config /etc/caddy/Caddyfile
Note: If the on-screen output results in a formatted warning, you can fix it by running the command below:
caddy fmt --overwrite /etc/caddy/Caddyfile
Next, restart the Caddy service on AlmaLinux 8 to apply the changes:
sudo systemctl restart caddy
Step 4 – Configure Firewall Rules For Caddy Web Server
At this point, you have learned to Install and Configure Caddy on AlmaLinux 8. We assumed that you have enabled the firewalld. Now you need to allow traffic on HTTP and HTTPS through the firewall with the following commands:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
Reload the firewall to apply the new rules:
sudo systemctl reload firewalld
Step 5 – Access the Caddy Web Server
At this point, you can access the Caddy web server by typing your domain name or server’s IP address in your web browser:
http://your-domain
You will see the Welcome test page.

Conclusion
At this point, you have learned to Install and Configure Caddy on AlmaLinux 8. With its automatic HTTPS, easy configuration, and active community support, Caddy stands out as an excellent choice for users looking for a modern alternative to traditional web servers like Apache or Nginx. By following the steps outlined in this guide, you can set up Caddy quickly and enjoy the benefits of a secure and high-performing web server.
Hope you enjoy it. You may also like the following articles:
Install Caddy Web Server on Debian 12
Install Apache Web Server on AlmaLinux 9
Caddy Web Server on Ubuntu 24.04
Install and Configure Caddy on Debian 11
FAQs
Can I use Caddy as a reverse proxy on AlmaLinux 8?
Yes. Its configuration file (Caddyfile) makes it straightforward to set up reverse proxy rules for routing traffic to backend services.
How do I reload Caddy after modifying the configuration?
You can reload Caddy By using the command: sudo systemctl reload caddy
Also, by using the guide steps to Install and Configure Caddy on AlmaLinux 8, you can easily start and enable your service.
Is Caddy compatible with other web applications and frameworks?
Yes, Caddy can serve various web applications, including those built with PHP, Python, Ruby, and more. It’s also compatible with popular frameworks like Laravel, Django, and Node.js.
Can I run multiple websites with Caddy on AlmaLinux 8?
Yes, Caddy supports virtual hosting, allowing you to serve multiple websites on the same server by configuring multiple domains in the Caddyfile.
Is it possible to integrate Caddy with a database on AlmaLinux 8?
While Caddy is primarily a web server, it can be used alongside database-driven applications like MySQL, PostgreSQL, or MongoDB.