Views: 223
1 0
Read Time:2 Minute, 32 Second

In this article, we will have explained the necessary steps to installing and configure the Caddy web server on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Caddy is a powerful, enterprise-ready, open-source web server with automatic HTTPS written in Go. Caddy includes modern features such as support for virtual hosts, minification of static files, and HTTP/2. Caddy is also the first web server that can obtain and renew SSL/TLS certificates automatically using Let’s Encrypt. Caddy support all popular platforms that are why it is available for Windows, macOS, Linux, BSD, Android, Solaris, 32-bit, x64, ARM, mips64, and more

Install Caddy Web Server on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Centos 8

sudo dnf install epel-release
sudo dnf update

centos 7

sudo yum install epel-release
sudo yum update

Step 2. Install Caddy Web Server on CentOS 8 system.

Now install Candy using the following command:

centos 8

sudo dnf install 'dnf-command(copr)'
sudo dnf copr enable @caddy/caddy
sudo dnf install caddy

centos 7

yum install yum-plugin-copr
yum copr enable @caddy/caddy
yum install caddy

Step 3. Configuring Firewall.

Allow HTTP and HTTPS ports:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

In case your firewall is not running then simply type:

centos 8

sudo systemctl enable firewall-cmd
sudo systemctl start firewall-cmd

centos 7

sudo systemctl enable firewall-cmd
sudo systemctl start firewall-cmd

Step 4. Create a Demo web page to test the Caddy web server.

Set up a document root for your website. A document root is a directory where your website files are stored:

sudo mkdir -p /var/www/your-domain.com/html
sudo mkdir /var/log/caddy

Set the ownership of the directory to Caddy:

sudo chown caddy:caddy /var/www/your-domain.com/html -R
sudo chown caddy:caddy /var/log/caddy

Next, create an HTML file to test:

Add the following line:

<!DOCTYPE html>
<html>
<head>
<title>Hello from Linuxtips!</title>
</head>
<body>
<h1>Hello, from Linuxtips!</h1>
</body>
</html>

Then, restart Caddy to enable the configuration:

sudo systemctl restart caddy

Step 5. Accessing Caddy Web Server.

After successfully configured, now open in your browser, and you should see the following page which means, the configuration is working.

https://linuxtips.in

That’s all you need to do to install Caddy on CentOS 8. I hope you find this quick tip helpful. For further reading on the Caddy web server, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.