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 them at /path/to/app; use a real path in your configuration.
-
Change ownership:
Run the following command (as root) so Unit can access the application directory (If the application uses several directories, run the command for each one):
# chown -R unit:unit /path/to/app/ # User and group that Unit's router runs as by default
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 theps 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 for share and root):
{ "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", "*~" ] }, "_comment_match": "Denies access to certain types of files and directories best kept hidden, allows access to well-known locations according to RFC 5785", "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/*" ] }, "_comment_match": "Allows direct access to core PHP scripts", "action": { "pass": "applications/drupal/direct" } }, { "match": { "uri": [ "!/index.php*", "*.php" ] }, "_comment_match": "Explicitly denies access to any PHP scripts other than index.php", "action": { "return": 404 } }, { "action": { "share": "/path/to/app/web$uri", "_comment_share": "Serves static files", "fallback": { "pass": "applications/drupal/index" }, "_comment_fallback": "Funnels all requests to index.php" } } ], "applications": { "drupal": { "type": "php", "targets": { "direct": { "root": "/path/to/app/web/", "_comment_root": "Path to the web/ directory; use a real path in your configuration" }, "index": { "root": "/path/to/app/web/", "_comment_root": "Path to the web/ directory; use a real path in your configuration", "script": "index.php", "_comment_script": "All requests are handled by a single script" } } } } }
The difference between the pass targets is their usage of the script setting:
- The direct target runs the .php script from the URI or index.php if the URI omits it.
- The index target specifies the script that Unit runs for any URIs the target receives.
-
Upload the updated configuration.
Assuming the JSON above was added to
config.json
. Run the following command as root:# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock \ # Path to Unit's control socket in your installation http://localhost/config/ # Path to the config section in Unit's control API
After a successful update, browse to http://localhost and set up your Drupal installation: