沉冰浮水

沉冰浮水

做最终到的事,成为最终成为的人!
github
bilibili
mastodon
zhihu
douban

"Getting Started" Caddy Easy Tutorial

Introduction#

I have a really crappy VPS that can't install Docker, and LNMP feels hopeless too, so I decided to install Caddy and play around with hugo or hexo.

The environment is Ubuntu 18.04, connected remotely using VSCode.

All the installation script links in various Chinese tutorials are broken, and the configuration instructions are even worse than Z-BlogPHP's documentation.

As expected, I had to refer to the official English documentation: https://caddyserver.com/docs/.

blog.wdssmq.com ← It actually opened while I was writing this tutorial. I tested it with hugo and it automatically configures SSL, which is pretty cool.

"AD: Various VPS recommendations"

Installation#

curl -sS https://webinstall.dev/caddy | bash

Install — Caddy Documentation

https://caddyserver.com/docs/install

Hello Caddy#

cd ~
mkdir caddy
# code is the command to edit files within VSCode;
code ~/caddy/Caddyfile

Enter:

:8080
respond "Hello, world!"
# caddy command needs to be executed in the same directory, unless the Caddyfile path is specified;
cd ~/caddy
# use adppt to update after modifying Caddyfile
caddy adapt
# start the service
caddy run

Running in the Background#

# run in the background
caddy start
# restart, adapt will be executed automatically
caddy reload
# stop
caddy stop

Caddyfile Configuration#

After modification, caddy reload is required;

Create an index.html in the same directory as the Caddyfile, and modify the content of the configuration file:

:8080
file_server
# file_server browse # display files in the folder when index file does not exist

Specify the root directory and domain name, etc.;

blog.wdssmq.com
root * /root/wwwroot/blog.wdssmq.com/public
encode zstd gzip
file_server

Enable multiple service listeners;

localhost can also be replaced with a specific domain name;

After that, write the root, file_server, and other attributes inside curly braces;

localhost {
	respond "Hello, world!"
}
localhost:2016 {
	respond "Goodbye, world!"
}

file_server (Caddyfile directive) — Caddy Documentation:

https://caddyserver.com/docs/caddyfile/directives/file_server

Caddyfile Tutorial — Caddy Documentation:

https://caddyserver.com/docs/caddyfile-tutorial

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.