mirror of
https://github.com/caddyserver/website.git
synced 2025-05-07 12:17:15 -04:00
Updates to make the page more generalized
Docker
This commit is contained in:
parent
33f8923aff
commit
59468700fa
5 changed files with 113 additions and 69 deletions
|
@ -311,7 +311,7 @@ Same as [`caddy run`](#caddy-run), but in the background. This command only bloc
|
|||
|
||||
Note: the flag `--config` doesn't support `-` to read the config from stdin.
|
||||
|
||||
Use of this command is discouraged with system services or on Windows. On Windows, the child process will remain attached to the terminal, so closing the window will forcefully stop Caddy, which is not obvious.
|
||||
Use of this command is discouraged with system services or on Windows. On Windows, the child process will remain attached to the terminal, so closing the window will forcefully stop Caddy, which is not obvious. Consider running Caddy [as a service](/docs/running) instead.
|
||||
|
||||
Once started, you can use [`caddy stop`](#caddy-stop) or [the /stop API endpoint](/docs/api#post-stop) to exit the background process.
|
||||
|
||||
|
|
|
@ -28,12 +28,11 @@ This page describes various methods for installing Caddy on your system.
|
|||
- [Ansible](#ansible)
|
||||
- [Scoop](#scoop)
|
||||
- [Termux](#termux)
|
||||
- [Windows service](#windows-service)
|
||||
|
||||
|
||||
## Static binaries
|
||||
|
||||
Simply downloading a Caddy binary does not [install it as a service](/docs/service#manual-installation), but can be useful in dev or when upgrading an existing installation.
|
||||
Simply downloading a Caddy binary does not [install it as a service](/docs/running#manual-installation), but can be useful in dev or when upgrading an existing installation.
|
||||
|
||||
- [**View releases on GitHub**](https://github.com/caddyserver/caddy/releases) (expand "Assets")
|
||||
- [**Use our download page**](/download)
|
||||
|
@ -41,7 +40,7 @@ Simply downloading a Caddy binary does not [install it as a service](/docs/servi
|
|||
|
||||
## Debian, Ubuntu, Raspbian
|
||||
|
||||
Installing this package automatically starts and runs Caddy as a [systemd service](/docs/service) named `caddy`, and also comes with a `caddy-api` service which is _not_ enabled by default, should you need it.
|
||||
Installing this package automatically starts and runs Caddy as a [systemd service](/docs/running#linux-service) named `caddy`, and also comes with a `caddy-api` service which is _not_ enabled by default, should you need it.
|
||||
|
||||
Stable releases:
|
||||
|
||||
|
@ -66,7 +65,7 @@ If you wish to use the packaged support files (systemd services, bash completion
|
|||
|
||||
## Fedora, RedHat, CentOS
|
||||
|
||||
This package comes with both of Caddy's [systemd service](/docs/service) unit files, but does not enable them by default.
|
||||
This package comes with both of Caddy's [systemd service](/docs/running#linux-service) unit files, but does not enable them by default.
|
||||
|
||||
Fedora or RHEL/CentOS 8:
|
||||
|
||||
|
@ -85,7 +84,7 @@ RHEL/CentOS 7:
|
|||
|
||||
## Arch Linux, Manjaro, Parabola
|
||||
|
||||
This package comes with both of Caddy's [systemd service](/docs/service) unit files, but does not enable them by default.
|
||||
This package comes with both of Caddy's [systemd service](/docs/running#linux-service) unit files, but does not enable them by default.
|
||||
|
||||
<pre><code class="cmd"><span class="bash">pacman -Syu caddy</span></code></pre>
|
||||
|
||||
|
@ -103,7 +102,7 @@ This package comes with both of Caddy's [systemd service](/docs/service) unit fi
|
|||
|
||||
[**Deploy a Caddy droplet on DigitalOcean**](https://marketplace.digitalocean.com/apps/caddy)
|
||||
|
||||
The droplet is preconfigured to run Caddy as a [systemd service](/docs/service) via being installed with the [`apt` repo](#debian-ubuntu-raspbian).
|
||||
The droplet is preconfigured to run Caddy as a [systemd service](/docs/running#linux-service) via being installed with the [`apt` repo](#debian-ubuntu-raspbian).
|
||||
|
||||
|
||||
## Homebrew
|
||||
|
@ -167,51 +166,3 @@ _Note: This is a community-maintained installation method._
|
|||
|
||||
[**View the Termux build.sh file**](https://github.com/termux/termux-packages/blob/master/packages/caddy/build.sh)
|
||||
|
||||
|
||||
## Windows service
|
||||
|
||||
_Note: This is a community-maintained installation method._
|
||||
|
||||
Install Caddy as a service on Windows with these instructions.
|
||||
|
||||
**Requirements:**
|
||||
|
||||
- `caddy.exe` binary that you [downloaded](/download) or [built from source](/docs/build)
|
||||
- Any exe from the latest release of the
|
||||
[WinSW](https://github.com/winsw/winsw/releases/latest) service wrapper (Stay
|
||||
on a v2.x release for now)
|
||||
|
||||
Put all files into a service directory. In the following examples, we use `c:\caddy`.
|
||||
|
||||
Rename the WinSW exe file to `caddy-service.exe`.
|
||||
|
||||
Add a `caddy-service.xml` in the directory:
|
||||
|
||||
<pre><code class="cmd"><service>
|
||||
<id>caddy</id>
|
||||
<!-- Display name of the service -->
|
||||
<name>Caddy Web Server (powered by WinSW)</name>
|
||||
<!-- Service description -->
|
||||
<description>Caddy Web Server (https://caddyserver.com/)</description>
|
||||
<executable>%BASE%\caddy.exe</executable>
|
||||
<arguments>run</arguments>
|
||||
<log mode="roll-by-time">
|
||||
<pattern>yyyy-MM-dd</pattern>
|
||||
</log>
|
||||
</service>
|
||||
</code></pre>
|
||||
|
||||
You can now install the service using:
|
||||
<pre><code class="cmd">caddy-service install</code></pre>
|
||||
|
||||
You might want to start the Windows Services Console to see if the service is runnnig correctly:
|
||||
<pre><code class="cmd">services.msc</code></pre>
|
||||
|
||||
Be aware that Windows services cannot be reloaded, so you have to tell caddy directly to relaod:
|
||||
<pre><code class="cmd">caddy reload</code></pre>
|
||||
|
||||
Restarting is possible via the normal Windows services commands.
|
||||
|
||||
For customizing the service wrapper, see the [WinSW documentation](https://github.com/winsw/winsw/tree/master#usage)
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
---
|
||||
title: Linux Service
|
||||
title: Keep Caddy Running
|
||||
---
|
||||
|
||||
Linux Service
|
||||
=============
|
||||
# Keep Caddy Running
|
||||
|
||||
The recommended way to run Caddy on Linux distributions with systemd is with our official systemd unit files.
|
||||
While Caddy can be run successfully by directly using its [Command Line Interface](/docs/command-line), there are numerous advantages to using a service manager to keep it running, such as ensuring it starts back up when the system boots, and to capture stdout/stderr logging.
|
||||
|
||||
|
||||
- [Linux Service](#linux-service)
|
||||
- [Unit Files](#unit-files)
|
||||
- [Using the Service](#using-the-service)
|
||||
- [Manual Installation](#manual-installation)
|
||||
- [Overrides](#overrides)
|
||||
- [Windows Service](#windows-service)
|
||||
- [Docker Compose](#docker-compose)
|
||||
|
||||
|
||||
## Unit Files
|
||||
## Linux Service
|
||||
|
||||
The recommended way to run Caddy on Linux distributions with systemd is with our official systemd unit files.
|
||||
|
||||
|
||||
### Unit Files
|
||||
|
||||
We provide two different systemd unit files that you can choose between, depending on your usecase:
|
||||
|
||||
|
@ -28,7 +36,7 @@ If you need to switch between the services, you should disable and stop the prev
|
|||
<span class="bash">sudo systemctl enable --now caddy-api</span></code></pre>
|
||||
|
||||
|
||||
## Using the Service
|
||||
### Using the Service
|
||||
|
||||
To verify that the service is running:
|
||||
<pre><code class="cmd bash">systemctl status caddy</code></pre>
|
||||
|
@ -48,7 +56,7 @@ You can stop the service with:
|
|||
</aside>
|
||||
|
||||
|
||||
## Manual Installation
|
||||
### Manual Installation
|
||||
|
||||
Some [installation methods](/docs/install) automatically set up Caddy to run as a service. If you chose a method that did not, you may follow these instructions to do so:
|
||||
|
||||
|
@ -95,7 +103,7 @@ Verify that it is running:
|
|||
Now you're ready to [use the service](#using-the-service)!
|
||||
|
||||
|
||||
## Overrides
|
||||
### Overrides
|
||||
|
||||
The best way to override aspects of the service files is with this command:
|
||||
<pre><code class="cmd bash">sudo systemctl edit caddy</code></pre>
|
||||
|
@ -119,3 +127,88 @@ ExecReload=/usr/bin/caddy reload --config /etc/caddy/caddy.json
|
|||
|
||||
Then, save the file and exit the text editor, and restart the service for it to take effect:
|
||||
<pre><code class="cmd bash">sudo systemctl restart caddy</code></pre>
|
||||
|
||||
|
||||
## Windows service
|
||||
|
||||
Install Caddy as a service on Windows with these instructions.
|
||||
|
||||
**Requirements:**
|
||||
|
||||
- `caddy.exe` binary that you [downloaded](/download) or [built from source](/docs/build)
|
||||
- Any exe from the latest release of the
|
||||
[WinSW](https://github.com/winsw/winsw/releases/latest) service wrapper (Stay
|
||||
on a v2.x release for now)
|
||||
|
||||
Put all files into a service directory. In the following examples, we use `c:\caddy`.
|
||||
|
||||
Rename the WinSW exe file to `caddy-service.exe`.
|
||||
|
||||
Add a `caddy-service.xml` in the directory:
|
||||
|
||||
<pre><code class="cmd"><service>
|
||||
<id>caddy</id>
|
||||
<!-- Display name of the service -->
|
||||
<name>Caddy Web Server (powered by WinSW)</name>
|
||||
<!-- Service description -->
|
||||
<description>Caddy Web Server (https://caddyserver.com/)</description>
|
||||
<executable>%BASE%\caddy.exe</executable>
|
||||
<arguments>run</arguments>
|
||||
<log mode="roll-by-time">
|
||||
<pattern>yyyy-MM-dd</pattern>
|
||||
</log>
|
||||
</service>
|
||||
</code></pre>
|
||||
|
||||
You can now install the service using:
|
||||
<pre><code class="cmd">caddy-service install</code></pre>
|
||||
|
||||
You might want to start the Windows Services Console to see if the service is runnnig correctly:
|
||||
<pre><code class="cmd">services.msc</code></pre>
|
||||
|
||||
Be aware that Windows services cannot be reloaded, so you have to tell caddy directly to relaod:
|
||||
<pre><code class="cmd">caddy reload</code></pre>
|
||||
|
||||
Restarting is possible via the normal Windows services commands.
|
||||
|
||||
For customizing the service wrapper, see the [WinSW documentation](https://github.com/winsw/winsw/tree/master#usage)
|
||||
|
||||
|
||||
## Docker Compose
|
||||
|
||||
The simplest way to get up and running with Docker is to use Docker Compose. _The below is only an excerpt, see the docs on [Docker Hub](https://hub.docker.com/_/caddy) for more details_.
|
||||
|
||||
First, create a file `docker-compose.yml` (or add this service to your existing file):
|
||||
|
||||
```yaml
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
caddy:
|
||||
image: caddy:<version>
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- $PWD/Caddyfile:/etc/caddy/Caddyfile
|
||||
- $PWD/site:/srv
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
|
||||
volumes:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
```
|
||||
|
||||
Make sure to fill in `<version>` with the latest version number, which you can find listed on [Docker Hub](https://hub.docker.com/_/caddy) under the "Tags" section.
|
||||
|
||||
Then, you can start the container:
|
||||
<pre><code class="cmd bash">docker-compose up -d</code></pre>
|
||||
|
||||
To reload Caddy after making changes to your Caddyfile:
|
||||
<pre><code class="cmd bash">docker-compose exec -w /etc/caddy caddy caddy reload</code></pre>
|
||||
|
||||
To see Caddy's logs:
|
||||
<pre><code class="cmd bash">docker-compose logs caddy</code></pre>
|
||||
|
|
@ -373,7 +373,7 @@ Most sites will not need this directive at all.
|
|||
|
||||
## Service files
|
||||
|
||||
We recommend using [one of our official systemd service files](/docs/service) for Caddy deployments.
|
||||
We recommend using [one of our official systemd service files](/docs/running#linux-service) for Caddy deployments.
|
||||
|
||||
If you need a custom service file, base it off of ours. They've been carefully tuned to what it is for good reasons! Be sure to customize yours if needed.
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<li><a href="/docs/logging">How Logging Works</a></li>
|
||||
<li><a href="/docs/metrics">Monitoring Caddy</a></li>
|
||||
<li><a href="/docs/architecture">Caddy Architecture</a></li>
|
||||
<li><a href="/docs/service">Linux Service</a></li>
|
||||
<li><a href="/docs/running">Keep Caddy Running</a></li>
|
||||
|
||||
<li class="heading">Developers</li>
|
||||
<li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue