# Drupal reference

Reference for running Drupal on TurboStack: where the files live, the command-line tool, and the scheduled job. For setup see [Deploy Drupal on TurboStack](deploy.md); for tuning see [Drupal best practices](best-practices.md).

## File layout

Everything lives under your system user's home directory. `~` is that home directory (for example `/var/www/prod/`). Run every Drush command from `~/public_html`.

| Path | What it is |
| --- | --- |
| `~/public_html/` | Drupal project root and web document root; run Drush from here |
| `~/public_html/core/` | Core framework |
| `~/public_html/modules/` | Contributed and custom modules |
| `~/public_html/themes/` | Themes |
| `~/public_html/profiles/` | Installation profiles |
| `~/public_html/sites/` | Site-specific configuration and files |
| `~/public_html/sites/default/files/` | Public uploads (must be writable) |
| `~/public_html/vendor/` | Composer dependencies |
| `~/nginx/` | Custom Nginx configuration |

For ownership and permissions, see [Application file layout and permissions](../index.md#file-layout-and-permissions). The uploads directory `sites/default/files` must be group-writable so uploads succeed, for example `chmod -R 775 ~/public_html/sites/default/files`.

> [!NOTE]
> In multi-site configurations, additional directories may exist under `~/public_html/sites/`, one per site alongside `default`.

## Command-line reference

Drupal ships the Drush command-line interface (CLI) at `drush`. Run every command from `~/public_html`. The common commands are below.

| Command | What it does |
| --- | --- |
| `drush status` | Show the site status and environment details |
| `drush cr` | Rebuild the cache |
| `drush cron` | Run cron |
| `drush updb` | Apply database updates |
| `drush cex` | Export configuration |
| `drush cim` | Import configuration |
| `drush watchdog:show` (alias `drush ws`) | Show recent log messages |

Manage dependencies with Composer from the project root:

```bash
cd ~/public_html && composer install
composer update
```

Make sure you set a supported PHP version and have installed all the PHP extensions Drupal requires before installing dependencies. On TurboStack the interpreter is `/usr/bin/php<version>` (for example `/usr/bin/php8.3`). If you need extra PHP modules, contact [Support](../../platform/support.md).

Clear caches at each layer with the TurboStack CLI ([tscli](../../api/cli.md)):

| Command | What it clears |
| --- | --- |
| `drush cr` | Drupal's own cache |
| `tscli redis clear` | Redis cache (Redis must be configured) |
| `tscli varnish clear` | Varnish full-page cache (works by default) |
| `tscli nginx reload` | Reloads Nginx after config changes |

## Cron

Drupal relies on cron to run periodic tasks such as indexing content, sending emails, and cleaning up old log entries. Schedule Drupal cron with Drush rather than the web cron. Add a cron entry for your system user - for example every 15 minutes:

```cron
*/15 * * * * cd ~/public_html && drush cron
```

## Varnish integration

To cache pages for logged-in users and invalidate the cache by cache tag, the contributed Advanced Varnish module (`adv_varnish`) integrates Drupal with Varnish. Install it with Composer and use the latest release, which supports Drupal 9, 10 and 11:

```bash
composer require drupal/adv_varnish
```

The module ships its own Varnish configuration (VCL). On TurboStack the Varnish layer is managed, so coordinate a custom VCL through [Support](../../platform/support.md). See the module's [project page](https://www.drupal.org/project/adv_varnish).

## Related

- [Deploy Drupal on TurboStack](deploy.md)
- [Drupal best practices](best-practices.md)
- [Troubleshooting Drupal](troubleshooting.md)
- [Application file layout and permissions](../index.md#file-layout-and-permissions)
- [How to manage user system services](../../technologies/system-services/manage-user-services.md)
