Skip to content

Instantly share code, notes, and snippets.

@nshtg
Forked from Jamesits/caddy.sh
Last active June 23, 2017 08:41
Show Gist options
  • Save nshtg/0371c343efe7ad0bc0c75bb60d7bf7ac to your computer and use it in GitHub Desktop.
Save nshtg/0371c343efe7ad0bc0c75bb60d7bf7ac to your computer and use it in GitHub Desktop.
Install Caddy Server on Centos with Systemd.
useradd www-data --system || true
curl -L https://getcaddy.com | bash -s http.awslambda,http.cgi,http.cors,http.expires,http.filemanager,http.filter,http.git,http.hugo,http.ipfilter,http.jwt,http.mailout,http.minify,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.upload,dns,net,hook.service
chown root:root /usr/local/bin/caddy
chmod 755 /usr/local/bin/caddy
setcap 'cap_net_bind_service=+ep' /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
# if you run plugins which creates new process (e.g. hugo), 64 is not enough and causes server crash; see https://github.com/hacdias/caddy-hugo/issues/96
curl -L https://github.com/mholt/caddy/raw/master/dist/init/linux-systemd/caddy.service | sed "s/LimitNPROC=64/LimitNPROC=128/" | sed "s/Wants=network-online.target systemd-networkd-wait-online.service/Wants=network-online.target/" | 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment