Lazy way for web application staging deployment
When comes to deployment, usually what we do is copy modified files over the server. It may takes some time on doing so.
I’ve discover an easy way to do deployment.
Example: I have a PHP web app hosted on Bitbucket, let say https://jslim89@bitbucket.org/myorganization/my-private-app.git and this project has 3 developers involved. Now I want to deploy on staging server for client to test.
SSH to the server
1 | $ ssh root@123.123.123.123 |
Assumed the project want to store in /var/www/mywebapp.com
1 | mkdir /var/www/mywebapp.com |
The Git URL please don’t use SSH, use HTTPS instead. The reason here is we don’t want to put our private key on server. Besides, there are 3 developers share the same copy.
The last command here you can see I put my username, you can put whatever you want as long as you can remember. Usually what we see is git remote add origin ....
, but in this case different developers may have different URL, e.g. https://dev1@bitbucket.org/myorganization/my-private-app.git. Thus use username rather than origin
Update the project
1 | $ git pull jslim89 master |
jslim89 here refer to the URL https://jslim89@bitbucket.org/myorganization/my-private-app.git, master refer to remote master branch
For other developers
They also do the same step with you
1 | git remote add dev1 https://dev1@bitbucket.org/myorganization/my-private-app.git |