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.
In this repository13 other files it gives its agents.
- agent-ready-siteSkill
- arabic-copySkill
- arabic-localizationSkill
- arabic-seoSkill
- client-briefSkill
- design-tokens-extractorSkill
- freelance-quoteSkill
- product-sheetSkill
- rtl-uiSkill
- ui-inventorySkill
- vat-worksheetSkill
- video-readerSkill
- zatca-invoiceSkill
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
- Distinctive: line 25
Stay inside the scope: Only files of the named site.
- Distinctive: line 33
Run the discovery script, or the same commands by hand:
- Very specific: line 72
Never chown -R or chmod -R above the docroot.
- Very specific: line 73
Leave .well-known/acme-challenge/ alone.
- Very specific: line 74
Run builds and CLI tools as the site user: runuser -u siteuser -- php build.php (or sudo -u).
- Distinctive: line 83
If the test fails, do not reload.
≈ “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.
Files
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
- Look before you touch. Discover read-only first. Never write during discovery.
- Back up what you will change, to a timestamped folder outside the web root, before the first write.
- 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.
- Test, then reload gracefully.
apachectl -t/nginx -tmust pass. Use graceful reload, never a hard restart. - 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.comIt 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
.htaccessapplies to this site too. Seereferences/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.comSaves 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/docrootTell 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. Thenchownto the site user, including the docroot directory itself. - Never
chown -Rorchmod -Rabove the docroot. Never on/home/useras 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(orsudo -u).
5. Test and reload
apachectl -t # or: nginx -t ; httpd -t ; /usr/local/apache/bin/apachectl -t
apachectl -k graceful # or: systemctl reload nginxIf 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.comIt 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 gracefulFor 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
| Trap | What happens | Avoid it |
| Nested docroot | Parent WordPress rewrite sends every URL to /index.php of the parent | Turn on RewriteEngine On in the child .htaccess; child rules then replace the parent's. Parent Header and <FilesMatch> still apply. |
| rsync as root | Docroot owned by UID 501, PHP can no longer write | --no-owner --no-group, then chown user:user . |
| suPHP / suEXEC | 500 error if a PHP file is group- or world-writable, or owned by another user | Files 644, dirs 755, owned by the site user |
| No PHP user in vhost | PHP runs as nobody or fails with 500 | Copy the user mapping block from a working vhost of the same user |
| Panel regenerates vhosts | Manual edit lost on next panel action | Use the panel's include folder; keep a copy of your edit in the repo |
systemctl restart | Drops every live connection on every site | graceful / reload |
Header set in child vs parent <FilesMatch> | Parent header still sent | Unset inside a child <FilesMatch>; Files sections merge after directory sections |
| Deleting "unused" files | Another site or a cron job used them | Only 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.
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
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.

