A simple way to deploy a site: push to a bare git repository on the server, and let a post-receive hook check out the files into the web root. Here example.com is the site and YOUR_IP is the server’s IP address.
The commands below run on the server, as a user with sudo access:
sudo usermod -aG deployer www-datasudo chown www-data:www-data -R /var/wwwsudo chmod g+w -R /var/www
sudo -u www-data mkdir /var/www/example.comsudo -u www-data mkdir /var/www/example.com/publicsudo chmod g+w -R /var/www/example.com/public
# Create a deployer usersudo useradd -r -M -s /usr/sbin/nologin deployer
# Add user to deployer groupsudo usermod -aG deployer risan
# Create git repository directorysudo mkdir /reposudo chown deployer:deployer -R /repo
# Create git repositorysudo -u deployer mkdir /repo/example.comcd /repo/example.comsudo -u deployer git init --baresudo chmod g+w -R /repo/example.com
# Setup post-receive hookssudo -u deployer vim /repo/example.com/hooks/post-receive######!/bin/bashgit --work-tree=/var/www/example.com/public --git-dir=/repo/example.com checkout -f#####sudo chmod u+x,g+wx /repo/example.com/hooks/post-receive
# On local machinegit remote add production ssh://risan@YOUR_IP:2270/repo/example.comgit push production masterNote that my SSH server listens on port 2270, see Setup New Ubuntu Server. The last two commands run on the local machine: add the server as a production remote, then push to it to deploy.