Drupal§
To run the Drupal content management system using Unit:
Install Unit with a PHP language module.
Install and configure Drupal’s prerequisites.
Install Drupal’s core files. Here, we install it at
/path/to/app/
; use a real path in your configuration.Run the following command so Unit can access the application directory:
# chown -R unit:unit /path/to/app/
Note
The
unit:unit
user-group pair is available only with official packages, Docker images, and some third-party repos. Otherwise, account names may differ; run the ps aux | grep unitd command to be sure.For further details, including permissions, see the security checklist.
Next, prepare the Drupal configuration for Unit. The default
.htaccess
scheme in a Drupal installation roughly translates into the following (use real values forshare
androot
):{ "listeners": { "*:80": { "pass": "routes" } }, "routes": [ { "match": { "uri": [ "!*/.well-known/*", "/vendor/*", "/core/profiles/demo_umami/modules/demo_umami_content/default_content/*", "*.engine", "*.inc", "*.install", "*.make", "*.module", "*.po", "*.profile", "*.sh", "*.theme", "*.tpl", "*.twig", "*.xtmpl", "*.yml", "*/.*", "*/Entries*", "*/Repository", "*/Root", "*/Tag", "*/Template", "*/composer.json", "*/composer.lock", "*/web.config", "*sql", "*.bak", "*.orig", "*.save", "*.swo", "*.swp", "*~" ] }, "action": { "return": 404 } }, { "match": { "uri": [ "/core/authorize.php", "/core/core.api.php", "/core/globals.api.php", "/core/install.php", "/core/modules/statistics/statistics.php", "~^/core/modules/system/tests/https?\\.php", "/core/rebuild.php", "/update.php", "/update.php/*" ] }, "action": { "pass": "applications/drupal/direct" } }, { "match": { "uri": [ "!/index.php*", "*.php" ] }, "action": { "return": 404 } }, { "action": { "share": "/path/to/app/web$uri", "fallback": { "pass": "applications/drupal/index" } } } ], "applications": { "drupal": { "type": "php", "targets": { "direct": { "root": "/path/to/app/web/" }, "index": { "root": "/path/to/app/web/", "script": "index.php" } } } } }
Note
The difference between the
pass
targets is their usage of thescript
setting:The
direct
target runs the.php
script from the URI orindex.php
if the URI omits it.The
index
target specifies thescript
that Unit runs for any URIs the target receives.
Upload the updated configuration. Assuming the JSON above was added to
config.json
:# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock http://localhost/config/
Note
The control socket path may vary; run unitd -h or see Startup and Shutdown for details.
After a successful update, browse to http://localhost and set up your Drupal installation: