Server Side Git Installation for Deploying our Laravel App

Server Side Git Installation for Deploying our Laravel App



How to install Git on the server side to push our Laravel 5 app from our Local computer to our VPS. We will utilize git hooks on the server to initiate the copy after …

35 thoughts on “Server Side Git Installation for Deploying our Laravel App

  1. I understand it's 2020 and usually nobody replies to comments but I will try to. My Laravel version is 6.2 and I have installed everything successfully but when running the command composer install –no-dev I receive the error:
    tlaravel/framework v7.6.2 requires tijsverkoyen/css-to-inline-styles ^2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.2].
    As I've read on some sources it's says the package is required for this laravel version and can't be excluded, any ideas how to fix this?

    Thank you.

  2. If you got this warning:
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    Let's assume you have created your SSH Key in your terminal (or Putty)
    Meaning your "id_rsa.pub" file is located on the internet (your domain/ip address), not your personal computer.
    Let's also assume that you have correctly copied/pasted the contents of the pub file into Vultr and Github.

    Around Step 12 in this tutorial series, we're no longer remote-ing into our domain. We are now working on our local computers.
    If you got that really nasty warning "Remote Host Identification has Changed"
    read the text on the screen.
    You should see something like:
    — -Please contact your system administrator.
    — Add correct host key in "/SOME/PATH/.ssh/known_hosts" to get rid of this message.

    On Windows, most likely the path will be "C:UsersYOURNAME.ssh"
    On Linux it's probably "/home/user/.ssh/"

    Just open up the "known_hosts" file in a text editor (like Notepad) and copy and paste the correct information.
    So let's pretend that your pub file on your IP/domain looks like this: (obviously, it will be much longer than this)
    "ssh-rsa AAAAPPPLLLEESSSSS== [email protected]"

    The "known_hosts" file on your personal computer should look something like this:
    12.34.567.890 ecdsa-sha2-nistp256
    AAAAPPPLLLEESSSSS==
    bitbucket.org,18.205.93.x ssh-rsa
    AAAAPPPLLLEESSSSS==

    Notice that this is the ip address for Bitbucket. You can open up command prompt and find the ipaddress of any website using "tracert"
    Example: tracert github.com
    Tracing route to github.com [140.82.113.4]

    Trace complete.

    (I am using bitbucket. You are probably using github if you're following along with this tutorial)

    If this file doesn't exist, try generating a new ssh key on your personal computer.
    Remember to go through all of the steps:
    $ ssh-keygen -t rsa -b 4096 -C "[email protected]"
    $ eval $(ssh-agent -s)
    $ ssh-add ~/.ssh/id_rsa
    You can safely delete the "id_rsa" and "id_rsa.pub" files that you generated on your personal computer.
    Open up the "known_hosts" file and edit it to match the SSH Key you want to use.

    To sum up:
    – On your domain, you will have a file "id_rsa.pub" with the following contents: "ssh-rsa AAAAPPPLLLEESSSSS== [email protected]"
    – In Vultr > Products > SSH Keys, you have added the same information: "ssh-rsa AAAAPPPLLLEESSSSS== [email protected]"
    – On Github/Bitbucket/wherever, you have added the same information: "ssh-rsa AAAAPPPLLLEESSSSS== [email protected]"
    – On your personal computer, you have edited the "known_hosts" file. This file should have a reference to your domain/ip address and a reference to github/bitbucket using "AAAAPPPLLLEESSSSS=="

  3. For those who get the error:
    -bash: git: command not found

    Just install Git by running command:
    # apt-get install git

  4. Those getting an empty folder on the server side after 'git push production master', try delete your local branch and then recreating it… then doing the Add/Commit/Push once again… that worked for me after several days of Stack Exchange confusing me even more. Okay, bless.

  5. Absolutely unbelievable. You are the best along with the other gentleman who created the guide.
    Edit: I just realized it's you. So now you're doubly incredible.

  6. Is it possible to run 'php artisan migrate' and 'composer update –no-dev' automatically after the deployment? Because without this command the process is not fully automatic.

  7. Hi, I am stuck at pushing to the production branch via ssh. It is stuck on writing objects, search the web couldnt find a working solution..
    Could use some help here

  8. Has anyone figured out the issue when doing 'git push production master' ??? I am on windows and haven't been able to figure this out…Another thing, I am not able to ssh in to the vps I need to go to putty and get in that way…not sure if that has anything to do with it.

  9. my server access needs an ssh public key file… how do I set it up for my remote? It won't let me connect

  10. got error how to fix?
    remote: fatal: Unable to create temporary file '/var/repo/ng.git/./objects/pack/tmp_pack_XXXXXX': Permission denied
    fatal: sha1 file '<stdout>' write error: Broken pipe
    error: remote unpack failed: index-pack abnormal exit
    error: failed to push some refs to 'ssh://[email protected]*********/var/repo/ng.git'

  11. hi, im trying to install git with this guide , to an aws elastic beanstalk . but the problem is that the ssh acces is quite different…:-

  12. Hello first off thank you so much for this tutorial as it has been a great help.

    However what can I do to troubleshoot an empty /var/www/laravel folder after my initial git push to remote production?

    Terminal showed that all files were uploaded successfully but my laravel folder is empty.

  13. how can i get the laravel files into my pc transfer to my server vps
    like folder app, bootstrap, database and files .env , composer.json , etc.

  14. Sir i have installed nginx and i customize the root folder to var/www/laravel/public/, but i get an error 403 forbidden?
    can you please help me to solve 🙁

  15. How to fix problem with permission and empty laravel folder after push production

    [SOLVE PROBLEM]
    fatal: unable to create temporary file: permission denied' and 'fatal: sha1 file write error: invalid argument'

    First, change bash script in vps machine:
    #####################################
    cd /var/repo/name-folder.git/hooks
    sudo nano post-receive
    #####################################

    On post-receive add sudo:
    #####################################
    #!/bin/sh
    sudo git –work-tree=/var/www/laravel –git-dir=/var/repo/name-folder.git checkout -f
    #####################################

    And after then:
    #####################################
    cd /var/repo/name-folder.git/hooks
    sudo chmod +x post-receive
    #####################################

    Next, fix file permissions in your remote .git dir e.g.
    #####################################
    sudo chmod -R ug+w /var/repo/name-folder.git
    sudo chown -R username-vps-machine:username-vps-machine /var/repo/name-folder.git
    #####################################

    or root:root if you want to assign members of root group for push access.

    Then git repository on the destination host needs to be set as shared, so the following command on remote needs to be run:
    #####################################
    cd /var/repo/name-folder.git
    git config core.sharedRepository group
    #####################################

  16. When I setup local computer on windows to push to production I get an error: "sh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository."

    What should I do?

  17. When i type exit or logout to access local machine, the window just closes. How can I access my local machine like you do?

  18. i setup my server on aws by following your videos. Every git push to remote was working fine but without any apparent reason push to my remote no more updates my live site . in my local repo every change i made is visible . success message when i commit and push to remote. but no effect on live site.. pls someone help me as soon as possible what to do now.

Leave a Reply

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