docs: Cross-link the root directive with file_server/php_fastcgi

This commit is contained in:
Francis Lavoie 2020-05-17 15:51:26 -04:00
parent e0f5ee1bb9
commit e287e61df6
No known key found for this signature in database
GPG key ID: 7D1A27F0725BE5D8
3 changed files with 26 additions and 5 deletions

View file

@ -19,7 +19,7 @@ file_server [<matcher>] [browse] {
``` ```
- **browse** enables file listings for requests to directories that do not have an index file. - **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. - **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` - **index** is a list of filenames to look for as index files. Default: `index.html index.txt`
- **<template_file>** is an optional custom template file to use for directory listings. - **<template_file>** 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 ```caddy-d
file_server /static/* 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
```

View file

@ -79,3 +79,10 @@ When using php-fpm listening via a unix socket:
```caddy-d ```caddy-d
php_fastcgi unix//run/php/php7.4-fpm.sock 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
```

View file

@ -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: 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 ```caddy-d
root * /home/user/public_html 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: 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 ```caddy-d
root public_html 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`: Set the site root only for requests in `/foo`:
```caddy-d ```caddy-d
root /foo/* /home/user/public_html/foo 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
```