How To Install Caddy Web Server on Ubuntu 16.04 LTS

Install Caddy Web Server on Ubuntu 16.04 LTS

In this tutorial, we will show you how to install Caddy Web Server on Ubuntu 16.04 LTS. For those of you who didn’t know, For those of you who didn’t know, Caddy is a modern, general-purpose, multi-platform web server that supports Virtual hosting, HTTP/2, IPv6, Markdown, WebSockets, FastCGI, automatic HTTPS via Let’s Encrypt, templates, and more.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Caddy Web Server on a Ubuntu 16.04 Xenial Xerus server.


  • A server running one of the following operating systems: Ubuntu 16.04 (Xenial Xerus)
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Caddy Web Server on Ubuntu 16.04 LTS

Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing Caddy Web Server.

Install Caddy is quick and easy with run the following command:

curl | bash

Once the installation is completed, we need to add the cap_net_bind_servicecapability to the Caddy binary:

sudo setcap cap_net_bind_service=+ep /usr/local/bin/caddy

Step 3. Setting Up Necessary Directories.

Next, create the directories where we will store the Caddy configuration file Caddyfile and SSL certificates:

sudo mkdir /etc/caddy
sudo chown -R root:www-data /etc/caddy
sudo mkdir /etc/ssl/caddy
sudo chown -R www-data:root /etc/ssl/caddy
sudo chmod 0770 /etc/ssl/caddy
sudo touch /etc/caddy/Caddyfile
sudo mkdir /var/www
sudo chown www-data: /var/www

Step 4. Installing Caddy as a System Service.

We also need to create a new SystemD configuration script:

nano /lib/systemd/system/caddy.service

Add the following line:

Description=Caddy HTTP/2 web server


; Letsencrypt-issued certificates will be written to this directory.

ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID



; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy. Uncomment if you like.
; Note that you may have to add capabilities required by any plugins in use.

Execute the following commands to enable Caddy to run on boot:

systemctl enable caddy.service
systemctl restart caddy.service

Step 5. Creating Test Web Page and a Caddyfile.

For testing purposes, we will create a test HTML file:

mkdir -p /var/www/
echo "Caddy" > /var/www/
chown -R www-data: /var/www/

Next, add our domain to the Caddy configuration file:

nano /etc/caddy/Caddyfile

Add the following line: {
    root /var/www/

Save the file and exit the editor. To apply the changes, restart Caddy:

systemctl restart caddy.service

Now, with a web browser, just go to, and you will see our test page!

Congratulations! You have successfully installed Caddy. Thanks for using this tutorial for installing the Caddy web server in Ubuntu 16.04 Xenial Xerus system. For additional help or useful information, we recommend you to check the official Caddy web server website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!




r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button