老狗VPS,稳如老狗!Caddy是一个支持HTTP/2的跨平台Web服务器,使用和配置都比较简单,与Apache或Nginx类似。本文将介绍下如何在Ubuntu服务器安装配置Caddy。
1、首先使用SSH工具登录到Ubuntu服务器,然后您可依次运行下面命令为服务器设置防火墙。
sudo apt update -y
sudo apt upgrade -y
sudo firewall-cmd –permanent –zone=public –add-service=http
sudo firewall-cmd –permanent –zone=public –add-service=https
sudo firewall-cmd –reload
2、给网站设置目录和测试页面
sudo mkdir -p /var/www/html/idcspytestcaddy.com
3、安装Caddy
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
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.listsudo apt update
sudo apt install caddy
4、配置Caddy文件
这里您打开配置文件,需要添加域名。
sudo nano /etc/caddy/caddyfile
idcspytestcaddy.com {
root * /var/www/html/idcspytestcaddy.com
file_server
}
5、运行下面命令,开启Caddy服务。
sudo systemctl start caddy
或者:
sudo systemctl reload caddy