Hello guys.

Today I'll tell you how to make a simple deploy the site using shipit and git. You fit this variant if you just need to move your code to server of prod or dev. In this variant, the previous revisions (versions) is not created. To cancel the changes you need to rollback the changes and perform deploy the site again.

We will do deploy site on yii2 advanced using git and shipitjs. OS used on local PC - ubuntu and on server ubuntu/debian.

We assume that you is already installed and configured git and shipitjs. If not then you here: Deploy of applications using Shipitjs.

Prepare the server

Connect via ssh to the server and create a folder:

mkdir /var/www/site

Clone repository in the folder you created:

git clone git@github.com:userName/example.git /var/www/site

Preparing the server is over)

Local settings

In the root of project, create a file shipitfile.js:

module.exports = function (shipit) {
        default: {
            deployTo: '/var/www/site',
            key: '~/.ssh/id_rsa',
            branch : 'master',
        dev: {
            servers: 'user@dev_server.com'
        prod: {
            servers: 'user@prod_server.com'
shipit.task('deploy', function () {
    return shipit.remote('cd '+shipit.config.deployTo+' && git checkout '+shipit.config.branch+' && git pull')
                      .then(function (res) {
                shipit.remote('cd '+shipit.config.deployTo+' && php yii migrate/up --interactive=0');

You must perform two teams to start deploy the site (on the local machine):

$ cd /home/user/project
$ shipit dev deploy

Go to the directory with the project and execute deploy your project.

As a result the following steps will be executed on a remote server (dev_server.com):

  • Transition to the directory where want to deploy of site
  • Switching on the git master branch
  • Loading master branch changes to the folder
  • Execution of migration for database in yii2

The first three steps are described in the file of shipitfile.js (Variables are replaced by actual values):

cd /var/www/site && git checkout master && git pull

The last step - the database migration for yii2:

cd /var/www/site && php yii migrate/up --interactive=0

P. S. After the first deploy of website on hosting, you must run the initialization of yii2, and then adjust the config files.

$ cd /var/www/site
$ php init

A more detailed description deploy of site using shipit