Main menu
WalkswithMeLinux CommandsEasy project deployment for web application

Easy project deployment for web application

Easy project deployment for web application ? you may wonder what it is right ? also thinks what is the issue with my current project deployment system ? Here I will explain a few techniques for better project deployment using version controller Git.

In our old way after finishing our projects we used FTP for uploading the projects files to the server, and its huge head ache for keeping backups, updates etc, then we found the version controllers will do this jobs much better that this approach plus update is much easier!.

For last year I worked with Laravel web apps impressed the way that get deployed to the server , no need of login to server with SSH it has option to set the Envoy for project deployment , So just push the changes to the cloud repo (Bit-bucket is my favourite) then in the same terminal you can run the envoy task , Its a simple blade file there we can define task and execute it with envoy run commands. This way the server and bit bucket must be authenticated with SSH key pair so it just prompt for the server password once we enter that its pull the latest changes to the live server.

Laravel Envoy Setup

The laravel Envoy blade looks like below,


@servers(['live' => 'username@hostname -p portnumber'])
@task('update', ['on' => 'live'])
cd ~/project/website
git pull --rebase
/home/user/bin/ composer dumpautoload -o
@endtask

I’m not explaining this in details bcoz Laravel Official docs is very clean and ready to cook the things.

Here is the deal , Laravel did it smoothly with Envoy, so a normal PHP application or CMS like Joomla, or Shopping cart like Magento, Prestashop how we can do such technique ?

most of the people now doing is login to server with SSH and move to the project folder then pull the latest changes. Yea it good, but few things we have to do evertime, type the SSH login info like user name and host name , also after the task we have to exit from server, Other wise we still in the server . etc.

So I look for something similar in Laravel, and found few options.

1) We can automatically deploy from cloud to server using Bitbucket.

2) We can automatically deploy using it Git.

3) A simple Bash script doe’s it exactly like Laravel ( I like this idea)

Automatic deployment from Bitbucket to server ?

Bitbucket have option to do this , with their own hooks , on every push received in a bitbucket repo we can trigger some hooks and manage the remote server update. make sure you are already authenticated you SSH keypair with the server and bitbucket. The detailed documentation can be found here. It was a nice and clear documentation also few update implemented in bitbucket after this blog post so you have to check this link to get it work perfectly.

Automatic deployment using Git with bare repository ?

Yea this is also possible you can easily deploy the code to server when ever a push reached in the bare repo. yea its a cool option too implement this way with automatically server gets update whenever a new push happen. detailed documentation can be found here. this is almost same technique like bitbucket they also use some hooks.

Bash Script for Easy project deployment for web application ?

I like this option bcoz it very simple compare to above to methods, additional you can controll when ever you need a production server update. means pushing to cloud repo will not automatically deploy the code to server you have to execute a bash script for it. This option also required SSH keypair authentication. just create a bashscript with following code and save it as deploy.sh .


#!/bin/bash
## Easy project deployment for web application ##
ssh username@hostname <<'ENDSSH'
cd /path / to /your project folder
git pull origin master;
ENDSSH

once you save the file as .sh format and give the executable permission with following code.

 chmod +x /path to your deploy.sh file/ 

Then this file can be placed in side you route of the project folder so from CLI simply execute the bash file then it will ask for the password prompt of server once you enter that it will execute the git pull command and server get update with latest changes in the bitbucket repo.

This is easy right ? That is why I said Easy project deployment for web application. You guys may not familiar with this methods right ? I hope this article help you to set up the Deployment process much better.

Happy reading.. :):):)

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

FacebookTwitterGoogle+RSS