Install Caddy Web Server on AlmaLinux 9 | Easy Setup
In this comprehensive guide, we’ll walk you through the process of installing and configuring the Caddy web server on AlmaLinux 9. Caddy is an open-source, production-ready web server known for its simplicity, ease of use, and security features. Built in Go, Caddy boasts zero dependencies, making it easily downloadable and compatible with virtually any platform that Go supports.
One of Caddy’s standout features is its automatic HTTPS support. It provisions and renews certificates through Let’s Encrypt by default, eliminating the need for manual configuration. Caddy is unique in providing these features out-of-the-box and automatically redirects HTTP traffic to HTTPS, enhancing security.
Compared to traditional web servers like Apache and Nginx, Caddy’s configuration files are significantly smaller and more concise. Moreover, Caddy operates on TLS 1.3, the latest standard in transport security, offering robust protection for your web applications. The steps below will help you Install Caddy Web Server on AlmaLinux 9.
Before proceeding, ensure you are logged into your AlmaLinux 9 server as a non-root user with sudo privileges and have a basic firewall set up. You can refer to our guide on Initial Server Setup with AlmaLinux 9 for detailed instructions.
1. Install Caddy on AlmaLinux 9
First, update your local package index with the following command:
sudo dnf update -y
By default, Caddy is not available in the standard AlmaLinux repository. Therefore, you’ll need to add the Copr repository to your server.
Enable Copr Repository
Copr (Cool Other Package Repo) is a Fedora project that simplifies the building and management of third-party package repositories.
To install the necessary Copr plugin, run:
sudo dnf install 'dnf-command(copr)' -y
Next, enable the Caddy repository on AlmaLinux 9 using the following command:
sudo dnf copr enable @caddy/caddy
**Output**
Repository successfully enabled.
Run the system update again to apply the changes:
sudo dnf update -y
**Output**
Copr repo for caddy owned by @caddy 1.5 kB/s | 1.4 kB 00:00
Dependencies resolved.
Nothing to do.
Complete!
Installing Caddy with DNF
Now, install Caddy on AlmaLinux 9 with the command below:
sudo dnf install caddy -y
After installation, start and enable the Caddy service:
# sudo systemctl start caddy
# sudo systemctl enable caddy
Verify that the Caddy service is active and running by running:
sudo systemctl status caddy
The output should indicate that Caddy is active (running).

With Caddy successfully installed and running, let’s create a new site on the Caddy web server.
2. Create a new Caddy Site on AlmaLinux 9
This step is analogous to Apache virtual hosts or Nginx server blocks. Begin by creating a directory for your site:
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:
# sudo chown caddy:caddy /var/www/your-domain/html -R
# sudo chown caddy:caddy /var/log/caddy
Now, create an index.html
file in your new site directory using your preferred text editor (e.g., vi):
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>
Save and close the file.
Next, edit the Caddy configuration file:
sudo vi /etc/caddy/Caddyfile
Remove all existing content and add the following configuration:
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
}
Save and close the file.
Validate your configuration:
caddy validate --adapter caddyfile --config /etc/caddy/Caddyfile
If the output displays a formatted warning, you can fix it by running:
caddy fmt --overwrite /etc/caddy/Caddyfile
Restart the Caddy service to apply the changes:
sudo systemctl restart caddy
3. Configure Firewall for Caddy on AlmaLinux 9
Assuming you have enabled firewalld, allow traffic on HTTP and HTTPS:
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
4. Access Caddy Web Server Page
Access the Caddy web server by entering your domain name or server’s IP address in your web browser:
http://server-ip-or-domain
You should see the Welcome test page.

Congratulations! You’ve successfully set up Caddy.
For further details, refer to the Caddy Documentation Page.
Conclusion
You have now successfully learned to Install Caddy Web Server on AlmaLinux 9. Caddy provides a modern, secure, and user-friendly alternative to traditional web servers. With its automatic HTTPS, simple configuration, and high performance, Caddy is an excellent choice for developers and system administrators seeking a streamlined web server setup. This article showed the process of Install Caddy Web Server on AlmaLinux 9.
We hope you found this guide helpful. Please follow us on Facebook, X, and YouTube.
You may also be interested in these articles:
Install Apache Web Server on AlmaLinux 9.
Install Nginx Web Server on AlmaLinux 9.
Alternative Solutions for Installing Caddy
While the Copr repository method is a straightforward way to install Caddy, here are two alternative methods for installing Caddy on AlmaLinux 9.
1. Using the Official Caddy Download Script:
Caddy provides a convenient shell script for downloading and installing the latest version directly from their website. This method offers more control over the installation process and allows you to easily specify plugins during installation.
Explanation:
This method involves downloading a script from Caddy’s website, making it executable, and then running it with optional arguments to specify the plugins you need. The script handles the download and installation of Caddy and its dependencies. This is an excellent choice if you need to customize your Caddy installation with specific plugins not available in the Copr repository.
Code Example:
First, download the Caddy download script:
curl -sS https://dl.caddyserver.com/api/v1/get/linux/amd64 -o caddy_install.sh
Make the script executable:
chmod +x caddy_install.sh
Install Caddy with desired plugins (e.g., http.filter
):
sudo ./caddy_install.sh install http.filter
This will install Caddy and the http.filter
plugin. Then, start and enable the Caddy service as mentioned in the original article.
2. Installing Caddy via Docker:
Docker provides a containerization platform that allows you to run applications in isolated environments. This approach is useful for maintaining consistent environments and simplifying deployment.
Explanation:
Using Docker to install Caddy involves pulling the official Caddy image from Docker Hub and running it as a container. Docker handles all the dependencies and ensures that Caddy runs in a consistent environment, regardless of the host system. This is particularly useful for complex setups or when you want to avoid conflicts with other applications on your server.
Code Example:
First, install Docker if you haven’t already:
sudo dnf install docker -y
sudo systemctl start docker
sudo systemctl enable docker
Pull the official Caddy Docker image:
sudo docker pull caddy:latest
Run Caddy in a Docker container, mapping ports 80 and 443 and mounting a volume for your Caddyfile:
sudo docker run -d --name caddy -p 80:80 -p 443:443 -v /path/to/your/Caddyfile:/etc/caddy/Caddyfile -v caddy_data:/data caddy:latest
Replace /path/to/your/Caddyfile
with the actual path to your Caddyfile.
These alternative methods provide flexibility depending on your specific requirements. Whether you need specific plugins or prefer a containerized solution, these options offer viable ways to Install Caddy Web Server on AlmaLinux 9.