# Magento reference

Reference for running Magento 2 (Adobe Commerce) on TurboStack: where the files live, the command-line tool, and the scheduled jobs. For setup see [Deploy Magento](deploy.md); for tuning see [Magento 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 `bin/magento` command from `~/public_html`.

| Path | What it is |
| --- | --- |
| `~/public_html/` | Magento project root; run the command-line tool from here |
| `~/public_html/pub/` | Web document root (the served files) |
| `~/public_html/bin/magento` | The Magento command-line tool |
| `~/public_html/app/` | Core modules, configuration (`app/etc`) and custom themes |
| `~/public_html/vendor/` | Composer dependencies |
| `~/public_html/var/` | Cache, generated code, sessions and logs |
| `~/nginx/` | Custom Nginx configuration |
| `~/.config/systemd/user/magento-consumer@.service` | Message-queue consumer service |

For ownership and permissions, see [Application file layout and permissions](../index.md#file-layout-and-permissions).

## Command-line reference

Magento ships a command-line interface (CLI) at `bin/magento`. Run `php bin/magento list` for the full list; the common commands are below.

| Command | What it does |
| --- | --- |
| `setup:upgrade` | Apply database schema and data changes from modules |
| `setup:di:compile` | Compile dependency injection code |
| `setup:static-content:deploy` | Generate static view files for the storefront |
| `deploy:mode:set {developer\|production}` | Set the deployment mode (`deploy:mode:show` reads it) |
| `cache:clean` / `cache:flush` | Clear enabled cache types / flush all cache backends |
| `cache:status` / `cache:enable` / `cache:disable` | Show or change which cache types are active |
| `indexer:reindex` | Rebuild indexers (for example catalog and search data) |
| `indexer:status` / `indexer:reset` / `indexer:set-mode` | Inspect, reset or switch schedule/realtime indexer mode |
| `config:set <path> <value>` / `config:show <path>` | Set or read a store configuration value |
| `maintenance:enable` / `maintenance:disable` / `maintenance:status` | Control maintenance mode |
| `module:status` / `module:enable` / `module:disable` | List, enable or disable a module |
| `admin:user:create` / `admin:user:unlock <user>` | Create an admin user or unlock a locked one |
| `cron:run` / `cron:install` | Run due cron jobs now / install the cron entries |
| `queue:consumers:list` / `queue:consumers:start <name>` | List message-queue consumers or start one |

> [!TIP]
> After deploying code on a production store, run `setup:upgrade --keep-generated` -> `setup:di:compile` -> `setup:static-content:deploy` -> `cache:flush`. See [Magento best practices](best-practices.md).

## Full-page cache debugging

Magento's built-in full-page cache adds an `X-Magento-Cache-Debug` response header: `HIT` means the page was served from cache, `MISS` means it was rendered fresh. The header appears only in developer mode (`bin/magento deploy:mode:set developer`) and is suppressed in production. Check it over SSH:

```bash
curl -sI https://example.com/ | grep -i x-magento-cache
```

With Varnish in front, use the Varnish cache headers instead.

> [!NOTE]
> In production, static files are pre-generated with `setup:static-content:deploy`. You can allow on-demand generation by adding `'static_content_on_demand_in_production' => 1` to `app/etc/env.php`, but Adobe recommends against this on live stores because it adds latency on the first request for each uncached asset.

## Cron and message-queue consumers

TurboStack installs the Magento cron entries for your system user automatically (`bin/magento cron:run`, `setup:cron:run` and the updater). These drive indexing, emails and scheduled jobs. Do not disable cron on a live store.

On a busy store, run each message-queue consumer as a persistent [user system service](../../technologies/system-services/what-is.md) so it restarts on failure, rather than relying on cron alone. The Magento consumer template unit and the exact `systemctl --user` commands are in [Magento best practices](best-practices.md#message-queue-consumers).

## Related

- [Deploy Magento](deploy.md)
- [Magento best practices](best-practices.md)
- [How to run multiple Magento store views](multiple-store-views.md)
- [Troubleshooting Magento](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)
