Web server

Commands for installing the Caddy Web server on AlmaLinux 8

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

Although Caddy is not popular like 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 service, reverse proxy, Kubernetes entry, 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 HTTP / 3 experimental, scalability, HTTPS support per box; Dynamic configuration, low memory consumption, no dependency; Modular stack, Caddy’s REST API makes automation easy; due to the Go – Caddy language is a multiplatform web server which can run under Windows, macOS, Linux, BSD, Android, Solaris, 32 bit, amd64, ARM, aarch64, mips64… Its functionality can be extended with plugins.

Steps to install Caddy on Almalinux or Rocky Linux 8 server

The given steps and commands will also work for other RHEL or RPM based Linux operating systems 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, Internet connection.

1. Run the DNF update

If you are using a new server, or if you have not 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 a Fedora managed repository called Copr. It hosts over 17,000 projects and is intended to automatically deliver installation packages for those projects to Fedora and other Linux RPM users whenever users call them up. However, before that, we need to add it manually to our system using the given command.

sudo dnf install 'dnf-command(copr)'

3. Activate the Caddy server repository

Now, activate which package repository you want to activate, this is Caddy.

sudo dnf copr enable @caddy/caddy

Run the system update again

sudo dnf update

Activate the 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 like HTTPd or any other application from the command terminal.

sudo dnf install caddy

5. Start and activate the Caddy service

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

To start:

sudo systemctl start caddy

To allow, so that it can start automatically:

sudo systemctl enable caddy

Check condition:

systemctl status caddy

Start the Caddy Web Server Services on Linux

6. Open ports 80 and 443 in the firewall

If you are using the built-in firewall from Almalinux, Rocky, or any other RHEL based system, use the given command to open ports 80/443. However, those that are in 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 generating 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 on which you are running Caddy.



To note: server-ip should be replaced with the actual address of your server which can be found using the command ip a Likewise, if you have 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 any web page server you want.

Learn more abouthttps://caddyserver.com/docs/caddyfile

Other articles:

• How to install MariaDB 10 on AlmaLinux 8 or Rocky Linux
• How to install WordPress on AlmaLinux 8 | Rocky linux 8
• Install the Gnome graphical interface on Almalinux or Rocky Linux 8