-
-
Save kristian-lange/c5a7e0ed5a01b7fd726f873f81b585a5 to your computer and use it in GitHub Desktop.
Install Caddy Server on Ubuntu with Systemd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This shell script installs and starts Caddy (https://caddyserver.com/) on Debian based distros. | |
# It uses Caddy's personal license (https://caddyserver.com/products/licenses). | |
# This script is a fork from https://gist.github.com/Jamesits/2a1e2677ddba31fae62d022ef8aa54dc. | |
# It will by default install all plugins; you can customize this behavior on line 7. | |
apt update | |
apt install curl | |
curl https://getcaddy.com | bash -s personal | |
chown root:root /usr/local/bin/caddy | |
chmod 755 /usr/local/bin/caddy | |
setcap 'cap_net_bind_service=+eip' /usr/local/bin/caddy | |
mkdir -p /etc/caddy | |
chown -R root:www-data /etc/caddy | |
mkdir -p /etc/ssl/caddy | |
chown -R www-data:root /etc/ssl/caddy | |
chmod 770 /etc/ssl/caddy | |
touch /etc/caddy/Caddyfile | |
mkdir -p /var/www | |
chown www-data:www-data /var/www | |
chmod 755 /var/www | |
curl -L https://github.com/mholt/caddy/raw/master/dist/init/linux-systemd/caddy.service | sed "s/;CapabilityBoundingSet/CapabilityBoundingSet/" | sed "s/;AmbientCapabilities/AmbientCapabilities/" | sed "s/;NoNewPrivileges/NoNewPrivileges/" | tee /etc/systemd/system/caddy.service | |
chown root:root /etc/systemd/system/caddy.service | |
chmod 744 /etc/systemd/system/caddy.service | |
systemctl daemon-reload | |
systemctl enable caddy.service | |
systemctl start caddy.service | |
# if you need QUIC protocol: | |
# 1. edit /etc/systemd/system/caddy.service, write " -quic" (without quotes) to the end of the line ExecStart | |
# 2. systemctl daemon-reload | |
# 3. systemctl restart caddy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment