Laravel Continuous Deployment on VPS over Github

Envoyer like deployment to VPS with zero downtime.

This solution is tested and working for Digital Ocean VPS server with Ubuntu 14.04.

This article will describe:


How to configure Ubuntu 14.04 for Laravel Project

Softwares required on the server:

List of commands to install all softwares listed above: Now lets create directories needed for the deployment and the project:

mkdir /home/user/deploy
mkdir /home/user/deploy/files
mkdir /home/user/storage
mkdir /home/user/vendor
vim /home/user/.env #put your env data in here

Create two files in /etc/nginx/sites-available/ and and put following configuration in it: You need to change server_name and root for to

root "/home/user/deploy/public";

At this point we do not have /home/user/current folder so lets put the project in it. We need to download the project from github or upload it to the server using ftp or sftp and put it e.g. in /home/user/project folder. Then create a symlink for it using followin command

ln -sfT /home/user/project /home/user/current

Now we can start enable our virtual hosts and start nginx:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo service nginx restart

Deployment script

Put the following files into corresponding folders:
/home/user/deploy/ /home/user/deploy/public/index.php

Now you should configure github repository to request on push event. From repository settings -> webhooks & services, add a webhook and define your payload URL.

Now you can push new commit to your github and see if the deployment process works. It can have permission problems, because php is running using www-data user on the server. There are many ways to fix this, simply you can make www-data an owner of all files and folder in /home/user.

Also you may need to clean your OpCache after deploy.