An application layout in /srv: code, public files, and writable data

Build a Debian training layout for frontend and admin, separating code ownership, cache and log directories, and access boundaries.

Two server compartments separate code, public files, and writable data for two applications.

With administrative access configured, we turn to the files for future applications. Before installing Nginx or PHP-FPM, we need to decide where code lives, who can read it, and where a process may write caches and logs.

The E-01 training VPS initially had no /srv/solution200 tree. We tested the directory and permission model on a separate Debian 13 virtual machine, then created it on E-01. The steps below describe the completed training VPS exercise and a fresh ownership and mode readback.

Directories express responsibility

/srv/solution200/products/lab/
├── frontend/
│   ├── src/code.txt
│   ├── public/
│   │   ├── sample.txt
│   │   └── nested/new.txt
│   ├── .env.local
│   ├── .git/config
│   └── var/
│       ├── cache/
│       └── log/
└── admin/
    └── …

Our training product has two applications, frontend and admin, each with its own root and writable directories. These teaching names do not disclose the production server layout.

src represents code, public holds files intended for web delivery, and var/cache and var/log hold process-generated data. All files are test markers. .env.local contains a setting named FIXTURE_ONLY with the value not-a-credential; .git/config is a text marker, not a real Git repository configuration.

We created 19 directories and 10 files to test permissions without deploying a product or using real secrets. The teaching markers must be removed before a future checkout into this same directory.

Code ownership and the process user have different roles

Root owns the code, with an application-specific group. The service user can read its code but cannot modify it. Its var, cache, and log directories belong to that user and are accessible only to it and privileged administrators.

Tree componentOwnerBase mode
srcroot:application group2750
src/code.txt and .env.localroot:application group0640
.git and .git/configroot:root0700 / 0600
var, var/cache, var/logapplication user:group0700

The leading 2 in 2750 sets the directory's setgid bit, making new objects inherit its group. It does not grant code write access. Separate traversal ACLs for public belong in the ACL article.

Read back the resulting layout

This teaching command reads metadata after directory creation:

APP=/srv/solution200/products/lab/frontend
sudo stat -c '%U:%G %a %n' \
  "$APP/src" "$APP/src/code.txt" "$APP/.git" \
  "$APP/.git/config" "$APP/.env.local" "$APP/var/cache"

Below is a normalized representation of the verified owners and modes. … replaces the common root; this is not literal command stdout:

root:s200-lab-frontend 2750 …/src
root:s200-lab-frontend 640 …/src/code.txt
root:root 700 …/.git
root:root 600 …/.git/config
root:s200-lab-frontend 640 …/.env.local
s200-lab-frontend:s200-lab-frontend 700 …/var/cache
A fresh E-01 readback: root owns code; separate service users own their caches and logs.

The frame shows a summary from a fresh SSH connection and state readback. It is not raw command stdout; the 44 filesystem checks ran during this batch's apply phase.

We also performed actual operations as each service user: reading its code file, attempting to open it for writing, and creating, reading, and deleting a separate file in its cache. Code reading and cache operations succeeded; opening code for writing was denied.

What changes for a real deployment

Root owns the teaching code. A future deployment user needs a separately defined permission policy. The important property is that a process does not gain code write access simply because it needs a writable cache.

The dummy .env.local demonstrates a read boundary rather than a finished secret-storage design. Real settings and keys need their own location and delivery method. Caches, logs, and user uploads have different lifecycles: clearing a cache must not delete uploads or the only copy of logs.

A directory name does not protect data

A useful layout identifies the product, application, and data type. Owners, modes, ACLs, and process restrictions provide protection. This exercise has no installed Nginx, PHP-FPM, or working website; web-server behavior will be checked after installation.

The gallery brings together three frames from this exercise: the directory layout, service identities, and ACLs.

  1. Architecture Admin, Frontend, and API: three distinct responsibilities
  2. Observability When a server is truly ready to launch
  3. Operations & Security ACLs on Debian: allow public files and protect the private tree
  4. Architecture Debian service users: a separate identity for each application
  5. Platform Engineering First Symfony site on a prepared stack: Composer and file permissions