How to Setup a Raspberry Pi Caddy Web Server

In this tutorial I will explain step by step how you can set up a Raspberry Pi Caddy web server, Caddy web server usually utilizes the modern web technologies such as HTTP2 and also automatically provisions SSL certificates for any domain name that you will setup it through, and it automatically grabs the certificate from “Let’s Encrypt” follow the below steps so you can guarantee a successful install of Caddy Web Server on Raspberry Pi.

Setting up Caddy on the Raspberry Pi

1. Run the below commands on the Raspian terminal to update the current package list to the latest version

sudo apt-get update

sudo apt-get upgrade

2. If you installed “apache2” on your raspberry it’s recommended to remove it, you can remove it from your system using the below command.

sudo apt-get remove apache2

3. Use the below command to download and install “Caddy”, the script you will download will detect your current operating system and download the correct package for it.

sudo curl | bash

4. After “Caddy” web server is downloaded and installed, create a folder so you can keep all of your configuration files on it, you can create the folder by using the below command.

sudo mkdir /etc/caddy

5. Create a new folder for your website and give it your website name instead of “AvoidErrors”.

sudo mkdir -p /var/www/avoiderrors

6. Edit the configuration file of “Caddy” by using the nano editor.

sudo nano /etc/caddy/Caddyfile

7. Add the lines below to the configuration file.

:80 localhost:80 {
  root /var/www/localhost

8. Create a sample of HTML file just to make sure that everything is well configured, use the below command to add any text to your main webpage of your project.

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

9. Once you open the editor, just type anything you want.

10. To run your Caddy server, run the below 2 commands on the terminal, and open your localhost webpage to make sure that you installed it correctly

cd /etc/caddy


After this tutorial you should be able to know how you can install Caddy web server on your Raspberry Pi.

Recommended For You

Leave a Reply

Your email address will not be published. Required fields are marked *