Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deathmetalgore's avatar

Seamless deployment of a Laravel project via Git and SSH

I have found this older tutorial by Jeffrey on how to make a seamless deployment via Github and SSH so you can have your website online via git push. This was very a very attractive approach and I would like to do that for my Laravel projects. I know about Envoyer, but I'm not really in a position to pay for such a service.

So here I am requesting a similar tutorial that would make the deployment of a Laravel project more attractive than just dropping files into a FTP client.

The struggle here is that a Laravel project in production has its public folder and application split making this deployment process much more complicated (at least for me).

So for example in my localhost the whole project is in one directory, but in production my application is inside /var/www/app and my public folder is in /var/www/html. How would I handle this kind of deployment in this case?

Is there a chance to make a tutorial out of this? I think this would be a very attractive series (or mini-series).

0 likes
6 replies
alenabdula's avatar

If you didn't know about PHP composer, you should get familiar with it.

So for example in my localhost the whole project is in one directory, but in production my application is inside /var/www/app and my public folder is in /var/www/html. How would I handle this kind of deployment in this case?

I would SSH into the server, navigate to /var/www/, and create a folder that represents my project name, so /var/www/app.com, then I would configure my server root to point to /var/www/app.com/public (Laravel default).

Edited to add...

Your initial deploy would be:

  1. Develop Locally
  2. Commit/Push Changes to GitHub or the like
  3. SSH into your server, and navigate to your application root ex. /var/www/app.com and pull in your changes
  4. Run your composer install command to pull in vendors folder (something you shouldn't keep in your repo)
  5. Off you go

Now that was simplistic overview, there's more things to consider like migrations, but I don't know what you understand about all of this to give you more fitting answer. What have you tried so far?

deathmetalgore's avatar

Hey, thanks for your answer @alenabdula . What I thought of doing was create a post-receive request to a page on my server that would execute git pull, composer update and php artisan migrate. Although I don't know how to secure this page exactly so only Github would be able to make calls there.

I just want an automated process where git push from my local server = production deployment, without touching anything else. This is the kind of workflow I am looking for. I understand pretty much everything of what you've told me. Now I'm only stuck at the part to secure that deployment post-receive URL. I'd appreciate your input.

MikeHopley's avatar

So for example in my localhost the whole project is in one directory, but in production my application is inside /var/www/app and my public folder is in /var/www/html. How would I handle this kind of deployment in this case?

You can create a symlink. Something like this maybe?

cd var/www
ln -s app/public html

If I've got my syntax right, this means: "when someone asks for the /var/www/html folder, give them the /var/www/app/public folder instead". Does that solve your problem?

geraintp's avatar

You can create a script using that ssh into your box and pulls the latest master branch etc..

https://deployer.org/

Thats triggered via github or bitbucket webhooks

Please or to participate in this conversation.