In this guide, we’ll walk through installing Caddy on Ubuntu 24.04, configuring it to serve a basic web page, and making it accessible via your server’s IP address.
- A fast, modern, and secure web server with automatic HTTPS support, Caddy is a fantastic choice.
- Unlike traditional web servers like Nginx or Apache, Caddy is built with simplicity
- Simple, readable Caddyfile configuration
sudo apt update && sudo apt upgrade -y
Install required dependencies
sudo apt install -y debian-keyring debian-archive-keyring curl gnupg apt-transport-https
Now add the official Caddy GPG key and repository:
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
Update your package index and install Caddy
sudo apt update
sudo apt install caddy -y
Check the installation
caddy version
You should see something like: v2.7.x
Configure Caddy to Serve a Site via IP
Edit the main Caddyfile:-
sudo vim /etc/caddy/Caddyfile
Replace the contents with the following:
:80 {
root * /var/www/html
file_server
}
This tells Caddy to listen on 80 and serve files from /var/www/html
Create a Default Web Page
Create a basic index.html page:
sudo mkdir -p /var/www/html
echo '<h1>Welcome to Caddy on Ubuntu 24.04</h1>' | sudo tee /var/www/html/index.html
Set permissions
sudo chown -R www-data:www-data /var/www/html
Reload the configuration:
sudo systemctl reload caddy
Or restart completely:
sudo systemctl restart caddy
Test in Browser
Open your browser and visit:
http://IP_address
You should see:
Welcome to Caddy on Ubuntu 24.04
Your site is now being served from your IP address using Caddy.
Conclusion
Caddy is not just a simple web server,it’s a powerful platform capable of handling much more. From acting as a reverse proxy for applications built with Node.js, Django, or even Docker containers, to offering built-in load balancing and seamless PHP support via php-fpm, Caddy can easily scale with your needs. It also provides built-in logging and metrics, making it easier to monitor and optimize your deployments. Whether you’re serving static sites or managing dynamic web applications, Caddy delivers a modern, developer-friendly experience out of the box.
If you encounter any issues or need expert assistance to install Caddy on Ubuntu 24.04, our team of experienced professionals is here to help. Whether it’s configuring Caddy for production, setting up automatic HTTPS, or optimizing your web server environment, Skynats offers reliable Server Management Services and Web Server Optimization Services tailored to your needs.
Get in touch with us today and ensure a smooth, secure, and efficient deployment of your Caddy server.