diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 52 |
1 files changed, 43 insertions, 9 deletions
@@ -1,12 +1,12 @@ -# Docsify: Self-Hosted Setup on Apache 2 +# Docsify: Self-Hosted Setup -A complete guide to running Docsify on Apache 2 with no external CDN dependencies. We follow the [manual creation](https://docsify.js.org/#/quickstart?id=manual-initialization) but download the JavaScript and CSS files locally so we don't have to worry if the domain cdn.jsdelivr.net get seized (who knows what's going to happen in the future). +A complete guide to self-hosting Docsify with no external CDN dependencies. We follow the [manual creation](https://docsify.js.org/#/quickstart?id=manual-initialization) but download the JavaScript and CSS files locally so we don't have to worry if the domain cdn.jsdelivr.net get seized (who knows what's going to happen in the future). The result is just static files, so it runs on any web server — Apache, nginx, Caddy, or similar. --- ## Prerequisites -- Apache 2.4+ +- Any static web server (Apache, nginx, Caddy, or similar) - `curl` (for downloading assets) --- @@ -311,7 +311,7 @@ Create `index.html`: ``` > **Note:** Docsify uses hash-based routing by default, producing URLs like -> `/docs/#/page-name`. This requires no Apache configuration whatsoever. +> `/docs/#/page-name`. This requires no web-server configuration whatsoever. --- @@ -371,7 +371,7 @@ when `subMaxLevel: 2` is set in `index.html`. ## Step 5: Set File Permissions Since you are creating these files yourself, you already own them. Just ensure they -are readable by Apache: +are readable by your web server's user (e.g. `www-data`, `nginx`, or `caddy`): ```bash find . -type f -exec chmod 644 {} \; @@ -380,11 +380,45 @@ find . -type d -exec chmod 755 {} \; --- -## Apache Configuration +## Serving the Site -No Apache configuration is required. Docsify's default hash-based routing means every -request is for a real file (`index.html`, a `.md` file, or an asset) — Apache serves -them as ordinary static files without any rewrite rules or special directives. +Docsify is just static files, so **any** web server works — Apache, nginx, Caddy, or even +`python3 -m http.server` for a quick local preview. **No server configuration is required:** +Docsify's default hash-based routing (`/#/page-name`) means the browser never sends the +route to the server, so every request is for a file that exists on disk (`index.html`, a +`.md` file, or an asset). There are no rewrite rules to set up — just point the document +root at this directory. + +**Apache** — drop the files in the document root; nothing else needed. + +**nginx** + +```nginx +server { + listen 80; + server_name docs.example.com; + root /var/www/docs; + location / { try_files $uri $uri/ =404; } +} +``` + +**Caddy** (also provisions HTTPS automatically) + +```caddy +docs.example.com { + root * /var/www/docs + file_server +} +``` + +**Local preview** — run `python3 -m http.server` in this directory and open +`http://localhost:8000/`. + +> **Clean URLs (optional):** the only time server config matters is if you switch Docsify +> to history-mode routing (`routerMode: 'history'`) to drop the `#` from URLs. Then you +> need a fallback so unknown paths return `index.html` — Apache `mod_rewrite`, nginx +> `try_files $uri /index.html;`, or Caddy `try_files {path} /index.html`. With the default +> hash routing used in this guide, you need none of it. --- |
