Caddy web server (known simply as Caddy), is an open source, HTTP/2-enabled web server written in Go. It uses the Go standard library for its HTTP functionality.

One of Caddy's most notable features is enabling HTTPS by default. Caddy is simple enough to be used as a quick development server and robust enough to be used in production environments.

In this guide, we will explain how to install Caddy on a CentOS 7 server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Next, enable the EPEL repository:

sudo yum install epel-release

Step 1: Install Caddy
Type the following command to install Caddy from the EPEL repository.

sudo yum install caddy

Step 2: Add Web Content
Caddy requires that you set up a home directory i.e web root, for your website. Type the following command to create a directory with the name of your website. In this guide, we'll be setting up CloudwaferLabs

sudo mkdir -p /var/www/cloudwaferlabs

Next, we need to create a test page in our newly created directory. Type the command below to create and edit the test page:

sudo nano /var/www/cloudwaferlabs/index.html

nigerian cloud hosting

Add the following content to the index page:

 <!doctype html>
 <head>
 <title>Caddy Test Page</title>
 </head>
 <body>
 <h1>Hello, World! Welcome to Cloudwaferlabs</h1>   
 </body>
 </html>

nigerian cloud hosting caddy linux

Lastly, it is important that we restore the correct selinux labels on the web root with the command below:

sudo restorecon -r /var/www/cloudwaferlabs

Step 3: Configure the Caddyfile
Next, we add our hostname and Webroot to the Caddy configuration.

sudo nano /etc/caddy/conf.d/cloudwaferlabs.conf

Type the following in the file created replacing cloudwaferlabs.com.ng with your domain name.

cloudwaferlabs.com.ng {
root /var/www/cloudwaferlabs
}

nigerian cloud hosting ubuntu

Step 4: Enable the Caddy Service
The final step is to enable the Caddy service using the command below:

sudo systemctl enable --now caddy.service

Proceed to restart Caddy using the command below:

sudo systemctl restart caddy

nigerian cloud hosting debian

After configurations, type your domain name into a browser window and you would be able to access the website we just created as shown in the screenshot below:

nigerian cloud hosting linux centos

**If you see a 404 error, then Caddy is working but the root of your site is missing an index file.

You can read more on Caddy here.