Commands to install the Caddy web server on AlmaLinux 8

Caddy is an HTTP web server, under open-source license, written in GO language. Here we will learn how to install Caddy Server on RHEL based AlmaLinux or Rocky Linux 8 using command line (terminal) on VPS, cloud or local machines.

Although Caddy is not as popular as Apache or Nginx, yet it is a powerful web server ready to meet business needs. It is modular and can be used for static file serving, reverse proxy, Kubernetes ingress, etc. Additionally, Caddy can automatically retrieve and renew TLS certificates for the website you are running.

Here are some of its offerings, caddy supports HTTP/1.1, HTTP/2 and experimental HTTP/3, scalability, HTTPS support out of the box; Dynamic configuration, low memory consumption, no dependency; Modular Stack, Caddy’s REST API makes automation easy; thanks to the Go language – Caddy is a cross-platform web server that can run on Windows, macOS, Linux, BSD, Android, Solaris, 32-bit, amd64, ARM, aarch64, mips64… Its functionality can be extended with plugins.

Steps to install Caddy in Almalinux or Rocky Linux 8 server

The given steps and commands will also work for other RHEL or RPM based Linux OS such as CentOS/RedHat 8/Oracle Linux…

What do you need to complete this guide?

A user with sudo access
Almalinux or Rocky
Of course, the Internet connection.

1. Run DNF Update

If you are using a new server or if you haven’t updated your server for a while, run the system update command first. This will rebuild the DNF repository cache.

sudo dnf update

2. Install the Copr repository on Almalinux or Rocky 8

Unlike Apache or Nginx, the packages we needed to install the Web Caddy Server are not available through the default base repository of Almalinux 8 or Rocky Linux. Therefore, we need to add the repository maintained by Fedora called Copr. It hosts over 17,000 projects and is intended to automatically provide installation packages for these projects to Fedora and other Linux RPM users whenever users request them. However, before that, we have to manually add it to our system using the given command.

sudo dnf install 'dnf-command(copr)'

3. Enable Caddy Server Repository

Now, activate which package repository you want to enable, here it is Caddy.

sudo dnf copr enable @caddy/caddy

Run the system update again

sudo dnf update

Enable Caddy Repository

4. Command to install Caddy on Rocky or AlmaLinux 8

Finally, we can use the DNF package manager to install the Caddy web server, just like HTTPd or any other application from the command terminal.

sudo dnf install caddy

5. Start and activate the Caddy service

After the installation is complete, the caddy server service may not work on your system by default. Therefore, start it and activate it manually. And to confirm use the status command:

To start:

sudo systemctl start caddy

To allowso that it can start automatically:

sudo systemctl enable caddy

Check status:

systemctl status caddy

Start Caddy Web Server Services on Linux

6. Open ports 80 and 443 in the firewall

If you are using built-in firewall Almalinux, Rocky or any other RHEL based system then use the given command to open ports 80/443. However, those on the cloud such as Google, AWS, etc. must allow public access to these ports or HTTP/HTTPS in their service provider’s firewall.

For port 80 or HTTP

sudo firewall-cmd --permanent --add-service=http

For port 443 or HTTPS:

sudo firewall-cmd --permanent --add-service=https

Reload the system firewall:

sudo systemctl reload firewalld

7. Access the web server demo page

To confirm that the server is operational to serve our web pages without throwing an error, let’s access it using the web browser. On your system, open the browser and enter this ip-address or the domain name of the server you are running Caddy on.

Example:

http://server-ip
Where
http://example.com

To note: server-ip should be replaced with the actual address of your server which can be found using the command ip a Similarly, if you transferred a domain to your server, you can also access the Caddy using it.

To modify the Caddy host configuration file:

sudo nano /etc/caddy/Caddyfile

You can change the root path to host any web pages you want.

Learn more about – https://caddyserver.com/docs/caddyfile

Other Items:

• How to install MariaDB 10 on AlmaLinux 8 or Rocky Linux
• How to install WordPress on AlmaLinux 8 | Rocky Linux 8
• Install Gnome GUI on Almalinux or Rocky Linux 8