May be this was a simple question,but i didn't get a proper solution for my probelm.
I've an ec2 instance running in aws cloud(amazon ami with php and nginx),and the source code hosted in a bit bucket private repository.
Here is my current deployment process.
1.Login into my ec2 instance using ssh.
2.Deploy the source code with git clone <remote-repo-url>.
need to login every time into my ec2 instance ,ithink this is a bad practice.
Is there any way to simplify so that i can able to deploy to ec2 instance without login into my ec2 instance.
Amazon is providing a solution(AWS codedeploy) but its look like complex process also the documentation is difficult to understand.
One more question
I'am using composer to install and manage my php application so when i commit to repo i've excluded the vendors folder to .gitignore.
So when deploy server i need to install composer and run composer install for the vendors folder(because vendors is excluded from git).
One way to overcome this is add vendors folder to git, but don't think its a good practice.
Is any way to avoid the composer installation in server and manage the vendors folders in server without adding vendors folder to git.
Finally i found an answer for my first part(Automatic git deployment).
this article simply explains how to setup github automatic deployment
in server.
Related
I am working on development of a web app (for learning) in Laravel and I`m using Bitbucket for source control. It will be deployed on couple servers (20 or so, perhaps more over time), and I would like to be able to update all of them as the app changes over time.
The problem is that I will not have SSH access to most of those servers so I wont be able to use a simple "git pull" (a server we test on does not even have git installed so shell_exec is not an option also).
My plan was to make a script that will download latest zip from Bitbucket server, unpack it overwriting the old code, and then running a Laravel script to run migrate (for eventual database changes).
Is there maybe a more sensible way of doing this?
What are you looking for is CI/CD, i.e. Continues Integration/ Continues Delivery. There are so many ways to automatically deploy or pull a code over server. You can use following methods
Automating Deployment to EC2 Instance With Git
Using Bitbucket for Automated Deployments
CI\CD workflow with BitBucket Cloud, Bamboo, AWS CodeDeploy
Bitbucket - Manage Web Hooks
Apart from this you can find so many articles on this, but if you wants to automate the process at laravel level then use Laravel Envoy
I just setup gitdeployment to my production server from my local machine following this tutorial
Now i am going to deploy a laravel project but i've few doubts.
1.In my laravel git repo vendors folders are excluded from the git so when i deploy the project with git to live server it doesn't worked because vendor folder is missing.
One solution to solve this problem is add vendor folder to the git buti don't think its a better practise.
My solution
After git deployment login to my live server and run the composer install command to add the vendors folder.
But its looks painful process suppose if a new package is added to my project (ie image intervention package) i need to repeat my step.
So is there any way to automatically manage vendors folder in live server
For example:
I have a Homestead with Laravel in Virtual Machine. After I finish my project could I just copy the files and bring them to my Wamp server, and export the database and import it into Wamp?
Or is there more behind all this?
Yes, generally this could be one way to deploy a project to a server.
The question is a bit broad to give a good answer because there are many ways how to built a good project deploy chain. First of all it depends on the server you are deploying to and the access rights you have (e.g. are you allowed to ssh into the server or can you run git at your server).
If you have ssh access and you are able to run git a good way could be to pull the git project from your git server, run composer install and migrate and seed your database with artisan.
There are even more ways up to full integrated deploy chains where you just need to push your project to a git server to trigger a deploy (e.g have a look at Capistrano or Laravel Forge for automated deploy).
I've created a Symfony project and pushed it to the github. Now I want to get it from github on another machine.
The problem is that there are a lot of files/folders in Symfony's .gitignore file by default, so my application is broken after 'git clone' command.
I would like to know, what is the best way/practice to store and retrieve Symfony application on/from github. What are the common steps to do it?
You have to download and install Composer on your server.
Keep your .gitignore as default and install your vendors on each cloning.
If your deployment isn't recurrent, you can do it manually by use :
composer install
after each cloning .
If you deploy recurrently or just if you want, you can automate your deployment using Capistrano tasks for Symfony2
Let me just say this, I'm very new to composer and laravel.
I'm a long time cli fan, so I feel very comfy with composer. I've used npm, ruby gems etc, I see all the benefits to package managers.
Problem is, I'm saving entire laravel dir to my svn repository. It seems kinda redundant, especially vendor/bootstrap dirs.
I also find it uncomfortable to have vendor packages same in every laravel app directory on the same server, I'm kinda missing global gems thing from ruby.
How do you deal with this? Is it possible to have laravel like a shared library on server and then just have app/public directories in each project?
What files should be saved to repository? can composer handle all the dependency installation on production server? I see laravel files come with .gitignore files, where do I get svn version?
Much confusion atm in my head, hope to clear these up, so I can start actually writing code ^_^
First off, as far as I know, it is not easily possible to install laravel and it's dependencies globally. I wouldn't worry about that too much though since composer will cache them so it won't need to download everything for each project you set up.
Vendor directory
The vendor dir should definitely NOT be in your repository. I'm no SVN expert but according to this answer you can ignore directories by doing:
svn propset svn:ignore "vendor" .
Most SVN client software should have a similar function in a context menu or similar.
Deploy workflow
Ideally you checkout the repo on your production server and then run composer update to install all dependencies. If you don't have terminal access or have other troubles with that I recommend you download a fresh copy of your repo and run composer udpate. Then upload it to your server.