From e287e61df6bf2bb36fec705b9c50cec1aca778a7 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Sun, 17 May 2020 15:51:26 -0400 Subject: [PATCH] docs: Cross-link the `root` directive with file_server/php_fastcgi --- .../markdown/caddyfile/directives/file_server.md | 9 ++++++++- .../markdown/caddyfile/directives/php_fastcgi.md | 7 +++++++ src/docs/markdown/caddyfile/directives/root.md | 15 +++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/docs/markdown/caddyfile/directives/file_server.md b/src/docs/markdown/caddyfile/directives/file_server.md index 7cc95ec..7472bcf 100644 --- a/src/docs/markdown/caddyfile/directives/file_server.md +++ b/src/docs/markdown/caddyfile/directives/file_server.md @@ -19,7 +19,7 @@ file_server [] [browse] { ``` - **browse** enables file listings for requests to directories that do not have an index file. -- **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: When specified as a subdirective like this, only this directive will know this root; for other directives (like [try_files](/docs/caddyfile/directives/try_files) or [templates](/docs/caddyfile/directives/templates)) to know the same site root, use the [root](/docs/caddyfile/directives/root) directive, not subdirective. +- **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: When specified as a subdirective like this, only this directive will know this root; for other directives (like [`try_files`](/docs/caddyfile/directives/try_files) or [`templates`](/docs/caddyfile/directives/templates)) to know the same site root, use the [`root`](/docs/caddyfile/directives/root) directive, not subdirective. - **hide** is a list of files to hide; if requested, the file server will pretend they do not exist. The active configuration file will be added by default. - **index** is a list of filenames to look for as index files. Default: `index.html index.txt` - **** is an optional custom template file to use for directory listings. @@ -44,3 +44,10 @@ Only serve static files out of the `/static` folder: ```caddy-d file_server /static/* ``` + +The `file_server` directive is usually paired with the [`root`](/docs/caddyfile/directives/root) directive to set the root path from which to serve files + +```caddy-d +root * /home/user/public_html +file_server +``` \ No newline at end of file diff --git a/src/docs/markdown/caddyfile/directives/php_fastcgi.md b/src/docs/markdown/caddyfile/directives/php_fastcgi.md index ef75233..3404a66 100644 --- a/src/docs/markdown/caddyfile/directives/php_fastcgi.md +++ b/src/docs/markdown/caddyfile/directives/php_fastcgi.md @@ -79,3 +79,10 @@ When using php-fpm listening via a unix socket: ```caddy-d php_fastcgi unix//run/php/php7.4-fpm.sock ``` + +The `php_fastcgi` directive is usually paired with the [`root`](/docs/caddyfile/directives/root) directive to set the root path from which to serve PHP files + +```caddy-d +root * /var/www/html +php_fastcgi 127.0.0.1:9000 +``` \ No newline at end of file diff --git a/src/docs/markdown/caddyfile/directives/root.md b/src/docs/markdown/caddyfile/directives/root.md index 62b6c11..b28fe67 100644 --- a/src/docs/markdown/caddyfile/directives/root.md +++ b/src/docs/markdown/caddyfile/directives/root.md @@ -23,22 +23,29 @@ Note that a matcher token is usually required since the first argument is a path Set the site root to `/home/user/public_html` for all requests: +(Note that a [wildcard matcher](/docs/caddyfile/matchers#wildcard-matchers) is required here because the first argument is ambiguous with a [path matcher](/docs/caddyfile/matchers#path-matchers).) + ```caddy-d root * /home/user/public_html ``` -(A [wildcard matcher](/docs/caddyfile/matchers#wildcard-matchers) is required in this case because the first argument is ambiguous with a [path matcher](/docs/caddyfile/matchers#path-matchers).) - Set the site root to `public_html` (relative to current working directory) for all requests: +(No matcher token is required here because our site root is a relative path, so it does not start with a forward slash and thus is not ambiguous.) + ```caddy-d root public_html ``` -(No matcher token is required here because our site root is a relative path, so it does not start with a forward slash and thus is not ambiguous.) - Set the site root only for requests in `/foo`: ```caddy-d root /foo/* /home/user/public_html/foo ``` + +The `root` directive is commonly paired with [`file_server`](/docs/caddyfile/directives/file_server) to serve static files and/or with [`php_fastcgi`](/docs/caddyfile/directives/php_fastcgi) to serve a PHP site: + +```caddy-d +root * /home/user/public_html +file_server +```