mirror of
https://github.com/caddyserver/website.git
synced 2025-05-07 12:17:15 -04:00
docs: Cross-link the root
directive with file_server/php_fastcgi
This commit is contained in:
parent
e0f5ee1bb9
commit
e287e61df6
3 changed files with 26 additions and 5 deletions
|
@ -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
|
||||||
|
```
|
|
@ -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
|
||||||
|
```
|
|
@ -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
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue