Deploy using Git
- You need to setup your ssh settings first.
- You need to have a git repository initialized on the server and a local copy of it as described in Local development.
- You need to be in your project directory:
- You need to have production set as git remote:
# Here we are using custom alias 'your-site' in ~/.ssh/config $ git remote -v production your-site:/data/wordpress/.git (fetch) production your-site:/data/wordpress/.git (push) # This is the output if project was cloned without ssh alias $ git remote -v production ssh://email@example.com:12345/data/wordpress (fetch) production ssh://firstname.lastname@example.org:12345/data/wordpress (push)
Note: This doesn’t deploy the database or the contents of uploads. We recommend that you don’t include these in git.
$ git push production master Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 317 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Seravo: composer.json was updated, installing... remote: Loading composer repositories with package information remote: Installing dependencies from lock file remote: Nothing to install or update remote: Generating autoload files remote: > Wordpress/Installer::symlinkWPContent remote: Seravo: Nginx configs were changed, reloading nginx... remote: testing nginx configuration... remote: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok remote: nginx: configuration file /etc/nginx/nginx.conf test is successful remote: restarting nginx... remote: nginx restarted! To your-site:/data/wordpress/.git 01b9b80..9b3d006 master -> master
# Go to your project folder $ cd Projects/your-site # Add new remote to git $ git remote add production ssh://email@example.com:12345/data/wordpress
Note: This is just an example. Use the real credentials for your site.
# First push doesn't share anything with the fresh site so you need to force push it $ git push production master --force
For deploying the database contents or the contents of the uploads folder you will need to roll your own solution which is safe enough to not overwrite any data created in production.
Note on wp-push- commands: In Seravo Vagrant images created before October 5th, 2016, there used to be the commands
wp-push-production-db(deploy database to production) and
wp-push-production-uploads(deploy wp-content/uploads into production) but they were deemed as too risky and removed to protect customers from accidentally making too much damage to their site.