agentleFS
grw-labgrw-lab/skills/shared-server-deploy/SKILL.md

shared-server-deploy

Skill1 starsChanged 35 days agoMITView on GitHub

Safely changes one site on a shared Linux web server (cPanel, CWP, Plesk, DirectAdmin, or plain Apache/Nginx) that also hosts other sites. Use when asked to deploy, edit a vhost, change .htaccess, fix permissions, add PHP, or reload the web server on a box with neighbours, or when the user says "be careful, this server has other sites". Covers read-only discovery, backups, scoped edits, config tests, graceful reloads, and checking every neighbour still answers.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stay inside the scope: Only files of the named site.

    line 25
  2. Distinctive:

    Run the discovery script, or the same commands by hand:

    line 33
  3. Very specific:

    Never chown -R or chmod -R above the docroot.

    line 72
  4. Very specific:

    Leave .well-known/acme-challenge/ alone.

    line 73
  5. Very specific:

    Run builds and CLI tools as the site user: runuser -u siteuser -- php build.php (or sudo -u).

    line 74
  6. Distinctive:

    If the test fails, do not reload.

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shared server deploy

A shared server is someone's production for many sites at once. One bad reload, one wrong chown -R, or one parent .htaccess rule can take all of them down. This skill makes every change small, reversible, and verified.

When to use

  • Deploying files or config for one site on a server that hosts others.
  • Editing a virtual host, .htaccess, PHP handler, or permissions.
  • Any task where the user names a scope ("only touch example.com").

When not to use

  • Containers or platforms where each app is isolated (Vercel, Fly, Kubernetes). Use their deploy flow.
  • Servers you own alone and can rebuild from scratch. The rules still help, but the neighbour checks do not apply.

The five rules

  1. Look before you touch. Discover read-only first. Never write during discovery.
  2. Back up what you will change, to a timestamped folder outside the web root, before the first write.
  3. Stay inside the scope. Only files of the named site. Never edit global config, other vhosts, or shared panels unless the user says so for that file.
  4. Test, then reload gracefully. apachectl -t / nginx -t must pass. Use graceful reload, never a hard restart.
  5. Prove nothing else broke. Record each neighbour's HTTP status before the change and compare after.

Workflow

1. Discover (read-only)

Run the discovery script, or the same commands by hand:

bash scripts/discover.sh example.com

It reports the OS, the control panel, the web server and version, listening ports, PHP handlers, process managers (pm2, systemd units), the vhost files that mention the domain, the document root, its owner, and the .htaccess chain from / down to the docroot. Read references/panels.md for where each panel keeps vhosts and what it regenerates.

Answer these before any write:

  • Which user owns the docroot? PHP and file writes must run as that user.
  • Is the docroot nested inside another site's docroot? Then the parent's .htaccess applies to this site too. See references/htaccess-inheritance.md.
  • How does PHP run (mod_php, PHP-FPM pool, suPHP, LSAPI)? Which user does it run as?
  • Will the control panel regenerate the vhost and wipe a manual edit? Prefer the panel's include or "custom config" hook if it has one.
  • Which other sites live here? List them for the neighbour check.

2. Baseline the neighbours

bash scripts/neighbours.sh before example.com other1.com other2.com

Saves each site's status code and a body hash to /tmp/neighbours-before.txt.

3. Back up

TS=$(date -u +%Y%m%dT%H%M%SZ)
mkdir -p /root/deploy-backups/example.com/$TS
cp -a /path/to/vhosts/example.com*.conf /root/deploy-backups/example.com/$TS/
cp -a /home/user/public_html/example.com /root/deploy-backups/example.com/$TS/docroot

Tell the user the backup path.

4. Change, scoped

  • Edit only the named site's files. Use exact, minimal edits. Show the diff.
  • Uploading with rsync as root: add --no-owner --no-group, or the remote files take your local UID. Then chown to the site user, including the docroot directory itself.
  • Never chown -R or chmod -R above the docroot. Never on /home/user as a whole.
  • Leave .well-known/acme-challenge/ alone; certificate renewal depends on it.
  • Run builds and CLI tools as the site user: runuser -u siteuser -- php build.php (or sudo -u).

5. Test and reload

apachectl -t        # or: nginx -t ; httpd -t ; /usr/local/apache/bin/apachectl -t
apachectl -k graceful   # or: systemctl reload nginx

If the test fails, do not reload. Restore from the backup and stop.

.htaccess changes need no reload but are not checked by -t. Test them with real requests right away (step 6), and keep the previous file to restore.

6. Verify

bash scripts/neighbours.sh after example.com other1.com other2.com

It diffs against the baseline and exits non-zero if any site changed status. Then check the target itself: the pages, assets, redirects, and headers you meant to change. Read the site's error log for new entries.

7. Report

Say what changed, where the backup is, how to roll back (one command), and the before/after neighbour table.

Rollback

cp -a /root/deploy-backups/example.com/$TS/*.conf /path/to/vhosts/
apachectl -t && apachectl -k graceful

For a docroot: rsync -a --delete /root/deploy-backups/example.com/$TS/docroot/ /home/user/public_html/example.com/, then chown back to the site user.

Traps that cause outages

TrapWhat happensAvoid it
Nested docrootParent WordPress rewrite sends every URL to /index.php of the parentTurn on RewriteEngine On in the child .htaccess; child rules then replace the parent's. Parent Header and <FilesMatch> still apply.
rsync as rootDocroot owned by UID 501, PHP can no longer write--no-owner --no-group, then chown user:user .
suPHP / suEXEC500 error if a PHP file is group- or world-writable, or owned by another userFiles 644, dirs 755, owned by the site user
No PHP user in vhostPHP runs as nobody or fails with 500Copy the user mapping block from a working vhost of the same user
Panel regenerates vhostsManual edit lost on next panel actionUse the panel's include folder; keep a copy of your edit in the repo
systemctl restartDrops every live connection on every sitegraceful / reload
Header set in child vs parent <FilesMatch>Parent header still sentUnset inside a child <FilesMatch>; Files sections merge after directory sections
Deleting "unused" filesAnother site or a cron job used themOnly delete what you created; log it

Done checklist

  • Discovery done and scope confirmed with the user.
  • Backup path reported.
  • Config test passed before reload.
  • Graceful reload only.
  • Neighbour check: no status changes.
  • Target verified with real requests and the error log.
  • Rollback command given.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.