Git on ISPmanager hosting: deploying a site from a repository
Git is available in the Shell client. One command deploys the site, another updates it.
Public repository
cd ~/www/example.com
git clone https://github.com/USER/REPO.git .The dot at the end clones right into the site folder. The folder must be empty: delete the placeholder index.html first. Updating the site:
cd ~/www/example.com
git pull
Private repository: an access key
A private repository needs a key. Create it in the Shell client and add it to the repository settings as a deploy key (read-only).
ssh-keygen -t ed25519 -N "" -C "deploy@example.com" -f ~/.ssh/deploy_key
cat ~/.ssh/deploy_key.pubCopy the ssh-ed25519 ... line and paste it: GitHub — repository → Settings → Deploy keys → Add deploy key; GitLab — Settings → Repository → Deploy keys.
From the hosting, GitHub is reachable over SSH on port 443. Set this in ~/.ssh/config:
Host github.com
HostName ssh.github.com
Port 443
User git
IdentityFile ~/.ssh/deploy_key
Check: ssh -T git@github.com. Before the key is added to the repository the answer is Permission denied (publickey), after — a greeting with the repository name. Then:
cd ~/www/example.com
git clone git@github.com:USER/REPO.git .Instead of a key you can clone over HTTPS with an access token: git clone https://TOKEN@github.com/USER/REPO.git .. The token is saved in .git/config — make it read-only and for this repository only.
What not to keep in the repository
.env,wp-config.phpand other files with passwords — create them on the hosting.vendorandnode_modules— aftergit pullruncomposer install --no-scriptsornpm install.- User uploads (for example
wp-content/uploads).
If the site is served from the repository root, the .git folder is reachable from the internet with the whole code history. Close it in .htaccess with RedirectMatch 404 /\.git or keep the site in a public subfolder and set it as the website public directory.
Scheduled updates
To make the site pull changes itself, add a job in Cron, for example hourly: cd /var/www/LOGIN/data/www/example.com && git pull -q.