How to Install Caddy Web Server on Ubuntu 24.04
Caddy is a powerful, user-friendly web server known for its ease of use, automatic HTTPS, and simple configuration. It's a great choice for developers looking to quickly and securely deploy web applications.
Prerequisites
-
An Ubuntu 24.04 VPS
- SSH root access or a user with sudo privileges
Update the System
Before beginning any installation, it's a good practice to update your system's package index and upgrade the installed packages to the latest versions. This ensures you have the most recent updates and security patches,
apt update && apt upgrade -y
Install Dependencies
Before installing Caddy, we need to install some necessary dependencies that help in managing packages and secure communications. Run the following command to install these dependencies,
apt install gnupg curl apt-transport-https debian-keyring debian-archive-keyring -y
Add the Caddy Repository
Import the Caddy GPG Key
To ensure the integrity and authenticity of the Caddy packages, add the official GPG key,
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
Output:
root@vps:~# curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
Add the Caddy Repository to Your Sources List
Next, add the Caddy repository to your list of package sources so that you can install Caddy directly from it:
wget -qO - https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt | sudo tee /etc/apt/sources.list.d/caddy.list
Output:
root@vps:~# wget -qO - https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt | sudo tee /etc/apt/sources.list.d/caddy.list
# Source: Caddy
# Site: https://github.com/caddyserver/caddy
# Repository: Caddy / stable
# Description: Fast, multi-platform web server with automatic HTTPS
Update the Package Index
After adding the repository, refresh the package index to include the new Caddy repository,
apt update
Output:
root@vps:~# apt install caddy -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
caddy
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Install Caddy
With the repository added and the package index updated, install Caddy using the following command,
apt install caddy -y
Verify Caddy Installation
Caddy starts automatically after installation. To check its status and ensure itβs running properly, use,
systemctl status caddy
Output:
root@vps:~# systemctl status caddy
β caddy.service - Caddy
Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-05-30 17:05:46 UTC; 6s ago
Docs: https://caddyserver.com/docs/
Main PID: 51986 (caddy)
Tasks: 7 (limit: 4558)
Memory: 10.9M
CPU: 51ms
CGroup: /system.slice/caddy.service
ββ51986 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
Access the Caddy Web Interface
To confirm that Caddy is running, open your web browser and navigate to,
http://YOUR_SERVER_IP_ADDRESS
If Caddy is running correctly, you should see the Caddy welcome page like below,
Done, This guide has covered the essential steps to get Caddy up and running, from updating your system to accessing the Caddy web interface. Enjoy the powerful features of Caddy for your web server needs!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS