How to Install Caddy on Ubuntu
In our blog post, we will be walking you through to install Caddy, before getting deep into installation steps. Let’s know what Caddy is, Caddy is a web server like Apache or Nginx that is used serving content, one of the interesting and main features of why Caddy is popular is it’s the only Web server which comes with HTTPS by default and automatically.
Steps to Install Caddy
1) Setup firewall to server http and https traffic:
sudo apt update -y
sudo apt upgrade -y
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
2) Setup Directory and a test page for your website to serve content:
sudo mkdir -p /var/www/html/racknerdtestcaddy.com
echo ‘<!doctype html><head><title>Racknerd Caddy Testing Page</title></head><body><h1>Welcome to Caddy Webserver, World!</h1></body></html>’ > /var/www/html/racknerdtestcaddy.com/index.html
3) Install Caddy
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/gpg.key’ | sudo gpg –dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt’ | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
4) Configure Caddy File
Here you need to add your domain name:
sudo nano /etc/caddy/caddyfile
racknerdtestcaddy.com {
root * /var/www/html/racknerdtestcaddy.com
file_server
}
5) Start and very Caddy Service Status
sudo systemctl start caddy
or
sudo systemctl reload caddy
Thanks for reading through this tutorial. Feel free to place an order and grab our offers and test your service.