First Symfony site on a prepared stack: Composer and file permissions

An official skeleton, exact commit, unprivileged Composer, private environment and Nginx/PHP-FPM checks, manually and through the CLI.

A building frame on a stone foundation with components and a sealed envelope.

The stack is running, but its PHP pool does not yet serve an application. Our first site is the official Symfony skeleton, without custom bundles, a database or application routes. It lets us test code delivery, dependencies, permissions and the Nginx-to-PHP-FPM connection. We completed the steps manually, then tested automation on a separate copy of the retained Debian 13 training VM.

Create the source with Symfony CLI

We ran the official command locally, initialized Git separately and published the repository to private GitLab.

symfony new article_demo --version='8.1.*' --php=8.5 --no-git --no-interaction

The result was Symfony 8.1.9 on PHP 8.5.12. We committed 22 files, including composer.json, composer.lock and symfony.lock. vendor/, var/, local environment values and generated files stayed outside Git. An empty APP_SECRET in tracked templates does not replace the private value required by an environment.

Deliver the selected commit

Exact Git objects from the selected commit travelled over the protected SSH connection. Uncommitted working-tree changes were excluded. No GitLab token or private key was copied to the VM. After installation, all 22 source-file SHA256 values matched the commit.

This fills an empty prepared application directory for the first time. It does not switch releases of a live site. Before writing, we checked current package history, Nginx configuration, both PHP pools and independent console access.

Install Composer separately from application packages

The signed APT plan added Composer 2.8.8-1+deb13u3 and 21 dependencies: 22 system packages. These are separate from the 22 repository files. PHP remained 8.5.12. Symfony components required by Debian’s Composer package do not determine the application’s Symfony version; its own composer.lock does.

We created a private .env.local on the VM. This example shows its structure only. The real secret was generated on the VM, never printed or committed.

APP_ENV=prod
APP_DEBUG=0
APP_SECRET=<NEW_PRIVATE_VALUE>

Install with a separate account

Composer ran inside the project directory as a locked account without interactive login. This account is distinct from the PHP-FPM identity and has no runtime-group membership. These were the installation and separate cache-warmup arguments; the working directory, systemd restrictions and environment were supplied externally.

APP_ENV=prod APP_DEBUG=0 php8.5 /usr/bin/composer --no-cache install \
  --no-dev --prefer-dist --no-interaction --no-progress --optimize-autoloader
APP_ENV=prod APP_DEBUG=0 php8.5 bin/console cache:warmup --env=prod --no-debug

Composer installed 32 application packages, with no updates or removals. The stock cache:clear and assets:install public scripts ran successfully; this skeleton has no custom assets. A separate warmup completed for prod with debug=false. We did not copy vendor/ from elsewhere. The Composer command reference explains installation from the lock file.

Both commands ran as transient systemd services. This fragment shows the actual properties with placeholders. Only three paths were writable. Temporary ACLs granted source reading and the required var/ access; we revoked the builder’s access afterwards.

User=<BUILDER_USER>
Group=<BUILDER_GROUP>
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=yes
PrivateDevices=yes
RestrictSUIDSGID=yes
ReadWritePaths=<APP_ROOT>/vendor <APP_ROOT>/var <APP_ROOT>/public/bundles

Ownership after installation

Code and vendor/ belong to root and the application group: directories use 2750, regular files 0640 and executable files 0750. PHP can read code but cannot overwrite it. var/ remains runtime space; newly built cache files were transferred to that identity. The 0640 .env.local is readable but not writable by PHP. The web-server account cannot read the secret. Once its ACLs were revoked, the builder could not even read composer.json. We tested access as each account rather than relying on chmod output alone.

One front-controller fallback

The document root remains public/. Only location / in the selected frontend changed: a missing file now falls back to index.php with its query arguments. The existing dedicated PHP handler and denials for arbitrary PHP files and hidden paths remain. This fragment extends the previously configured server; it is not a complete server block.

location / {
    limit_except GET { deny all; }
    try_files $uri /index.php$is_args$args;
}

The candidate passed an isolated nginx -t before replacing the live file. One reload preserved the master PID. The Symfony web-server guide explains public/ and the front controller.

Why production404 is expected

The skeleton has no application route for /. A request must reach Symfony and return its ordinary production404 page with Oops!, without a welcome page or stack trace. This proves delivery, not a finished editorial site. Requests went through Nginx → PHP-FPM, without a local PHP development server.

curl --noproxy '*' -sS -o /dev/null -w '%{http_code}\n' \
  -H 'Host: frontend.example.test' http://127.0.0.1:8080/

The command returned 404. Separate requests to /index.php, /.env, /composer.json and /vendor/autoload.php also returned 404. For / and /index.php we checked the Symfony body as well: a status code alone would not distinguish application execution from an early Nginx rejection.

Repeat the delivery through the CLI

Automation used another copy of the same prepared disk. Composer was added under a separate signed plan. Application planning checked the current stack, explicit commit and empty target. Examples require private absolute paths; approval hashes come from reviewed plans.

deploy-cli host application plan \
  --profile <administrator> --request-file <private-request> \
  --profile-file <application-profile> \
  --maintenance-plan-file <completed-install-plan> \
  --maintenance-plan-sha256 <install-sha256> \
  --source-repository <absolute-local-git-root> --commit <exact-40hex-commit> \
  --plan-file <new-delivery-plan>

Apply requires the exact plan hash and explicit privilege approval. It creates the builder, installs dependencies, warms cache, revokes temporary access and changes the approved fallback. The controller implementation remains private.

deploy-cli host application apply \
  --profile <administrator> --request-file <private-request> \
  --profile-file <application-profile> \
  --maintenance-plan-file <completed-install-plan> \
  --maintenance-plan-sha256 <install-sha256> \
  --plan-file <reviewed-delivery-plan> --plan-sha256 <delivery-sha256> \
  --approve-privileges

The applied state is checked through fresh SSH. The separate command reads an already completed delivery:

deploy-cli host application verify \
  --profile <administrator> --request-file <private-request> \
  --profile-file <application-profile> \
  --maintenance-plan-file <completed-install-plan> \
  --maintenance-plan-sha256 <install-sha256> \
  --plan-file <reviewed-delivery-plan> --plan-sha256 <delivery-sha256>

A failure caught in the rehearsal

The first CLI run completed Composer and warmup, then stopped while restoring ACLs because a helper received the wrong argument. Nginx had not changed. We retained the pending journal and did not rerun installation there. The corrected full run used a new, separate copy of the original disk.

Final checks covered permissions, exact source, production responses and the browser at two widths. All nine configured services and timers, 20 earlier HTTP controls, both PHP pools and MySQL, Redis and Elasticsearch data controls remained functional. This skeleton needs no new migrations, database accounts or background workers. Public DNS, Cloudflare and TLS are the next stage.

Live version and permission reads and five separate HTTP requests; the curl command is abbreviated. The lower section summarizes retained observations.
  1. PHP PHP and Composer: what to check beyond the version number
  2. Operations & Security ACLs on Debian: allow public files and protect the private tree
  3. Architecture An application layout in /srv: code, public files, and writable data
  4. Operations & Security Nginx and PHP-FPM: two applications and the right worker
  5. Platform Engineering Updating a configured Debian server: APT and a managed reboot
  6. Symfony Core Independent sites with a shared Symfony foundation