首页 小组 文章 搜索 用户

centos7和centos8的yum下安装Caddy

2020-02-03 20:22:09
0
510

centos下安装caddy

Fedora or RHEL/CentOS 8:

dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy
systemctl enable caddy
systemctl start caddy

RHEL/CentOS 7:

yum install yum-plugin-copr
yum copr enable @caddy/caddy
yum install caddy
systemctl enable caddy
systemctl start caddy

编辑/etc/caddy/Caddyfile文件,设置站点配置文件

echo 'import ./vhosts/*' > /etc/caddy/Caddyfile
mkdir -p /etc/caddy/vhosts

设置路径的访问权限

chown -R caddy:caddy /etc/caddy

创建用于存放ssl证书的路径

mkdir /etc/ssl/caddy
chown -R root:caddy /etc/ssl/caddy
chmod 0770 /etc/ssl/caddy

创建用于存放日志的路径

mkdir /var/log/caddy
chown -R caddy:root /var/log/caddy

创建网页存放目录

mkdir -p /home/www
chown caddy:caddy /home/www

配置网站信息

网站配置参数信息文件是/etc/caddy/Caddyfile

vi /etc/caddy/vhosts/os.me

输入以下代码

www.osyum.com   #把这改成你网站的域名
{
  log /var/log/caddy/caddy.log
  tls 111111111111@qq.com     #把这里改成你的邮箱地址
  root /home/www
  gzip
}

有了这些配置参数信息以后就可以启动caddy服务了,初次启动会自动申请免费证书

nohup caddy -conf=/etc/caddy/Caddyfile -agree >> /tmp/caddy.log 2>&1 &

完成

评论